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 "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/invalidation/invalidation_service.h" | 9 #include "chrome/browser/invalidation/invalidation_service.h" |
10 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 10 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 227 |
228 void SyncBackendHostImpl::StopSyncingForShutdown() { | 228 void SyncBackendHostImpl::StopSyncingForShutdown() { |
229 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 229 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); |
230 | 230 |
231 // Immediately stop sending messages to the frontend. | 231 // Immediately stop sending messages to the frontend. |
232 frontend_ = NULL; | 232 frontend_ = NULL; |
233 | 233 |
234 // Stop listening for and forwarding locally-triggered sync refresh requests. | 234 // Stop listening for and forwarding locally-triggered sync refresh requests. |
235 notification_registrar_.RemoveAll(); | 235 notification_registrar_.RemoveAll(); |
236 | 236 |
| 237 // Stop non-blocking sync types from sending any more requests to the syncer. |
| 238 sync_core_proxy_.reset(); |
| 239 |
237 DCHECK(registrar_->sync_thread()->IsRunning()); | 240 DCHECK(registrar_->sync_thread()->IsRunning()); |
238 | 241 |
239 registrar_->RequestWorkerStopOnUIThread(); | 242 registrar_->RequestWorkerStopOnUIThread(); |
240 | 243 |
241 core_->ShutdownOnUIThread(); | 244 core_->ShutdownOnUIThread(); |
242 } | 245 } |
243 | 246 |
244 scoped_ptr<base::Thread> SyncBackendHostImpl::Shutdown(ShutdownOption option) { | 247 scoped_ptr<base::Thread> SyncBackendHostImpl::Shutdown(ShutdownOption option) { |
245 // StopSyncingForShutdown() (which nulls out |frontend_|) should be | 248 // StopSyncingForShutdown() (which nulls out |frontend_|) should be |
246 // called first. | 249 // called first. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 423 } |
421 | 424 |
422 void SyncBackendHostImpl::DeactivateDataType(syncer::ModelType type) { | 425 void SyncBackendHostImpl::DeactivateDataType(syncer::ModelType type) { |
423 registrar_->DeactivateDataType(type); | 426 registrar_->DeactivateDataType(type); |
424 } | 427 } |
425 | 428 |
426 syncer::UserShare* SyncBackendHostImpl::GetUserShare() const { | 429 syncer::UserShare* SyncBackendHostImpl::GetUserShare() const { |
427 return core_->sync_manager()->GetUserShare(); | 430 return core_->sync_manager()->GetUserShare(); |
428 } | 431 } |
429 | 432 |
| 433 syncer::SyncCoreProxy SyncBackendHostImpl::GetSyncCoreProxy() { |
| 434 return *sync_core_proxy_.get(); |
| 435 } |
| 436 |
430 SyncBackendHostImpl::Status SyncBackendHostImpl::GetDetailedStatus() { | 437 SyncBackendHostImpl::Status SyncBackendHostImpl::GetDetailedStatus() { |
431 DCHECK(initialized()); | 438 DCHECK(initialized()); |
432 return core_->sync_manager()->GetDetailedStatus(); | 439 return core_->sync_manager()->GetDetailedStatus(); |
433 } | 440 } |
434 | 441 |
435 syncer::sessions::SyncSessionSnapshot | 442 syncer::sessions::SyncSessionSnapshot |
436 SyncBackendHostImpl::GetLastSessionSnapshot() const { | 443 SyncBackendHostImpl::GetLastSessionSnapshot() const { |
437 return last_snapshot_; | 444 return last_snapshot_; |
438 } | 445 } |
439 | 446 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 573 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); |
567 if (!frontend_) | 574 if (!frontend_) |
568 return; | 575 return; |
569 | 576 |
570 frontend_->OnSyncConfigureRetry(); | 577 frontend_->OnSyncConfigureRetry(); |
571 } | 578 } |
572 | 579 |
573 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( | 580 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( |
574 const syncer::WeakHandle<syncer::JsBackend> js_backend, | 581 const syncer::WeakHandle<syncer::JsBackend> js_backend, |
575 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> | 582 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> |
576 debug_info_listener) { | 583 debug_info_listener, |
| 584 syncer::SyncCoreProxy sync_core_proxy) { |
577 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 585 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); |
578 if (!frontend_) | 586 if (!frontend_) |
579 return; | 587 return; |
580 | 588 |
581 initialized_ = true; | 589 initialized_ = true; |
582 | 590 |
| 591 sync_core_proxy_.reset(new syncer::SyncCoreProxy(sync_core_proxy)); |
| 592 |
583 invalidator_->RegisterInvalidationHandler(this); | 593 invalidator_->RegisterInvalidationHandler(this); |
584 invalidation_handler_registered_ = true; | 594 invalidation_handler_registered_ = true; |
585 | 595 |
586 // Fake a state change to initialize the SyncManager's cached invalidator | 596 // Fake a state change to initialize the SyncManager's cached invalidator |
587 // state. | 597 // state. |
588 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); | 598 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); |
589 | 599 |
590 // Start forwarding refresh requests to the SyncManager | 600 // Start forwarding refresh requests to the SyncManager |
591 notification_registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, | 601 notification_registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, |
592 content::Source<Profile>(profile_)); | 602 content::Source<Profile>(profile_)); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { | 784 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { |
775 return registrar_->sync_thread()->message_loop(); | 785 return registrar_->sync_thread()->message_loop(); |
776 } | 786 } |
777 | 787 |
778 } // namespace browser_sync | 788 } // namespace browser_sync |
779 | 789 |
780 #undef SDVLOG | 790 #undef SDVLOG |
781 | 791 |
782 #undef SLOG | 792 #undef SLOG |
783 | 793 |
OLD | NEW |