Commit 848c651c authored by Paul Jensen's avatar Paul Jensen Committed by Commit Bot

Disable AddressTrackerLinux on Android P+ as it's unnecessary.

Since Android P, ConnectivityManager's NetworkCallback signals (which
NetworkChangeNotifierAutoDetect listens to) include changes to VPNs so
Chrome doesn't need to use AddressTrackerLinux to detect VPNs coming and
going.  Avoiding it should speed up initialization and decrease memory
usage.  This change disables all of NetworkChangeNotifierAndroid's
BlockingThreadObjects for Android P+ as it only contains an
AddressTrackerLinux instantiation.

Change-Id: Ic64f0360d78ee9d75e3f7e5a46ac7e57ccc2dd93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2007525
Commit-Queue: Paul Jensen <pauljensen@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Auto-Submit: Paul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733993}
parent 9f95d16c
......@@ -201,25 +201,33 @@ NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid(
NetworkChangeNotifierDelegateAndroid* delegate)
: NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()),
delegate_(delegate),
blocking_thread_runner_(base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock()})),
blocking_thread_objects_(
new BlockingThreadObjects(),
// Ensure |blocking_thread_objects_| lives on
// |blocking_thread_runner_| to prevent races where
// NetworkChangeNotifierAndroid outlives
// TaskEnvironment. https://crbug.com/938126
base::OnTaskRunnerDeleter(blocking_thread_runner_)),
blocking_thread_objects_(nullptr, base::OnTaskRunnerDeleter(nullptr)),
force_network_handles_supported_for_testing_(false) {
CHECK_EQ(NetId::INVALID, NetworkChangeNotifier::kInvalidNetworkHandle)
<< "kInvalidNetworkHandle doesn't match NetId::INVALID";
delegate_->AddObserver(this);
blocking_thread_runner_->PostTask(
FROM_HERE,
base::BindOnce(&BlockingThreadObjects::Init,
// The Unretained pointer is safe here because it's
// posted before the deleter can post.
base::Unretained(blocking_thread_objects_.get())));
// Since Android P, ConnectivityManager's signals include VPNs so we don't
// need to use AddressTrackerLinux.
if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_P) {
// |blocking_thread_objects_| will live on this runner.
scoped_refptr<base::SequencedTaskRunner> blocking_thread_runner =
base::CreateSequencedTaskRunner({base::ThreadPool(), base::MayBlock()});
blocking_thread_objects_ =
std::unique_ptr<BlockingThreadObjects, base::OnTaskRunnerDeleter>(
new BlockingThreadObjects(),
// Ensure |blocking_thread_objects_| lives on
// |blocking_thread_runner| to prevent races where
// NetworkChangeNotifierAndroid outlives
// TaskEnvironment. https://crbug.com/938126
base::OnTaskRunnerDeleter(blocking_thread_runner));
blocking_thread_runner->PostTask(
FROM_HERE,
base::BindOnce(&BlockingThreadObjects::Init,
// The Unretained pointer is safe here because it's
// posted before the deleter can post.
base::Unretained(blocking_thread_objects_.get())));
}
}
// static
......
......@@ -16,7 +16,6 @@
#include "net/base/network_change_notifier.h"
namespace base {
class SequencedTaskRunner;
struct OnTaskRunnerDeleter;
} // namespace base
......@@ -96,8 +95,6 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierAndroid
NetworkChangeNotifierDelegateAndroid* delegate);
NetworkChangeNotifierDelegateAndroid* const delegate_;
// |blocking_thread_objects_| will live on this runner.
scoped_refptr<base::SequencedTaskRunner> blocking_thread_runner_;
// A collection of objects that must live on blocking sequences. These objects
// listen for notifications and relay the notifications to the registered
// observers without posting back to the thread the object was created on.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment