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 "chrome/browser/sync/glue/sync_backend_host_impl.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // Stop non-blocking sync types from sending any more requests to the syncer. | 268 // Stop non-blocking sync types from sending any more requests to the syncer. |
269 sync_context_proxy_.reset(); | 269 sync_context_proxy_.reset(); |
270 | 270 |
271 DCHECK(registrar_->sync_thread()->IsRunning()); | 271 DCHECK(registrar_->sync_thread()->IsRunning()); |
272 | 272 |
273 registrar_->RequestWorkerStopOnUIThread(); | 273 registrar_->RequestWorkerStopOnUIThread(); |
274 | 274 |
275 core_->ShutdownOnUIThread(); | 275 core_->ShutdownOnUIThread(); |
276 } | 276 } |
277 | 277 |
278 scoped_ptr<base::Thread> SyncBackendHostImpl::Shutdown(ShutdownOption option) { | 278 scoped_ptr<base::Thread> SyncBackendHostImpl::Shutdown( |
| 279 syncer::ShutdownReason reason) { |
279 // StopSyncingForShutdown() (which nulls out |frontend_|) should be | 280 // StopSyncingForShutdown() (which nulls out |frontend_|) should be |
280 // called first. | 281 // called first. |
281 DCHECK(!frontend_); | 282 DCHECK(!frontend_); |
282 DCHECK(registrar_->sync_thread()->IsRunning()); | 283 DCHECK(registrar_->sync_thread()->IsRunning()); |
283 | 284 |
284 bool sync_disabled = (option == DISABLE_AND_CLAIM_THREAD); | 285 bool sync_thread_claimed = (reason != syncer::BROWSER_SHUTDOWN); |
285 bool sync_thread_claimed = | |
286 (option == DISABLE_AND_CLAIM_THREAD || option == STOP_AND_CLAIM_THREAD); | |
287 | 286 |
288 if (invalidation_handler_registered_) { | 287 if (invalidation_handler_registered_) { |
289 if (sync_disabled) { | 288 if (reason == syncer::DISABLE_SYNC) { |
290 UnregisterInvalidationIds(); | 289 UnregisterInvalidationIds(); |
291 } | 290 } |
292 invalidator_->UnregisterInvalidationHandler(this); | 291 invalidator_->UnregisterInvalidationHandler(this); |
293 invalidator_ = NULL; | 292 invalidator_ = NULL; |
294 } | 293 } |
295 invalidation_handler_registered_ = false; | 294 invalidation_handler_registered_ = false; |
296 | 295 |
297 // Shut down and destroy sync manager. | 296 // Shut down and destroy sync manager. |
298 registrar_->sync_thread()->message_loop()->PostTask( | 297 registrar_->sync_thread()->message_loop()->PostTask( |
299 FROM_HERE, | 298 FROM_HERE, |
300 base::Bind(&SyncBackendHostCore::DoShutdown, | 299 base::Bind(&SyncBackendHostCore::DoShutdown, |
301 core_.get(), sync_disabled)); | 300 core_.get(), reason)); |
302 core_ = NULL; | 301 core_ = NULL; |
303 | 302 |
304 // Worker cleanup. | 303 // Worker cleanup. |
305 SyncBackendRegistrar* detached_registrar = registrar_.release(); | 304 SyncBackendRegistrar* detached_registrar = registrar_.release(); |
306 detached_registrar->sync_thread()->message_loop()->PostTask( | 305 detached_registrar->sync_thread()->message_loop()->PostTask( |
307 FROM_HERE, | 306 FROM_HERE, |
308 base::Bind(&SyncBackendRegistrar::Shutdown, | 307 base::Bind(&SyncBackendRegistrar::Shutdown, |
309 base::Unretained(detached_registrar))); | 308 base::Unretained(detached_registrar))); |
310 | 309 |
311 if (sync_thread_claimed) | 310 if (sync_thread_claimed) |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 | 884 |
886 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { | 885 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { |
887 return registrar_->sync_thread()->message_loop(); | 886 return registrar_->sync_thread()->message_loop(); |
888 } | 887 } |
889 | 888 |
890 } // namespace browser_sync | 889 } // namespace browser_sync |
891 | 890 |
892 #undef SDVLOG | 891 #undef SDVLOG |
893 | 892 |
894 #undef SLOG | 893 #undef SLOG |
OLD | NEW |