Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1010)

Unified Diff: components/browser_sync/profile_sync_service.cc

Issue 2555433003: [Sync] Plumb initial type set from engine to DTM. (Closed)
Patch Set: Rebase. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/browser_sync/profile_sync_service.cc
diff --git a/components/browser_sync/profile_sync_service.cc b/components/browser_sync/profile_sync_service.cc
index 67e30c8870e1da8463a7915b441bfd67f789a384..b4a269f8b8beee2d043b5ec65da26393b5aa3480 100644
--- a/components/browser_sync/profile_sync_service.cc
+++ b/components/browser_sync/profile_sync_service.cc
@@ -964,49 +964,8 @@ void ProfileSyncService::UpdateEngineInitUMA(bool success) {
}
}
-void ProfileSyncService::PostEngineInitialization() {
- if (protocol_event_observers_.might_have_observers()) {
- engine_->RequestBufferedProtocolEventsAndEnableForwarding();
- }
-
- if (type_debug_info_observers_.might_have_observers()) {
- engine_->EnableDirectoryTypeDebugInfoForwarding();
- }
-
- // If we have a cached passphrase use it to decrypt/encrypt data now that the
- // engine is initialized. We want to call this before notifying observers in
- // case this operation affects the "passphrase required" status.
- ConsumeCachedPassphraseIfPossible();
-
- // The very first time the engine initializes is effectively the first time
- // we can say we successfully "synced". LastSyncedTime will only be null in
- // this case, because the pref wasn't restored on StartUp.
- if (sync_prefs_.GetLastSyncedTime().is_null()) {
- UpdateLastSyncedTime();
- }
-
- // Auto-start means IsFirstSetupComplete gets set automatically.
- if (start_behavior_ == AUTO_START && !IsFirstSetupComplete()) {
- // This will trigger a configure if it completes setup.
- SetFirstSetupComplete();
- } else if (CanConfigureDataTypes()) {
- ConfigureDataTypeManager();
- }
-
- // Check for a cookie jar mismatch.
- std::vector<gaia::ListedAccount> accounts;
- std::vector<gaia::ListedAccount> signed_out_accounts;
- GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
- if (gaia_cookie_manager_service_ &&
- gaia_cookie_manager_service_->ListAccounts(
- &accounts, &signed_out_accounts, "ChromiumProfileSyncService")) {
- OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error);
- }
-
- NotifyObservers();
-}
-
void ProfileSyncService::OnEngineInitialized(
+ ModelTypeSet initial_types,
const syncer::WeakHandle<syncer::JsBackend>& js_backend,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
debug_info_listener,
@@ -1047,7 +1006,50 @@ void ProfileSyncService::OnEngineInitialized(
local_device_->Initialize(cache_guid, signin_scoped_device_id,
blocking_pool_);
- PostEngineInitialization();
+ if (protocol_event_observers_.might_have_observers()) {
+ engine_->RequestBufferedProtocolEventsAndEnableForwarding();
+ }
+
+ if (type_debug_info_observers_.might_have_observers()) {
+ engine_->EnableDirectoryTypeDebugInfoForwarding();
+ }
+
+ // If we have a cached passphrase use it to decrypt/encrypt data now that the
+ // backend is initialized. We want to call this before notifying observers in
+ // case this operation affects the "passphrase required" status.
+ ConsumeCachedPassphraseIfPossible();
+
+ // The very first time the backend initializes is effectively the first time
+ // we can say we successfully "synced". LastSyncedTime will only be null in
+ // this case, because the pref wasn't restored on StartUp.
+ if (sync_prefs_.GetLastSyncedTime().is_null()) {
+ UpdateLastSyncedTime();
+ }
+
+ data_type_manager_.reset(
+ sync_client_->GetSyncApiComponentFactory()->CreateDataTypeManager(
+ initial_types, debug_info_listener_, &data_type_controllers_, this,
+ engine_.get(), this));
+
+ // Auto-start means IsFirstSetupComplete gets set automatically.
+ if (start_behavior_ == AUTO_START && !IsFirstSetupComplete()) {
+ // This will trigger a configure if it completes setup.
+ SetFirstSetupComplete();
+ } else if (CanConfigureDataTypes()) {
+ ConfigureDataTypeManager();
+ }
+
+ // Check for a cookie jar mismatch.
+ std::vector<gaia::ListedAccount> accounts;
+ std::vector<gaia::ListedAccount> signed_out_accounts;
+ GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
+ if (gaia_cookie_manager_service_ &&
+ gaia_cookie_manager_service_->ListAccounts(
+ &accounts, &signed_out_accounts, "ChromiumProfileSyncService")) {
+ OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error);
+ }
+
+ NotifyObservers();
}
void ProfileSyncService::OnSyncCycleCompleted() {
@@ -1831,12 +1833,8 @@ void ProfileSyncService::ConfigureDataTypeManager() {
}
bool restart = false;
- if (!data_type_manager_) {
+ if (!migrator_) {
restart = true;
- data_type_manager_.reset(
- sync_client_->GetSyncApiComponentFactory()->CreateDataTypeManager(
- debug_info_listener_, &data_type_controllers_, this, engine_.get(),
- this));
// We create the migrator at the same time.
migrator_ = base::MakeUnique<BackendMigrator>(
« no previous file with comments | « components/browser_sync/profile_sync_service.h ('k') | components/browser_sync/profile_sync_service_autofill_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698