Migrate SyncSchedulerImpl to NetworkConnectionTracker
This migrates SyncSchedulerImpl from NetworkChangeNotifier to
NetworkConnectionTracker, which works with the network service enabled.
Bug: 883126
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I3482c04e6943df0b928eaebd48d9b511c6cb913a
Reviewed-on: https://chromium-review.googlesource.com/1222699
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Marc Treib <[email protected]>
Commit-Queue: Robbie McElrath <[email protected]>
Cr-Commit-Position: refs/heads/master@{#592459}
diff --git a/components/browser_sync/abstract_profile_sync_service_test.cc b/components/browser_sync/abstract_profile_sync_service_test.cc
index f23bf07..1552562 100644
--- a/components/browser_sync/abstract_profile_sync_service_test.cc
+++ b/components/browser_sync/abstract_profile_sync_service_test.cc
@@ -21,6 +21,7 @@
#include "components/sync/protocol/sync.pb.h"
#include "components/sync/syncable/test_user_share.h"
#include "google_apis/gaia/gaia_constants.h"
+#include "services/network/test/test_network_connection_tracker.h"
using syncer::SyncBackendHostImpl;
using syncer::ModelType;
@@ -80,7 +81,8 @@
params.http_factory_getter = base::Bind(&GetHttpPostProviderFactory);
params.sync_manager_factory =
std::make_unique<syncer::SyncManagerFactoryForProfileSyncTest>(
- std::move(callback_));
+ std::move(callback_),
+ network::TestNetworkConnectionTracker::GetInstance());
params.credentials.email = "[email protected]";
params.credentials.sync_token = "token";
params.credentials.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope);
diff --git a/components/browser_sync/profile_sync_service.cc b/components/browser_sync/profile_sync_service.cc
index 975099e8..e763fb9 100644
--- a/components/browser_sync/profile_sync_service.cc
+++ b/components/browser_sync/profile_sync_service.cc
@@ -189,6 +189,7 @@
network_time_update_callback_(
std::move(init_params.network_time_update_callback)),
url_loader_factory_(std::move(init_params.url_loader_factory)),
+ network_connection_tracker_(init_params.network_connection_tracker),
is_first_time_sync_configure_(false),
engine_initialized_(false),
sync_disabled_by_admin_(false),
@@ -636,7 +637,8 @@
sync_client_->GetInvalidationService();
params.invalidator_client_id =
invalidator ? invalidator->GetInvalidatorClientId() : "",
- params.sync_manager_factory = std::make_unique<syncer::SyncManagerFactory>();
+ params.sync_manager_factory =
+ std::make_unique<syncer::SyncManagerFactory>(network_connection_tracker_);
// The first time we start up the engine we want to ensure we have a clean
// directory, so delete any old one that might be there.
params.delete_sync_data_folder = !IsFirstSetupComplete();
diff --git a/components/browser_sync/profile_sync_service.h b/components/browser_sync/profile_sync_service.h
index 6f0be68..9a8e46dc 100644
--- a/components/browser_sync/profile_sync_service.h
+++ b/components/browser_sync/profile_sync_service.h
@@ -56,6 +56,7 @@
}
namespace network {
+class NetworkConnectionTracker;
class SharedURLLoaderFactory;
} // namespace network
@@ -218,6 +219,7 @@
StartBehavior start_behavior = MANUAL_START;
syncer::NetworkTimeUpdateCallback network_time_update_callback;
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory;
+ network::NetworkConnectionTracker* network_connection_tracker;
std::string debug_identifier;
version_info::Channel channel = version_info::Channel::UNKNOWN;
bool user_events_separate_pref_group = false;
@@ -680,6 +682,9 @@
// The URL loader factory for the sync.
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
+ // The global NetworkConnectionTracker instance.
+ network::NetworkConnectionTracker* network_connection_tracker_;
+
// Indicates if this is the first time sync is being configured.
// This is set to true if last synced time is not set at the time of
// OnEngineInitialized().
diff --git a/components/browser_sync/profile_sync_test_util.cc b/components/browser_sync/profile_sync_test_util.cc
index 7babee3..07ab16b5 100644
--- a/components/browser_sync/profile_sync_test_util.cc
+++ b/components/browser_sync/profile_sync_test_util.cc
@@ -25,6 +25,7 @@
#include "components/sync_sessions/local_session_event_router.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
+#include "services/network/test/test_network_connection_tracker.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -293,6 +294,8 @@
init_params.url_loader_factory =
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_);
+ init_params.network_connection_tracker =
+ network::TestNetworkConnectionTracker::GetInstance();
init_params.debug_identifier = "dummyDebugName";
init_params.channel = version_info::Channel::UNKNOWN;