Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" | |
| 20 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 21 #include "base/timer.h" | 20 #include "base/timer.h" |
| 22 #include "base/tracked_objects.h" | 21 #include "base/tracked_objects.h" |
| 23 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 24 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/signin/token_service.h" | 25 #include "chrome/browser/signin/token_service.h" |
| 27 #include "chrome/browser/signin/token_service_factory.h" | 26 #include "chrome/browser/signin/token_service_factory.h" |
| 28 #include "chrome/browser/sync/glue/bridged_invalidator.h" | 27 #include "chrome/browser/sync/glue/bridged_invalidator.h" |
| 29 #include "chrome/browser/sync/glue/change_processor.h" | 28 #include "chrome/browser/sync/glue/change_processor.h" |
| 30 #include "chrome/browser/sync/glue/chrome_encryptor.h" | 29 #include "chrome/browser/sync/glue/chrome_encryptor.h" |
| 31 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" | 30 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" |
| 32 #include "chrome/browser/sync/glue/device_info.h" | 31 #include "chrome/browser/sync/glue/device_info.h" |
| 33 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 32 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
| 33 #include "chrome/browser/sync/glue/synced_device_tracker.h" | |
| 34 #include "chrome/browser/sync/glue/device_info.h" | |
|
Nicolas Zea
2012/11/16 19:42:27
abc order
rlarocque
2012/11/17 00:07:21
That file was included twice, actually. Must have
| |
| 34 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 35 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 35 #include "chrome/browser/sync/sync_prefs.h" | 36 #include "chrome/browser/sync/sync_prefs.h" |
| 36 #include "chrome/common/chrome_notification_types.h" | 37 #include "chrome/common/chrome_notification_types.h" |
| 37 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 38 #include "chrome/common/chrome_version_info.h" | 39 #include "chrome/common/chrome_version_info.h" |
| 39 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 40 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/common/content_client.h" | 42 #include "content/public/common/content_client.h" |
| 42 #include "google_apis/gaia/gaia_constants.h" | 43 #include "google_apis/gaia/gaia_constants.h" |
| 43 #include "jingle/notifier/base/notification_method.h" | 44 #include "jingle/notifier/base/notification_method.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 void DoSetEncryptionPassphrase(const std::string& passphrase, | 160 void DoSetEncryptionPassphrase(const std::string& passphrase, |
| 160 bool is_explicit); | 161 bool is_explicit); |
| 161 | 162 |
| 162 // Called to decrypt the pending keys. | 163 // Called to decrypt the pending keys. |
| 163 void DoSetDecryptionPassphrase(const std::string& passphrase); | 164 void DoSetDecryptionPassphrase(const std::string& passphrase); |
| 164 | 165 |
| 165 // Called to turn on encryption of all sync data as well as | 166 // Called to turn on encryption of all sync data as well as |
| 166 // reencrypt everything. | 167 // reencrypt everything. |
| 167 void DoEnableEncryptEverything(); | 168 void DoEnableEncryptEverything(); |
| 168 | 169 |
| 169 // Called to load sync encryption state and re-encrypt any types | 170 // Called to perform tasks which require the control data to be downloaded. |
| 170 // needing encryption as necessary. | 171 // This includes refreshing encryption, setting up the device info change |
| 171 void DoAssociateNigori(); | 172 // processor, etc. |
| 173 void DoInitialProcessControlTypes(); | |
| 174 | |
| 175 void FinishInitialProcessControlTypes(); | |
|
Nicolas Zea
2012/11/16 19:42:27
Comment about why these two are separated?
rlarocque
2012/11/17 00:07:21
Done.
| |
| 172 | 176 |
| 173 // The shutdown order is a bit complicated: | 177 // The shutdown order is a bit complicated: |
| 174 // 1) From |sync_thread_|, invoke the syncapi Shutdown call to do | 178 // 1) From |sync_thread_|, invoke the syncapi Shutdown call to do |
| 175 // a final SaveChanges, and close sqlite handles. | 179 // a final SaveChanges, and close sqlite handles. |
| 176 // 2) Then, from |frontend_loop_|, halt the sync_thread_ (which is | 180 // 2) Then, from |frontend_loop_|, halt the sync_thread_ (which is |
| 177 // a blocking call). This causes syncapi thread-exit handlers | 181 // a blocking call). This causes syncapi thread-exit handlers |
| 178 // to run and make use of cached pointers to various components | 182 // to run and make use of cached pointers to various components |
| 179 // owned implicitly by us. | 183 // owned implicitly by us. |
| 180 // 3) Destroy this Core. That will delete syncapi components in a | 184 // 3) Destroy this Core. That will delete syncapi components in a |
| 181 // safe order because the thread that was using them has exited | 185 // safe order because the thread that was using them has exited |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 196 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); | 200 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); |
| 197 void DoRetryConfiguration( | 201 void DoRetryConfiguration( |
| 198 const base::Closure& retry_callback); | 202 const base::Closure& retry_callback); |
| 199 | 203 |
| 200 // Set the base request context to use when making HTTP calls. | 204 // Set the base request context to use when making HTTP calls. |
| 201 // This method will add a reference to the context to persist it | 205 // This method will add a reference to the context to persist it |
| 202 // on the IO thread. Must be removed from IO thread. | 206 // on the IO thread. Must be removed from IO thread. |
| 203 | 207 |
| 204 syncer::SyncManager* sync_manager() { return sync_manager_.get(); } | 208 syncer::SyncManager* sync_manager() { return sync_manager_.get(); } |
| 205 | 209 |
| 210 SyncedDeviceTracker* synced_device_tracker() { | |
| 211 return synced_device_tracker_.get(); | |
| 212 } | |
| 213 | |
| 206 // Delete the sync data folder to cleanup backend data. Happens the first | 214 // Delete the sync data folder to cleanup backend data. Happens the first |
| 207 // time sync is enabled for a user (to prevent accidentally reusing old | 215 // time sync is enabled for a user (to prevent accidentally reusing old |
| 208 // sync databases), as well as shutdown when you're no longer syncing. | 216 // sync databases), as well as shutdown when you're no longer syncing. |
| 209 void DeleteSyncDataFolder(); | 217 void DeleteSyncDataFolder(); |
| 210 | 218 |
| 211 private: | 219 private: |
| 212 friend class base::RefCountedThreadSafe<SyncBackendHost::Core>; | 220 friend class base::RefCountedThreadSafe<SyncBackendHost::Core>; |
| 213 friend class SyncBackendHostForProfileSyncTest; | 221 friend class SyncBackendHostForProfileSyncTest; |
| 214 | 222 |
| 215 virtual ~Core(); | 223 virtual ~Core(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 // Our parent's notification bridge (not owned). Non-NULL only | 256 // Our parent's notification bridge (not owned). Non-NULL only |
| 249 // between calls to DoInitialize() and DoShutdown(). | 257 // between calls to DoInitialize() and DoShutdown(). |
| 250 ChromeSyncNotificationBridge* chrome_sync_notification_bridge_; | 258 ChromeSyncNotificationBridge* chrome_sync_notification_bridge_; |
| 251 | 259 |
| 252 // The timer used to periodically call SaveChanges. | 260 // The timer used to periodically call SaveChanges. |
| 253 scoped_ptr<base::RepeatingTimer<Core> > save_changes_timer_; | 261 scoped_ptr<base::RepeatingTimer<Core> > save_changes_timer_; |
| 254 | 262 |
| 255 // Our encryptor, which uses Chrome's encryption functions. | 263 // Our encryptor, which uses Chrome's encryption functions. |
| 256 ChromeEncryptor encryptor_; | 264 ChromeEncryptor encryptor_; |
| 257 | 265 |
| 266 // A special ChangeProcessor that tracks the DEVICE_INFO type for us. | |
| 267 scoped_ptr<SyncedDeviceTracker> synced_device_tracker_; | |
| 268 | |
| 258 // The top-level syncapi entry point. Lives on the sync thread. | 269 // The top-level syncapi entry point. Lives on the sync thread. |
| 259 scoped_ptr<syncer::SyncManager> sync_manager_; | 270 scoped_ptr<syncer::SyncManager> sync_manager_; |
| 260 | 271 |
| 261 // Whether or not we registered with |sync_manager_| as an invalidation | 272 // Whether or not we registered with |sync_manager_| as an invalidation |
| 262 // handler. Necessary since we may end up trying to unregister before we | 273 // handler. Necessary since we may end up trying to unregister before we |
| 263 // register in tests (in synchronous initialization mode). | 274 // register in tests (in synchronous initialization mode). |
| 264 // | 275 // |
| 265 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). | 276 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). |
| 266 bool registered_as_invalidation_handler_; | 277 bool registered_as_invalidation_handler_; |
| 267 | 278 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 void SyncBackendHost::GetModelSafeRoutingInfo( | 765 void SyncBackendHost::GetModelSafeRoutingInfo( |
| 755 syncer::ModelSafeRoutingInfo* out) const { | 766 syncer::ModelSafeRoutingInfo* out) const { |
| 756 if (initialized()) { | 767 if (initialized()) { |
| 757 CHECK(registrar_.get()); | 768 CHECK(registrar_.get()); |
| 758 registrar_->GetModelSafeRoutingInfo(out); | 769 registrar_->GetModelSafeRoutingInfo(out); |
| 759 } else { | 770 } else { |
| 760 NOTREACHED(); | 771 NOTREACHED(); |
| 761 } | 772 } |
| 762 } | 773 } |
| 763 | 774 |
| 775 SyncedDeviceTracker* SyncBackendHost::GetSyncedDeviceTrackerForTest() { | |
| 776 return core_->synced_device_tracker(); | |
| 777 } | |
| 778 | |
| 764 void SyncBackendHost::InitCore(const DoInitializeOptions& options) { | 779 void SyncBackendHost::InitCore(const DoInitializeOptions& options) { |
| 765 sync_thread_.message_loop()->PostTask(FROM_HERE, | 780 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 766 base::Bind(&SyncBackendHost::Core::DoInitialize, core_.get(), options)); | 781 base::Bind(&SyncBackendHost::Core::DoInitialize, core_.get(), options)); |
| 767 } | 782 } |
| 768 | 783 |
| 769 void SyncBackendHost::RequestConfigureSyncer( | 784 void SyncBackendHost::RequestConfigureSyncer( |
| 770 syncer::ConfigureReason reason, | 785 syncer::ConfigureReason reason, |
| 771 syncer::ModelTypeSet types_to_config, | 786 syncer::ModelTypeSet types_to_config, |
| 772 const syncer::ModelSafeRoutingInfo& routing_info, | 787 const syncer::ModelSafeRoutingInfo& routing_info, |
| 773 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 788 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 #endif | 1087 #endif |
| 1073 | 1088 |
| 1074 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); | 1089 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); |
| 1075 sync_manager_->AddObserver(this); | 1090 sync_manager_->AddObserver(this); |
| 1076 sync_manager_->Init( | 1091 sync_manager_->Init( |
| 1077 sync_data_folder_path_, | 1092 sync_data_folder_path_, |
| 1078 options.event_handler, | 1093 options.event_handler, |
| 1079 options.service_url.host() + options.service_url.path(), | 1094 options.service_url.host() + options.service_url.path(), |
| 1080 options.service_url.EffectiveIntPort(), | 1095 options.service_url.EffectiveIntPort(), |
| 1081 options.service_url.SchemeIsSecure(), | 1096 options.service_url.SchemeIsSecure(), |
| 1082 BrowserThread::GetBlockingPool(), | |
| 1083 options.make_http_bridge_factory_fn.Run().Pass(), | 1097 options.make_http_bridge_factory_fn.Run().Pass(), |
| 1084 options.workers, | 1098 options.workers, |
| 1085 options.extensions_activity_monitor, | 1099 options.extensions_activity_monitor, |
| 1086 options.registrar /* as SyncManager::ChangeDelegate */, | 1100 options.registrar /* as SyncManager::ChangeDelegate */, |
| 1087 options.credentials, | 1101 options.credentials, |
| 1088 scoped_ptr<syncer::Invalidator>(new BridgedInvalidator( | 1102 scoped_ptr<syncer::Invalidator>(new BridgedInvalidator( |
| 1089 options.chrome_sync_notification_bridge, | 1103 options.chrome_sync_notification_bridge, |
| 1090 options.invalidator_factory->CreateInvalidator(), | 1104 options.invalidator_factory->CreateInvalidator(), |
| 1091 kDefaultInvalidatorState)), | 1105 kDefaultInvalidatorState)), |
| 1092 options.restored_key_for_bootstrapping, | 1106 options.restored_key_for_bootstrapping, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1136 sync_manager_->UpdateRegisteredInvalidationIds(this, ids); | 1150 sync_manager_->UpdateRegisteredInvalidationIds(this, ids); |
| 1137 } | 1151 } |
| 1138 } | 1152 } |
| 1139 | 1153 |
| 1140 void SyncBackendHost::Core::DoStartSyncing( | 1154 void SyncBackendHost::Core::DoStartSyncing( |
| 1141 const syncer::ModelSafeRoutingInfo& routing_info) { | 1155 const syncer::ModelSafeRoutingInfo& routing_info) { |
| 1142 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1156 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1143 sync_manager_->StartSyncingNormally(routing_info); | 1157 sync_manager_->StartSyncingNormally(routing_info); |
| 1144 } | 1158 } |
| 1145 | 1159 |
| 1146 void SyncBackendHost::Core::DoAssociateNigori() { | |
| 1147 DCHECK_EQ(MessageLoop::current(), sync_loop_); | |
| 1148 sync_manager_->GetEncryptionHandler()->Init(); | |
| 1149 host_.Call(FROM_HERE, | |
| 1150 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop, | |
| 1151 true); | |
| 1152 } | |
| 1153 | |
| 1154 void SyncBackendHost::Core::DoSetEncryptionPassphrase( | 1160 void SyncBackendHost::Core::DoSetEncryptionPassphrase( |
| 1155 const std::string& passphrase, | 1161 const std::string& passphrase, |
| 1156 bool is_explicit) { | 1162 bool is_explicit) { |
| 1157 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1163 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1158 sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase( | 1164 sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase( |
| 1159 passphrase, is_explicit); | 1165 passphrase, is_explicit); |
| 1160 } | 1166 } |
| 1161 | 1167 |
| 1168 void SyncBackendHost::Core::DoInitialProcessControlTypes() { | |
| 1169 DCHECK_EQ(MessageLoop::current(), sync_loop_); | |
| 1170 | |
| 1171 DVLOG(1) << "Initilalizing Control Types"; | |
| 1172 | |
| 1173 // Initialize encryption. | |
| 1174 sync_manager_->GetEncryptionHandler()->Init(); | |
| 1175 | |
| 1176 // Initialize device info. | |
| 1177 synced_device_tracker_.reset( | |
| 1178 new SyncedDeviceTracker(sync_manager_->cache_guid())); | |
| 1179 if (sync_manager_->GetUserShare()) { // NULL in some tests. | |
| 1180 DVLOG(1) << "Initializing DeviceInfo type"; | |
| 1181 registrar_->ActivateDataType(syncer::DEVICE_INFO, | |
|
Nicolas Zea
2012/11/16 19:42:27
Why not activate the datatype after initialization
rlarocque
2012/11/17 00:07:21
It made more sense to me to do it after the activa
Nicolas Zea
2012/11/17 00:31:01
InitLocalDeviceInfo seems to me like an "Associate
| |
| 1182 syncer::GROUP_PASSIVE, | |
| 1183 synced_device_tracker_.get(), | |
| 1184 sync_manager_->GetUserShare()); | |
| 1185 synced_device_tracker_->InitLocalDeviceInfo( | |
| 1186 base::Bind(&SyncBackendHost::Core::FinishInitialProcessControlTypes, | |
| 1187 this)); | |
| 1188 } else { | |
| 1189 DVLOG(1) << "Skipping initialization of DeviceInfo"; | |
| 1190 FinishInitialProcessControlTypes(); | |
| 1191 } | |
| 1192 } | |
| 1193 | |
| 1194 void SyncBackendHost::Core::FinishInitialProcessControlTypes() { | |
|
Nicolas Zea
2012/11/16 19:42:27
I think the naming convention prefers DoFinishInit
rlarocque
2012/11/17 00:07:21
I think you're right. I renamed it.
| |
| 1195 host_.Call( | |
| 1196 FROM_HERE, | |
| 1197 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop, | |
| 1198 true); | |
| 1199 } | |
| 1200 | |
| 1162 void SyncBackendHost::Core::DoSetDecryptionPassphrase( | 1201 void SyncBackendHost::Core::DoSetDecryptionPassphrase( |
| 1163 const std::string& passphrase) { | 1202 const std::string& passphrase) { |
| 1164 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1203 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1165 sync_manager_->GetEncryptionHandler()->SetDecryptionPassphrase( | 1204 sync_manager_->GetEncryptionHandler()->SetDecryptionPassphrase( |
| 1166 passphrase); | 1205 passphrase); |
| 1167 } | 1206 } |
| 1168 | 1207 |
| 1169 void SyncBackendHost::Core::DoEnableEncryptEverything() { | 1208 void SyncBackendHost::Core::DoEnableEncryptEverything() { |
| 1170 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1209 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1171 sync_manager_->GetEncryptionHandler()->EnableEncryptEverything(); | 1210 sync_manager_->GetEncryptionHandler()->EnableEncryptEverything(); |
| 1172 } | 1211 } |
| 1173 | 1212 |
| 1174 void SyncBackendHost::Core::DoStopSyncManagerForShutdown( | 1213 void SyncBackendHost::Core::DoStopSyncManagerForShutdown( |
| 1175 const base::Closure& closure) { | 1214 const base::Closure& closure) { |
| 1176 if (sync_manager_.get()) { | 1215 if (sync_manager_.get()) { |
| 1177 sync_manager_->StopSyncingForShutdown(closure); | 1216 sync_manager_->StopSyncingForShutdown(closure); |
| 1178 } else { | 1217 } else { |
| 1179 sync_loop_->PostTask(FROM_HERE, closure); | 1218 sync_loop_->PostTask(FROM_HERE, closure); |
| 1180 } | 1219 } |
| 1181 } | 1220 } |
| 1182 | 1221 |
| 1183 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { | 1222 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { |
| 1184 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1223 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1224 // It's safe to do this even if the type was never activated. | |
| 1225 registrar_->DeactivateDataType(syncer::DEVICE_INFO); | |
| 1226 synced_device_tracker_.reset(); | |
| 1227 | |
| 1185 DoDestroySyncManager(); | 1228 DoDestroySyncManager(); |
| 1186 | 1229 |
| 1187 chrome_sync_notification_bridge_ = NULL; | 1230 chrome_sync_notification_bridge_ = NULL; |
| 1188 registrar_ = NULL; | 1231 registrar_ = NULL; |
| 1189 | 1232 |
| 1190 if (sync_disabled) | 1233 if (sync_disabled) |
| 1191 DeleteSyncDataFolder(); | 1234 DeleteSyncDataFolder(); |
| 1192 | 1235 |
| 1193 sync_loop_ = NULL; | 1236 sync_loop_ = NULL; |
| 1194 | 1237 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1320 | 1363 |
| 1321 // Run initialization state machine. | 1364 // Run initialization state machine. |
| 1322 switch (initialization_state_) { | 1365 switch (initialization_state_) { |
| 1323 case NOT_INITIALIZED: | 1366 case NOT_INITIALIZED: |
| 1324 // This configuration should result in a download request if the nigori | 1367 // This configuration should result in a download request if the nigori |
| 1325 // type's initial_sync_ended bit is unset. If the download request | 1368 // type's initial_sync_ended bit is unset. If the download request |
| 1326 // contains progress markers, there is a risk that the server will try to | 1369 // contains progress markers, there is a risk that the server will try to |
| 1327 // trigger migration. That would be disastrous, so we must rely on the | 1370 // trigger migration. That would be disastrous, so we must rely on the |
| 1328 // sync manager to ensure that this type never has both progress markers | 1371 // sync manager to ensure that this type never has both progress markers |
| 1329 // and !initial_sync_ended. | 1372 // and !initial_sync_ended. |
| 1330 initialization_state_ = DOWNLOADING_NIGORI; | 1373 initialization_state_ = DOWNLOADING_CONTROL_TYPES; |
| 1331 ConfigureDataTypes( | 1374 ConfigureDataTypes( |
| 1332 syncer::CONFIGURE_REASON_NEW_CLIENT, | 1375 syncer::CONFIGURE_REASON_NEW_CLIENT, |
| 1333 syncer::ModelTypeSet(syncer::ControlTypes()), | 1376 syncer::ModelTypeSet(syncer::ControlTypes()), |
| 1334 syncer::ModelTypeSet(), | 1377 syncer::ModelTypeSet(), |
| 1335 // Calls back into this function. | 1378 // Calls back into this function. |
| 1336 base::Bind( | 1379 base::Bind( |
| 1337 &SyncBackendHost:: | 1380 &SyncBackendHost:: |
| 1338 HandleNigoriConfigurationCompletedOnFrontendLoop, | 1381 HandleNigoriConfigurationCompletedOnFrontendLoop, |
| 1339 weak_ptr_factory_.GetWeakPtr()), | 1382 weak_ptr_factory_.GetWeakPtr()), |
| 1340 base::Bind(&SyncBackendHost::OnNigoriDownloadRetry, | 1383 base::Bind(&SyncBackendHost::OnNigoriDownloadRetry, |
| 1341 weak_ptr_factory_.GetWeakPtr())); | 1384 weak_ptr_factory_.GetWeakPtr())); |
| 1342 break; | 1385 break; |
| 1343 case DOWNLOADING_NIGORI: | 1386 case DOWNLOADING_CONTROL_TYPES: |
| 1344 initialization_state_ = ASSOCIATING_NIGORI; | 1387 initialization_state_ = PROCESSING_CONTROL_TYPES; |
| 1345 // Triggers OnEncryptedTypesChanged() and OnEncryptionComplete() | 1388 // Updates encryption and other metadata. Will call |
| 1346 // if necessary. | 1389 // OnEncryptedTypesChanged() and OnEncryptionComplete() if necessary. |
| 1347 sync_thread_.message_loop()->PostTask( | 1390 InitialProcessControlTypes( |
| 1348 FROM_HERE, | 1391 base::Bind( |
| 1349 base::Bind(&SyncBackendHost::Core::DoAssociateNigori, | 1392 &SyncBackendHost:: |
| 1350 core_.get())); | 1393 HandleInitializationCompletedOnFrontendLoop, |
| 1394 weak_ptr_factory_.GetWeakPtr(), true)); | |
| 1351 break; | 1395 break; |
| 1352 case ASSOCIATING_NIGORI: | 1396 case PROCESSING_CONTROL_TYPES: |
| 1353 initialization_state_ = INITIALIZED; | 1397 initialization_state_ = INITIALIZED; |
| 1354 // Now that we've downloaded the nigori node, we can see if there are any | 1398 // Now that we've downloaded the nigori node, we can see if there are any |
| 1355 // experimental types to enable. This should be done before we inform | 1399 // experimental types to enable. This should be done before we inform |
| 1356 // the frontend to ensure they're visible in the customize screen. | 1400 // the frontend to ensure they're visible in the customize screen. |
| 1357 AddExperimentalTypes(); | 1401 AddExperimentalTypes(); |
| 1358 frontend_->OnBackendInitialized(js_backend_, | 1402 frontend_->OnBackendInitialized(js_backend_, |
| 1359 debug_info_listener_, | 1403 debug_info_listener_, |
| 1360 true); | 1404 true); |
| 1361 js_backend_.Reset(); | 1405 js_backend_.Reset(); |
| 1362 break; | 1406 break; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1521 | 1565 |
| 1522 frontend_->OnConnectionStatusChange(status); | 1566 frontend_->OnConnectionStatusChange(status); |
| 1523 } | 1567 } |
| 1524 | 1568 |
| 1525 void SyncBackendHost::HandleNigoriConfigurationCompletedOnFrontendLoop( | 1569 void SyncBackendHost::HandleNigoriConfigurationCompletedOnFrontendLoop( |
| 1526 const syncer::ModelTypeSet failed_configuration_types) { | 1570 const syncer::ModelTypeSet failed_configuration_types) { |
| 1527 HandleInitializationCompletedOnFrontendLoop( | 1571 HandleInitializationCompletedOnFrontendLoop( |
| 1528 failed_configuration_types.Empty()); | 1572 failed_configuration_types.Empty()); |
| 1529 } | 1573 } |
| 1530 | 1574 |
| 1575 void SyncBackendHost::InitialProcessControlTypes( | |
| 1576 const base::Closure& done_callback) { | |
| 1577 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | |
| 1578 // Then forward the request to the sync thread. | |
| 1579 sync_thread_.message_loop()->PostTask( | |
| 1580 FROM_HERE, | |
| 1581 base::Bind(&SyncBackendHost::Core::DoInitialProcessControlTypes, | |
| 1582 core_.get())); | |
| 1583 } | |
| 1584 | |
| 1531 #undef SDVLOG | 1585 #undef SDVLOG |
| 1532 | 1586 |
| 1533 #undef SLOG | 1587 #undef SLOG |
| 1534 | 1588 |
| 1535 } // namespace browser_sync | 1589 } // namespace browser_sync |
| OLD | NEW |