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> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 typedef GoogleServiceAuthError AuthError; | 62 typedef GoogleServiceAuthError AuthError; |
63 | 63 |
64 namespace browser_sync { | 64 namespace browser_sync { |
65 | 65 |
66 using content::BrowserThread; | 66 using content::BrowserThread; |
67 using syncer::InternalComponentsFactory; | 67 using syncer::InternalComponentsFactory; |
68 using syncer::InternalComponentsFactoryImpl; | 68 using syncer::InternalComponentsFactoryImpl; |
69 using syncer::sessions::SyncSessionSnapshot; | 69 using syncer::sessions::SyncSessionSnapshot; |
70 using syncer::SyncCredentials; | 70 using syncer::SyncCredentials; |
71 | 71 |
72 const char kHandlerName[] = "SyncBackendHost::Core"; | |
73 | |
72 // Helper macros to log with the syncer thread name; useful when there | 74 // Helper macros to log with the syncer thread name; useful when there |
73 // are multiple syncers involved. | 75 // are multiple syncers involved. |
74 | 76 |
75 #define SLOG(severity) LOG(severity) << name_ << ": " | 77 #define SLOG(severity) LOG(severity) << name_ << ": " |
76 | 78 |
77 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " | 79 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " |
78 | 80 |
79 class SyncBackendHost::Core | 81 class SyncBackendHost::Core |
80 : public base::RefCountedThreadSafe<SyncBackendHost::Core>, | 82 : public base::RefCountedThreadSafe<SyncBackendHost::Core>, |
81 public syncer::SyncManager::Observer, | 83 public syncer::SyncManager::Observer, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 // a final SaveChanges, and close sqlite handles. | 165 // a final SaveChanges, and close sqlite handles. |
164 // 2) Then, from |frontend_loop_|, halt the sync_thread_ (which is | 166 // 2) Then, from |frontend_loop_|, halt the sync_thread_ (which is |
165 // a blocking call). This causes syncapi thread-exit handlers | 167 // a blocking call). This causes syncapi thread-exit handlers |
166 // to run and make use of cached pointers to various components | 168 // to run and make use of cached pointers to various components |
167 // owned implicitly by us. | 169 // owned implicitly by us. |
168 // 3) Destroy this Core. That will delete syncapi components in a | 170 // 3) Destroy this Core. That will delete syncapi components in a |
169 // safe order because the thread that was using them has exited | 171 // safe order because the thread that was using them has exited |
170 // (in step 2). | 172 // (in step 2). |
171 void DoStopSyncManagerForShutdown(const base::Closure& closure); | 173 void DoStopSyncManagerForShutdown(const base::Closure& closure); |
172 void DoShutdown(bool stopping_sync); | 174 void DoShutdown(bool stopping_sync); |
175 void DoDestroySyncManager(); | |
173 | 176 |
174 // Configuration methods that must execute on sync loop. | 177 // Configuration methods that must execute on sync loop. |
175 void DoConfigureSyncer( | 178 void DoConfigureSyncer( |
176 syncer::ConfigureReason reason, | 179 syncer::ConfigureReason reason, |
177 syncer::ModelTypeSet types_to_config, | 180 syncer::ModelTypeSet types_to_config, |
178 const syncer::ModelSafeRoutingInfo routing_info, | 181 const syncer::ModelSafeRoutingInfo routing_info, |
179 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 182 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
180 const base::Closure& retry_callback); | 183 const base::Closure& retry_callback); |
181 void DoFinishConfigureDataTypes( | 184 void DoFinishConfigureDataTypes( |
182 syncer::ModelTypeSet types_to_config, | 185 syncer::ModelTypeSet types_to_config, |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 &SyncBackendHost::Core::DoStopSyncManagerForShutdown, | 537 &SyncBackendHost::Core::DoStopSyncManagerForShutdown, |
535 core_.get(), | 538 core_.get(), |
536 closure)); | 539 closure)); |
537 } else { | 540 } else { |
538 core_->DoStopSyncManagerForShutdown(closure); | 541 core_->DoStopSyncManagerForShutdown(closure); |
539 } | 542 } |
540 } | 543 } |
541 | 544 |
542 void SyncBackendHost::StopSyncingForShutdown() { | 545 void SyncBackendHost::StopSyncingForShutdown() { |
543 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 546 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
547 | |
548 // Immediately stop sending messages to the frontend. | |
549 frontend_ = NULL; | |
550 | |
544 // Thread shutdown should occur in the following order: | 551 // Thread shutdown should occur in the following order: |
545 // - Sync Thread | 552 // - Sync Thread |
546 // - UI Thread (stops some time after we return from this call). | 553 // - UI Thread (stops some time after we return from this call). |
547 // | 554 // |
548 // In order to acheive this, we first shutdown components from the UI thread | 555 // In order to achieve this, we first shutdown components from the UI thread |
549 // and send signals to abort components that may be busy on the sync thread. | 556 // and send signals to abort components that may be busy on the sync thread. |
550 // The callback (OnSyncerShutdownComplete) will happen on the sync thread, | 557 // The callback (OnSyncerShutdownComplete) will happen on the sync thread, |
551 // after which we'll shutdown components on the sync thread, and then be | 558 // after which we'll shutdown components on the sync thread, and then be |
552 // able to stop the sync loop. | 559 // able to stop the sync loop. |
553 if (sync_thread_.IsRunning()) { | 560 if (sync_thread_.IsRunning()) { |
554 StopSyncManagerForShutdown( | 561 StopSyncManagerForShutdown( |
555 base::Bind(&SyncBackendRegistrar::OnSyncerShutdownComplete, | 562 base::Bind(&SyncBackendRegistrar::OnSyncerShutdownComplete, |
556 base::Unretained(registrar_.get()))); | 563 base::Unretained(registrar_.get()))); |
557 | 564 |
558 // Before joining the sync_thread_, we wait for the UIModelWorker to | 565 // Before joining the sync_thread_, we wait for the UIModelWorker to |
559 // give us the green light that it is not depending on the frontend_loop_ | 566 // give us the green light that it is not depending on the frontend_loop_ |
560 // to process any more tasks. Stop() blocks until this termination | 567 // to process any more tasks. Stop() blocks until this termination |
561 // condition is true. | 568 // condition is true. |
562 base::Time stop_registrar_start_time = base::Time::Now(); | 569 base::Time stop_registrar_start_time = base::Time::Now(); |
563 if (registrar_.get()) | 570 if (registrar_.get()) |
564 registrar_->StopOnUIThread(); | 571 registrar_->StopOnUIThread(); |
565 base::TimeDelta stop_registrar_time = base::Time::Now() - | 572 base::TimeDelta stop_registrar_time = base::Time::Now() - |
566 stop_registrar_start_time; | 573 stop_registrar_start_time; |
567 UMA_HISTOGRAM_TIMES("Sync.Shutdown.StopRegistrarTime", | 574 UMA_HISTOGRAM_TIMES("Sync.Shutdown.StopRegistrarTime", |
568 stop_registrar_time); | 575 stop_registrar_time); |
569 } else { | 576 } else { |
570 // If the sync thread isn't running, then the syncer is effectively | 577 // If the sync thread isn't running, then the syncer is effectively |
571 // stopped. Moreover, it implies that we never attempted initialization, | 578 // stopped. Moreover, it implies that we never attempted initialization, |
572 // so the registrar won't need stopping either. | 579 // so the registrar won't need stopping either. |
573 DCHECK_EQ(NOT_ATTEMPTED, initialization_state_); | 580 DCHECK_EQ(initialization_state_, NOT_ATTEMPTED); |
tim (not reviewing)
2012/08/07 16:39:38
hm, so I've always followed the pattern from ASSER
akalin
2012/08/07 17:19:23
I think that's only because EXPECT makes a distinc
| |
574 DCHECK(!registrar_.get()); | 581 DCHECK(!registrar_.get()); |
575 } | 582 } |
576 } | 583 } |
577 | 584 |
578 void SyncBackendHost::Shutdown(bool sync_disabled) { | 585 void SyncBackendHost::Shutdown(bool sync_disabled) { |
586 // StopSyncingForShutdown() (which nulls out |frontend_|) should be | |
587 // called first. | |
588 DCHECK(!frontend_); | |
579 // TODO(tim): DCHECK(registrar_->StoppedOnUIThread()) would be nice. | 589 // TODO(tim): DCHECK(registrar_->StoppedOnUIThread()) would be nice. |
580 if (sync_thread_.IsRunning()) { | 590 if (sync_thread_.IsRunning()) { |
581 sync_thread_.message_loop()->PostTask(FROM_HERE, | 591 sync_thread_.message_loop()->PostTask(FROM_HERE, |
582 base::Bind(&SyncBackendHost::Core::DoShutdown, core_.get(), | 592 base::Bind(&SyncBackendHost::Core::DoShutdown, core_.get(), |
583 sync_disabled)); | 593 sync_disabled)); |
594 | |
595 if (chrome_sync_notification_bridge_.get()) | |
596 chrome_sync_notification_bridge_->StopForShutdown(); | |
584 } | 597 } |
585 | 598 |
586 // Stop will return once the thread exits, which will be after DoShutdown | 599 // Stop will return once the thread exits, which will be after DoShutdown |
587 // runs. DoShutdown needs to run from sync_thread_ because the sync backend | 600 // runs. DoShutdown needs to run from sync_thread_ because the sync backend |
588 // requires any thread that opened sqlite handles to relinquish them | 601 // requires any thread that opened sqlite handles to relinquish them |
589 // personally. We need to join threads, because otherwise the main Chrome | 602 // personally. We need to join threads, because otherwise the main Chrome |
590 // thread (ui loop) can exit before DoShutdown finishes, at which point | 603 // thread (ui loop) can exit before DoShutdown finishes, at which point |
591 // virtually anything the sync backend does (or the post-back to | 604 // virtually anything the sync backend does (or the post-back to |
592 // frontend_loop_ by our Core) will epically fail because the CRT won't be | 605 // frontend_loop_ by our Core) will epically fail because the CRT won't be |
593 // initialized. | 606 // initialized. |
594 // Since we are blocking the UI thread here, we need to turn ourselves in | 607 // Since we are blocking the UI thread here, we need to turn ourselves in |
595 // with the ThreadRestriction police. For sentencing and how we plan to fix | 608 // with the ThreadRestriction police. For sentencing and how we plan to fix |
596 // this, see bug 19757. | 609 // this, see bug 19757. |
597 base::Time stop_thread_start_time = base::Time::Now(); | 610 base::Time stop_thread_start_time = base::Time::Now(); |
598 { | 611 { |
599 base::ThreadRestrictions::ScopedAllowIO allow_io; | 612 base::ThreadRestrictions::ScopedAllowIO allow_io; |
600 sync_thread_.Stop(); | 613 sync_thread_.Stop(); |
601 } | 614 } |
602 base::TimeDelta stop_sync_thread_time = base::Time::Now() - | 615 base::TimeDelta stop_sync_thread_time = base::Time::Now() - |
603 stop_thread_start_time; | 616 stop_thread_start_time; |
604 UMA_HISTOGRAM_TIMES("Sync.Shutdown.StopSyncThreadTime", | 617 UMA_HISTOGRAM_TIMES("Sync.Shutdown.StopSyncThreadTime", |
605 stop_sync_thread_time); | 618 stop_sync_thread_time); |
606 | 619 |
607 registrar_.reset(); | 620 registrar_.reset(); |
608 frontend_ = NULL; | |
609 chrome_sync_notification_bridge_.reset(); | 621 chrome_sync_notification_bridge_.reset(); |
610 core_ = NULL; // Releases reference to core_. | 622 core_ = NULL; // Releases reference to core_. |
611 } | 623 } |
612 | 624 |
613 void SyncBackendHost::ConfigureDataTypes( | 625 void SyncBackendHost::ConfigureDataTypes( |
614 syncer::ConfigureReason reason, | 626 syncer::ConfigureReason reason, |
615 syncer::ModelTypeSet types_to_add, | 627 syncer::ModelTypeSet types_to_add, |
616 syncer::ModelTypeSet types_to_remove, | 628 syncer::ModelTypeSet types_to_remove, |
617 NigoriState nigori_state, | 629 NigoriState nigori_state, |
618 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 630 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 } | 897 } |
886 | 898 |
887 | 899 |
888 void SyncBackendHost::Core::OnInitializationComplete( | 900 void SyncBackendHost::Core::OnInitializationComplete( |
889 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 901 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
890 bool success, | 902 bool success, |
891 const syncer::ModelTypeSet restored_types) { | 903 const syncer::ModelTypeSet restored_types) { |
892 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 904 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
893 | 905 |
894 if (!success) { | 906 if (!success) { |
895 sync_manager_->RemoveObserver(this); | 907 DoDestroySyncManager(); |
896 sync_manager_->UpdateRegisteredInvalidationIds( | |
897 this, syncer::ObjectIdSet()); | |
898 sync_manager_->ShutdownOnSyncThread(); | |
899 sync_manager_.reset(); | |
900 } | 908 } |
901 | 909 |
902 host_.Call( | 910 host_.Call( |
903 FROM_HERE, | 911 FROM_HERE, |
904 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, | 912 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, |
905 js_backend, success, restored_types); | 913 js_backend, success, restored_types); |
906 | 914 |
907 if (success) { | 915 if (success) { |
908 // Initialization is complete, so we can schedule recurring SaveChanges. | 916 // Initialization is complete, so we can schedule recurring SaveChanges. |
909 sync_loop_->PostTask(FROM_HERE, | 917 sync_loop_->PostTask(FROM_HERE, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1078 options.restored_keystore_key_for_bootstrapping, | 1086 options.restored_keystore_key_for_bootstrapping, |
1079 CommandLine::ForCurrentProcess()->HasSwitch( | 1087 CommandLine::ForCurrentProcess()->HasSwitch( |
1080 switches::kSyncKeystoreEncryption), | 1088 switches::kSyncKeystoreEncryption), |
1081 scoped_ptr<InternalComponentsFactory>( | 1089 scoped_ptr<InternalComponentsFactory>( |
1082 options.internal_components_factory), | 1090 options.internal_components_factory), |
1083 &encryptor_, | 1091 &encryptor_, |
1084 options.unrecoverable_error_handler, | 1092 options.unrecoverable_error_handler, |
1085 options.report_unrecoverable_error_function); | 1093 options.report_unrecoverable_error_function); |
1086 LOG_IF(ERROR, !success) << "Sync manager initialization failed!"; | 1094 LOG_IF(ERROR, !success) << "Sync manager initialization failed!"; |
1087 | 1095 |
1088 // Now check the command line to see if we need to simulate an | 1096 // |sync_manager_| may end up being NULL here in tests (in |
1089 // unrecoverable error for testing purpose. Note the error is thrown | 1097 // synchronous initialization mode). |
1090 // only if the initialization succeeded. Also it makes sense to use this | 1098 // |
1091 // flag only when restarting the browser with an account already setup. If | 1099 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). |
1092 // you use this before setting up the setup would not succeed as an error | 1100 if (sync_manager_.get()) { |
1093 // would be encountered. | 1101 sync_manager_->SetInvalidationHandler(kHandlerName, this); |
1094 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1102 |
1095 switches::kSyncThrowUnrecoverableError)) { | 1103 // Now check the command line to see if we need to simulate an |
1096 sync_manager_->ThrowUnrecoverableError(); | 1104 // unrecoverable error for testing purpose. Note the error is thrown |
1105 // only if the initialization succeeded. Also it makes sense to use this | |
1106 // flag only when restarting the browser with an account already setup. If | |
1107 // you use this before setting up the setup would not succeed as an error | |
1108 // would be encountered. | |
1109 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
1110 switches::kSyncThrowUnrecoverableError)) { | |
1111 sync_manager_->ThrowUnrecoverableError(); | |
1112 } | |
1097 } | 1113 } |
1098 } | 1114 } |
1099 | 1115 |
1100 void SyncBackendHost::Core::DoUpdateCredentials( | 1116 void SyncBackendHost::Core::DoUpdateCredentials( |
1101 const SyncCredentials& credentials) { | 1117 const SyncCredentials& credentials) { |
1102 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1118 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1103 sync_manager_->UpdateCredentials(credentials); | 1119 sync_manager_->UpdateCredentials(credentials); |
1104 } | 1120 } |
1105 | 1121 |
1106 void SyncBackendHost::Core::DoUpdateRegisteredInvalidationIds( | 1122 void SyncBackendHost::Core::DoUpdateRegisteredInvalidationIds( |
1107 const syncer::ObjectIdSet& ids) { | 1123 const syncer::ObjectIdSet& ids) { |
1108 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1124 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1109 // |sync_manager_| may end up being NULL here in tests (in | 1125 // |sync_manager_| may end up being NULL here in tests (in |
1110 // synchronous initialization mode) since this is called during | 1126 // synchronous initialization mode) since this is called during |
1111 // shutdown. | 1127 // shutdown. |
1112 // | 1128 // |
1113 // TODO(akalin): Fix this behavior. | 1129 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). |
1114 if (sync_manager_.get()) { | 1130 if (sync_manager_.get()) { |
1115 sync_manager_->UpdateRegisteredInvalidationIds(this, ids); | 1131 sync_manager_->UpdateRegisteredInvalidationIds(kHandlerName, ids); |
1116 } | 1132 } |
1117 } | 1133 } |
1118 | 1134 |
1119 void SyncBackendHost::Core::DoStartSyncing( | 1135 void SyncBackendHost::Core::DoStartSyncing( |
1120 const syncer::ModelSafeRoutingInfo& routing_info) { | 1136 const syncer::ModelSafeRoutingInfo& routing_info) { |
1121 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1137 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1122 sync_manager_->StartSyncingNormally(routing_info); | 1138 sync_manager_->StartSyncingNormally(routing_info); |
1123 } | 1139 } |
1124 | 1140 |
1125 void SyncBackendHost::Core::DoSetEncryptionPassphrase( | 1141 void SyncBackendHost::Core::DoSetEncryptionPassphrase( |
(...skipping 26 matching lines...) Expand all Loading... | |
1152 const base::Closure& closure) { | 1168 const base::Closure& closure) { |
1153 if (sync_manager_.get()) { | 1169 if (sync_manager_.get()) { |
1154 sync_manager_->StopSyncingForShutdown(closure); | 1170 sync_manager_->StopSyncingForShutdown(closure); |
1155 } else { | 1171 } else { |
1156 sync_loop_->PostTask(FROM_HERE, closure); | 1172 sync_loop_->PostTask(FROM_HERE, closure); |
1157 } | 1173 } |
1158 } | 1174 } |
1159 | 1175 |
1160 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { | 1176 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { |
1161 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1177 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1162 if (sync_manager_.get()) { | 1178 DoDestroySyncManager(); |
1163 save_changes_timer_.reset(); | |
1164 sync_manager_->UpdateRegisteredInvalidationIds( | |
1165 this, syncer::ObjectIdSet()); | |
1166 sync_manager_->ShutdownOnSyncThread(); | |
1167 sync_manager_->RemoveObserver(this); | |
1168 sync_manager_.reset(); | |
1169 } | |
1170 | 1179 |
1171 chrome_sync_notification_bridge_ = NULL; | 1180 chrome_sync_notification_bridge_ = NULL; |
1172 registrar_ = NULL; | 1181 registrar_ = NULL; |
1173 | 1182 |
1174 if (sync_disabled) | 1183 if (sync_disabled) |
1175 DeleteSyncDataFolder(); | 1184 DeleteSyncDataFolder(); |
1176 | 1185 |
1177 sync_loop_ = NULL; | 1186 sync_loop_ = NULL; |
1178 | 1187 |
1179 host_.Reset(); | 1188 host_.Reset(); |
1180 } | 1189 } |
1181 | 1190 |
1191 void SyncBackendHost::Core::DoDestroySyncManager() { | |
1192 DCHECK_EQ(MessageLoop::current(), sync_loop_); | |
1193 if (sync_manager_.get()) { | |
1194 save_changes_timer_.reset(); | |
1195 sync_manager_->SetInvalidationHandler(kHandlerName, NULL); | |
1196 sync_manager_->RemoveObserver(this); | |
1197 sync_manager_->ShutdownOnSyncThread(); | |
1198 sync_manager_.reset(); | |
1199 } | |
1200 } | |
1201 | |
1182 void SyncBackendHost::Core::DoConfigureSyncer( | 1202 void SyncBackendHost::Core::DoConfigureSyncer( |
1183 syncer::ConfigureReason reason, | 1203 syncer::ConfigureReason reason, |
1184 syncer::ModelTypeSet types_to_config, | 1204 syncer::ModelTypeSet types_to_config, |
1185 const syncer::ModelSafeRoutingInfo routing_info, | 1205 const syncer::ModelSafeRoutingInfo routing_info, |
1186 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 1206 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
1187 const base::Closure& retry_callback) { | 1207 const base::Closure& retry_callback) { |
1188 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1208 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1189 sync_manager_->ConfigureSyncer( | 1209 sync_manager_->ConfigureSyncer( |
1190 reason, | 1210 reason, |
1191 types_to_config, | 1211 types_to_config, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1262 void SyncBackendHost::OnNigoriDownloadRetry() { | 1282 void SyncBackendHost::OnNigoriDownloadRetry() { |
1263 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1283 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1264 if (!frontend_) | 1284 if (!frontend_) |
1265 return; | 1285 return; |
1266 | 1286 |
1267 frontend_->OnSyncConfigureRetry(); | 1287 frontend_->OnSyncConfigureRetry(); |
1268 } | 1288 } |
1269 | 1289 |
1270 void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop( | 1290 void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop( |
1271 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success) { | 1291 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success) { |
1272 DCHECK_NE(NOT_ATTEMPTED, initialization_state_); | 1292 DCHECK_NE(initialization_state_, NOT_ATTEMPTED); |
1273 if (!frontend_) | 1293 if (!frontend_) |
1274 return; | 1294 return; |
1275 | 1295 |
1276 // We've at least created the sync manager at this point, but if that is all | 1296 // We've at least created the sync manager at this point, but if that is all |
1277 // we've done we're just beginning the initialization process. | 1297 // we've done we're just beginning the initialization process. |
1278 if (initialization_state_ == CREATING_SYNC_MANAGER) | 1298 if (initialization_state_ == CREATING_SYNC_MANAGER) |
1279 initialization_state_ = NOT_INITIALIZED; | 1299 initialization_state_ = NOT_INITIALIZED; |
1280 | 1300 |
1281 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1301 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1282 if (!success) { | 1302 if (!success) { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 FROM_HERE, | 1532 FROM_HERE, |
1513 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1533 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
1514 core_.get(), sync_thread_done_callback)); | 1534 core_.get(), sync_thread_done_callback)); |
1515 } | 1535 } |
1516 | 1536 |
1517 #undef SDVLOG | 1537 #undef SDVLOG |
1518 | 1538 |
1519 #undef SLOG | 1539 #undef SLOG |
1520 | 1540 |
1521 } // namespace browser_sync | 1541 } // namespace browser_sync |
OLD | NEW |