| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // | 99 // |
| 100 // The Do* methods are the various entry points from our | 100 // The Do* methods are the various entry points from our |
| 101 // SyncBackendHost. They are all called on the sync thread to | 101 // SyncBackendHost. They are all called on the sync thread to |
| 102 // actually perform synchronous (and potentially blocking) syncapi | 102 // actually perform synchronous (and potentially blocking) syncapi |
| 103 // operations. | 103 // operations. |
| 104 // | 104 // |
| 105 // Called to perform initialization of the syncapi on behalf of | 105 // Called to perform initialization of the syncapi on behalf of |
| 106 // SyncBackendHost::Initialize. | 106 // SyncBackendHost::Initialize. |
| 107 void DoInitialize(const DoInitializeOptions& options); | 107 void DoInitialize(const DoInitializeOptions& options); |
| 108 | 108 |
| 109 // Called to check server reachability after initialization is | |
| 110 // fully completed. | |
| 111 void DoCheckServerReachable(); | |
| 112 | |
| 113 // Called to perform credential update on behalf of | 109 // Called to perform credential update on behalf of |
| 114 // SyncBackendHost::UpdateCredentials | 110 // SyncBackendHost::UpdateCredentials |
| 115 void DoUpdateCredentials(const sync_api::SyncCredentials& credentials); | 111 void DoUpdateCredentials(const sync_api::SyncCredentials& credentials); |
| 116 | 112 |
| 117 // Called when the user disables or enables a sync type. | 113 // Called when the user disables or enables a sync type. |
| 118 void DoUpdateEnabledTypes(); | 114 void DoUpdateEnabledTypes(); |
| 119 | 115 |
| 120 // Called to tell the syncapi to start syncing (generally after | 116 // Called to tell the syncapi to start syncing (generally after |
| 121 // initialization and authentication). | 117 // initialization and authentication). |
| 122 void DoStartSyncing(); | 118 void DoStartSyncing(); |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 options.registrar /* as SyncManager::ChangeDelegate */, | 925 options.registrar /* as SyncManager::ChangeDelegate */, |
| 930 MakeUserAgentForSyncApi(), | 926 MakeUserAgentForSyncApi(), |
| 931 options.credentials, | 927 options.credentials, |
| 932 options.sync_notifier_factory->CreateSyncNotifier(), | 928 options.sync_notifier_factory->CreateSyncNotifier(), |
| 933 options.restored_key_for_bootstrapping, | 929 options.restored_key_for_bootstrapping, |
| 934 options.setup_for_test_mode, | 930 options.setup_for_test_mode, |
| 935 options.unrecoverable_error_handler); | 931 options.unrecoverable_error_handler); |
| 936 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; | 932 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; |
| 937 } | 933 } |
| 938 | 934 |
| 939 void SyncBackendHost::Core::DoCheckServerReachable() { | |
| 940 DCHECK_EQ(MessageLoop::current(), sync_loop_); | |
| 941 sync_manager_->CheckServerReachable(); | |
| 942 } | |
| 943 | |
| 944 void SyncBackendHost::Core::DoUpdateCredentials( | 935 void SyncBackendHost::Core::DoUpdateCredentials( |
| 945 const SyncCredentials& credentials) { | 936 const SyncCredentials& credentials) { |
| 946 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 937 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 947 sync_manager_->UpdateCredentials(credentials); | 938 sync_manager_->UpdateCredentials(credentials); |
| 948 } | 939 } |
| 949 | 940 |
| 950 void SyncBackendHost::Core::DoUpdateEnabledTypes() { | 941 void SyncBackendHost::Core::DoUpdateEnabledTypes() { |
| 951 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 942 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 952 sync_manager_->UpdateEnabledTypes(); | 943 sync_manager_->UpdateEnabledTypes(); |
| 953 } | 944 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 HandleInitializationCompletedOnFrontendLoop, | 1101 HandleInitializationCompletedOnFrontendLoop, |
| 1111 weak_ptr_factory_.GetWeakPtr(), js_backend, true)); | 1102 weak_ptr_factory_.GetWeakPtr(), js_backend, true)); |
| 1112 break; | 1103 break; |
| 1113 case REFRESHING_NIGORI: | 1104 case REFRESHING_NIGORI: |
| 1114 initialization_state_ = INITIALIZED; | 1105 initialization_state_ = INITIALIZED; |
| 1115 // Now that we've downloaded the nigori node, we can see if there are any | 1106 // Now that we've downloaded the nigori node, we can see if there are any |
| 1116 // experimental types to enable. This should be done before we inform | 1107 // experimental types to enable. This should be done before we inform |
| 1117 // the frontend to ensure they're visible in the customize screen. | 1108 // the frontend to ensure they're visible in the customize screen. |
| 1118 AddExperimentalTypes(); | 1109 AddExperimentalTypes(); |
| 1119 frontend_->OnBackendInitialized(js_backend, true); | 1110 frontend_->OnBackendInitialized(js_backend, true); |
| 1120 // Now that we're fully initialized, kick off a server | |
| 1121 // reachability check. | |
| 1122 sync_thread_.message_loop()->PostTask( | |
| 1123 FROM_HERE, | |
| 1124 base::Bind(&SyncBackendHost::Core::DoCheckServerReachable, | |
| 1125 core_.get())); | |
| 1126 break; | 1111 break; |
| 1127 default: | 1112 default: |
| 1128 NOTREACHED(); | 1113 NOTREACHED(); |
| 1129 } | 1114 } |
| 1130 } | 1115 } |
| 1131 | 1116 |
| 1132 void SyncBackendHost::PersistEncryptionBootstrapToken( | 1117 void SyncBackendHost::PersistEncryptionBootstrapToken( |
| 1133 const std::string& token) { | 1118 const std::string& token) { |
| 1134 CHECK(sync_prefs_.get()); | 1119 CHECK(sync_prefs_.get()); |
| 1135 sync_prefs_->SetEncryptionBootstrapToken(token); | 1120 sync_prefs_->SetEncryptionBootstrapToken(token); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 FROM_HERE, | 1250 FROM_HERE, |
| 1266 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1251 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
| 1267 core_.get(), sync_thread_done_callback)); | 1252 core_.get(), sync_thread_done_callback)); |
| 1268 } | 1253 } |
| 1269 | 1254 |
| 1270 #undef SDVLOG | 1255 #undef SDVLOG |
| 1271 | 1256 |
| 1272 #undef SLOG | 1257 #undef SLOG |
| 1273 | 1258 |
| 1274 } // namespace browser_sync | 1259 } // namespace browser_sync |
| OLD | NEW |