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> |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, | 839 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, |
| 840 snapshot); | 840 snapshot); |
| 841 } | 841 } |
| 842 | 842 |
| 843 | 843 |
| 844 void SyncBackendHost::Core::OnInitializationComplete( | 844 void SyncBackendHost::Core::OnInitializationComplete( |
| 845 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 845 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
| 846 bool success, | 846 bool success, |
| 847 const syncer::ModelTypeSet restored_types) { | 847 const syncer::ModelTypeSet restored_types) { |
| 848 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 848 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 849 | |
| 850 if (!success) { | |
| 851 sync_manager_->RemoveObserver(this); | |
| 852 sync_manager_.reset(); | |
|
tim (not reviewing)
2012/07/31 19:40:26
The main danger with this is that SyncManager need
rlarocque
2012/07/31 20:14:07
Good idea. Done.
| |
| 853 } | |
| 854 | |
| 849 host_.Call( | 855 host_.Call( |
| 850 FROM_HERE, | 856 FROM_HERE, |
| 851 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, | 857 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, |
| 852 js_backend, success, restored_types); | 858 js_backend, success, restored_types); |
| 853 | 859 |
| 854 if (success) { | 860 if (success) { |
| 855 // Initialization is complete, so we can schedule recurring SaveChanges. | 861 // Initialization is complete, so we can schedule recurring SaveChanges. |
| 856 sync_loop_->PostTask(FROM_HERE, | 862 sync_loop_->PostTask(FROM_HERE, |
| 857 base::Bind(&Core::StartSavingChanges, this)); | 863 base::Bind(&Core::StartSavingChanges, this)); |
| 858 } | 864 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 void SyncBackendHost::Core::DoRefreshNigori( | 1050 void SyncBackendHost::Core::DoRefreshNigori( |
| 1045 const base::Closure& done_callback) { | 1051 const base::Closure& done_callback) { |
| 1046 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1052 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1047 chrome::VersionInfo version_info; | 1053 chrome::VersionInfo version_info; |
| 1048 sync_manager_->RefreshNigori(version_info.CreateVersionString(), | 1054 sync_manager_->RefreshNigori(version_info.CreateVersionString(), |
| 1049 done_callback); | 1055 done_callback); |
| 1050 } | 1056 } |
| 1051 | 1057 |
| 1052 void SyncBackendHost::Core::DoStopSyncManagerForShutdown( | 1058 void SyncBackendHost::Core::DoStopSyncManagerForShutdown( |
| 1053 const base::Closure& closure) { | 1059 const base::Closure& closure) { |
| 1054 DCHECK(sync_manager_.get()); | 1060 if (sync_manager_.get()) { |
| 1055 sync_manager_->StopSyncingForShutdown(closure); | 1061 sync_manager_->StopSyncingForShutdown(closure); |
| 1062 } else { | |
| 1063 sync_loop_->PostTask(FROM_HERE, closure); | |
| 1064 } | |
| 1056 } | 1065 } |
| 1057 | 1066 |
| 1058 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { | 1067 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { |
| 1059 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1068 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1060 if (!sync_manager_.get()) | 1069 if (sync_manager_.get()) { |
| 1061 return; | 1070 save_changes_timer_.reset(); |
| 1071 sync_manager_->ShutdownOnSyncThread(); | |
| 1072 sync_manager_->RemoveObserver(this); | |
| 1073 sync_manager_.reset(); | |
| 1074 } | |
| 1062 | 1075 |
| 1063 save_changes_timer_.reset(); | |
| 1064 sync_manager_->ShutdownOnSyncThread(); | |
| 1065 sync_manager_->RemoveObserver(this); | |
| 1066 sync_manager_.reset(); | |
| 1067 chrome_sync_notification_bridge_ = NULL; | 1076 chrome_sync_notification_bridge_ = NULL; |
| 1068 registrar_ = NULL; | 1077 registrar_ = NULL; |
| 1069 | 1078 |
| 1070 if (sync_disabled) | 1079 if (sync_disabled) |
| 1071 DeleteSyncDataFolder(); | 1080 DeleteSyncDataFolder(); |
| 1072 | 1081 |
| 1073 sync_loop_ = NULL; | 1082 sync_loop_ = NULL; |
| 1074 | 1083 |
| 1075 host_.Reset(); | 1084 host_.Reset(); |
| 1076 } | 1085 } |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1379 FROM_HERE, | 1388 FROM_HERE, |
| 1380 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1389 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
| 1381 core_.get(), sync_thread_done_callback)); | 1390 core_.get(), sync_thread_done_callback)); |
| 1382 } | 1391 } |
| 1383 | 1392 |
| 1384 #undef SDVLOG | 1393 #undef SDVLOG |
| 1385 | 1394 |
| 1386 #undef SLOG | 1395 #undef SLOG |
| 1387 | 1396 |
| 1388 } // namespace browser_sync | 1397 } // namespace browser_sync |
| OLD | NEW |