| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/sync/driver/glue/sync_backend_host_impl.h" | 5 #include "components/sync/driver/glue/sync_backend_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 48 invalidation::InvalidationService* invalidator, | 48 invalidation::InvalidationService* invalidator, |
| 49 const base::WeakPtr<SyncPrefs>& sync_prefs, | 49 const base::WeakPtr<SyncPrefs>& sync_prefs, |
| 50 const base::FilePath& sync_folder) | 50 const base::FilePath& sync_folder) |
| 51 : frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 51 : frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 52 sync_client_(sync_client), | 52 sync_client_(sync_client), |
| 53 ui_thread_(ui_thread), | 53 ui_thread_(ui_thread), |
| 54 name_(name), | 54 name_(name), |
| 55 initialized_(false), | 55 initialized_(false), |
| 56 sync_prefs_(sync_prefs), | 56 sync_prefs_(sync_prefs), |
| 57 frontend_(NULL), | 57 frontend_(nullptr), |
| 58 cached_passphrase_type_(PassphraseType::IMPLICIT_PASSPHRASE), | 58 cached_passphrase_type_(PassphraseType::IMPLICIT_PASSPHRASE), |
| 59 invalidator_(invalidator), | 59 invalidator_(invalidator), |
| 60 invalidation_handler_registered_(false), | 60 invalidation_handler_registered_(false), |
| 61 weak_ptr_factory_(this) { | 61 weak_ptr_factory_(this) { |
| 62 core_ = new SyncBackendHostCore(name_, sync_folder, | 62 core_ = new SyncBackendHostCore(name_, sync_folder, |
| 63 sync_prefs_->IsFirstSetupComplete(), | 63 sync_prefs_->IsFirstSetupComplete(), |
| 64 weak_ptr_factory_.GetWeakPtr()); | 64 weak_ptr_factory_.GetWeakPtr()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 SyncBackendHostImpl::~SyncBackendHostImpl() { | 67 SyncBackendHostImpl::~SyncBackendHostImpl() { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // pending. This scenario is a valid race, and SetDecryptionPassphrase can | 218 // pending. This scenario is a valid race, and SetDecryptionPassphrase can |
| 219 // trigger a new OnPassphraseRequired if it needs to. | 219 // trigger a new OnPassphraseRequired if it needs to. |
| 220 NotifyPassphraseAccepted(); | 220 NotifyPassphraseAccepted(); |
| 221 return true; | 221 return true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 void SyncBackendHostImpl::StopSyncingForShutdown() { | 224 void SyncBackendHostImpl::StopSyncingForShutdown() { |
| 225 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 225 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 226 | 226 |
| 227 // Immediately stop sending messages to the frontend. | 227 // Immediately stop sending messages to the frontend. |
| 228 frontend_ = NULL; | 228 frontend_ = nullptr; |
| 229 | 229 |
| 230 DCHECK(registrar_->sync_thread()->IsRunning()); | 230 DCHECK(registrar_->sync_thread()->IsRunning()); |
| 231 | 231 |
| 232 registrar_->RequestWorkerStopOnUIThread(); | 232 registrar_->RequestWorkerStopOnUIThread(); |
| 233 | 233 |
| 234 core_->ShutdownOnUIThread(); | 234 core_->ShutdownOnUIThread(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 std::unique_ptr<base::Thread> SyncBackendHostImpl::Shutdown( | 237 std::unique_ptr<base::Thread> SyncBackendHostImpl::Shutdown( |
| 238 ShutdownReason reason) { | 238 ShutdownReason reason) { |
| 239 // StopSyncingForShutdown() (which nulls out |frontend_|) should be | 239 // StopSyncingForShutdown() (which nulls out |frontend_|) should be |
| 240 // called first. | 240 // called first. |
| 241 DCHECK(!frontend_); | 241 DCHECK(!frontend_); |
| 242 DCHECK(registrar_->sync_thread()->IsRunning()); | 242 DCHECK(registrar_->sync_thread()->IsRunning()); |
| 243 | 243 |
| 244 bool sync_thread_claimed = (reason != BROWSER_SHUTDOWN); | 244 bool sync_thread_claimed = (reason != BROWSER_SHUTDOWN); |
| 245 | 245 |
| 246 if (invalidation_handler_registered_) { | 246 if (invalidation_handler_registered_) { |
| 247 if (reason == DISABLE_SYNC) { | 247 if (reason == DISABLE_SYNC) { |
| 248 UnregisterInvalidationIds(); | 248 UnregisterInvalidationIds(); |
| 249 } | 249 } |
| 250 invalidator_->UnregisterInvalidationHandler(this); | 250 invalidator_->UnregisterInvalidationHandler(this); |
| 251 invalidator_ = NULL; | 251 invalidator_ = nullptr; |
| 252 } | 252 } |
| 253 invalidation_handler_registered_ = false; | 253 invalidation_handler_registered_ = false; |
| 254 | 254 |
| 255 model_type_connector_.reset(); | 255 model_type_connector_.reset(); |
| 256 | 256 |
| 257 // Shut down and destroy sync manager. | 257 // Shut down and destroy sync manager. |
| 258 registrar_->sync_thread()->task_runner()->PostTask( | 258 registrar_->sync_thread()->task_runner()->PostTask( |
| 259 FROM_HERE, | 259 FROM_HERE, |
| 260 base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason)); | 260 base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason)); |
| 261 core_ = NULL; | 261 core_ = nullptr; |
| 262 | 262 |
| 263 // Worker cleanup. | 263 // Worker cleanup. |
| 264 SyncBackendRegistrar* detached_registrar = registrar_.release(); | 264 SyncBackendRegistrar* detached_registrar = registrar_.release(); |
| 265 detached_registrar->sync_thread()->task_runner()->PostTask( | 265 detached_registrar->sync_thread()->task_runner()->PostTask( |
| 266 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown, | 266 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown, |
| 267 base::Unretained(detached_registrar))); | 267 base::Unretained(detached_registrar))); |
| 268 | 268 |
| 269 if (sync_thread_claimed) | 269 if (sync_thread_claimed) |
| 270 return detached_registrar->ReleaseSyncThread(); | 270 return detached_registrar->ReleaseSyncThread(); |
| 271 else | 271 else |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 const SyncManager::ClearServerDataCallback& frontend_callback) { | 817 const SyncManager::ClearServerDataCallback& frontend_callback) { |
| 818 DCHECK(ui_thread_->BelongsToCurrentThread()); | 818 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 819 frontend_callback.Run(); | 819 frontend_callback.Run(); |
| 820 } | 820 } |
| 821 | 821 |
| 822 } // namespace syncer | 822 } // namespace syncer |
| 823 | 823 |
| 824 #undef SDVLOG | 824 #undef SDVLOG |
| 825 | 825 |
| 826 #undef SLOG | 826 #undef SLOG |
| OLD | NEW |