Chromium Code Reviews| 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_core.h" | 5 #include "components/sync/driver/glue/sync_backend_host_core.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 DoConfigureSyncerTypes::~DoConfigureSyncerTypes() {} | 104 DoConfigureSyncerTypes::~DoConfigureSyncerTypes() {} |
| 105 | 105 |
| 106 SyncBackendHostCore::SyncBackendHostCore( | 106 SyncBackendHostCore::SyncBackendHostCore( |
| 107 const std::string& name, | 107 const std::string& name, |
| 108 const base::FilePath& sync_data_folder_path, | 108 const base::FilePath& sync_data_folder_path, |
| 109 bool has_sync_setup_completed, | 109 bool has_sync_setup_completed, |
| 110 const base::WeakPtr<SyncBackendHostImpl>& backend) | 110 const base::WeakPtr<SyncBackendHostImpl>& backend) |
| 111 : name_(name), | 111 : name_(name), |
| 112 sync_data_folder_path_(sync_data_folder_path), | 112 sync_data_folder_path_(sync_data_folder_path), |
| 113 host_(backend), | 113 host_(backend), |
| 114 sync_loop_(NULL), | 114 sync_loop_(nullptr), |
| 115 registrar_(NULL), | 115 registrar_(nullptr), |
| 116 has_sync_setup_completed_(has_sync_setup_completed), | 116 has_sync_setup_completed_(has_sync_setup_completed), |
| 117 forward_protocol_events_(false), | 117 forward_protocol_events_(false), |
| 118 forward_type_info_(false), | 118 forward_type_info_(false), |
| 119 weak_ptr_factory_(this) { | 119 weak_ptr_factory_(this) { |
| 120 DCHECK(backend.get()); | 120 DCHECK(backend.get()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 SyncBackendHostCore::~SyncBackendHostCore() { | 123 SyncBackendHostCore::~SyncBackendHostCore() { |
| 124 DCHECK(!sync_manager_.get()); | 124 DCHECK(!sync_manager_.get()); |
| 125 } | 125 } |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 | 459 |
| 460 DVLOG(1) << "Initilalizing Control Types"; | 460 DVLOG(1) << "Initilalizing Control Types"; |
| 461 | 461 |
| 462 // Initialize encryption. | 462 // Initialize encryption. |
| 463 sync_manager_->GetEncryptionHandler()->Init(); | 463 sync_manager_->GetEncryptionHandler()->Init(); |
| 464 | 464 |
| 465 // Note: experiments are currently handled via SBH::AddExperimentalTypes, | 465 // Note: experiments are currently handled via SBH::AddExperimentalTypes, |
| 466 // which is called at the end of every sync cycle. | 466 // which is called at the end of every sync cycle. |
| 467 // TODO(zea): eventually add an experiment handler and initialize it here. | 467 // TODO(zea): eventually add an experiment handler and initialize it here. |
| 468 | 468 |
| 469 if (!sync_manager_->GetUserShare()) { // NULL in some tests. | 469 if (!sync_manager_->GetUserShare()) { // null in some tests. |
|
maxbogue
2016/10/17 20:33:14
nit: Null (sentences begin with capital letters.)
skym
2016/10/17 20:36:00
Done.
| |
| 470 DVLOG(1) << "Skipping initialization of DeviceInfo"; | 470 DVLOG(1) << "Skipping initialization of DeviceInfo"; |
| 471 host_.Call(FROM_HERE, | 471 host_.Call(FROM_HERE, |
| 472 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop); | 472 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop); |
| 473 return; | 473 return; |
| 474 } | 474 } |
| 475 | 475 |
| 476 if (!sync_manager_->InitialSyncEndedTypes().HasAll(ControlTypes())) { | 476 if (!sync_manager_->InitialSyncEndedTypes().HasAll(ControlTypes())) { |
| 477 LOG(ERROR) << "Failed to download control types"; | 477 LOG(ERROR) << "Failed to download control types"; |
| 478 host_.Call(FROM_HERE, | 478 host_.Call(FROM_HERE, |
| 479 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop); | 479 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 // guarantees that the ServerConnectionManager will no longer attempt to | 520 // guarantees that the ServerConnectionManager will no longer attempt to |
| 521 // create new connections. | 521 // create new connections. |
| 522 release_request_context_signal_.Signal(); | 522 release_request_context_signal_.Signal(); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void SyncBackendHostCore::DoShutdown(ShutdownReason reason) { | 525 void SyncBackendHostCore::DoShutdown(ShutdownReason reason) { |
| 526 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 526 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 527 | 527 |
| 528 DoDestroySyncManager(reason); | 528 DoDestroySyncManager(reason); |
| 529 | 529 |
| 530 registrar_ = NULL; | 530 registrar_ = nullptr; |
| 531 | 531 |
| 532 if (reason == DISABLE_SYNC) | 532 if (reason == DISABLE_SYNC) |
| 533 DeleteSyncDataFolder(); | 533 DeleteSyncDataFolder(); |
| 534 | 534 |
| 535 host_.Reset(); | 535 host_.Reset(); |
| 536 weak_ptr_factory_.InvalidateWeakPtrs(); | 536 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void SyncBackendHostCore::DoDestroySyncManager(ShutdownReason reason) { | 539 void SyncBackendHostCore::DoDestroySyncManager(ShutdownReason reason) { |
| 540 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 540 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 } | 682 } |
| 683 | 683 |
| 684 void SyncBackendHostCore::ClearServerDataDone( | 684 void SyncBackendHostCore::ClearServerDataDone( |
| 685 const base::Closure& frontend_callback) { | 685 const base::Closure& frontend_callback) { |
| 686 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 686 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 687 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, | 687 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, |
| 688 frontend_callback); | 688 frontend_callback); |
| 689 } | 689 } |
| 690 | 690 |
| 691 } // namespace syncer | 691 } // namespace syncer |
| OLD | NEW |