| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/internal_api/sync_rollback_manager.h" | 5 #include "sync/internal_api/sync_rollback_manager.h" |
| 6 | 6 |
| 7 #include "sync/internal_api/public/base/model_type.h" | 7 #include "sync/internal_api/public/base/model_type.h" |
| 8 #include "sync/internal_api/public/read_node.h" | 8 #include "sync/internal_api/public/read_node.h" |
| 9 #include "sync/internal_api/public/read_transaction.h" | 9 #include "sync/internal_api/public/read_transaction.h" |
| 10 #include "sync/internal_api/public/util/syncer_error.h" | 10 #include "sync/internal_api/public/util/syncer_error.h" |
| 11 #include "sync/internal_api/public/write_transaction.h" | 11 #include "sync/internal_api/public/write_transaction.h" |
| 12 #include "sync/syncable/directory.h" | 12 #include "sync/syncable/directory.h" |
| 13 #include "sync/syncable/mutable_entry.h" | 13 #include "sync/syncable/mutable_entry.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace syncer { | 16 namespace syncer { |
| 17 | 17 |
| 18 SyncRollbackManager::SyncRollbackManager() | 18 SyncRollbackManager::SyncRollbackManager() |
| 19 : change_delegate_(NULL) { | 19 : change_delegate_(NULL) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 SyncRollbackManager::~SyncRollbackManager() { | 22 SyncRollbackManager::~SyncRollbackManager() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void SyncRollbackManager::Init( | 25 void SyncRollbackManager::Init(InitArgs* args) { |
| 26 const base::FilePath& database_location, | |
| 27 const WeakHandle<JsEventHandler>& event_handler, | |
| 28 const GURL& service_url, | |
| 29 scoped_ptr<HttpPostProviderFactory> post_factory, | |
| 30 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | |
| 31 ExtensionsActivity* extensions_activity, | |
| 32 SyncManager::ChangeDelegate* change_delegate, | |
| 33 const SyncCredentials& credentials, | |
| 34 const std::string& invalidator_client_id, | |
| 35 const std::string& restored_key_for_bootstrapping, | |
| 36 const std::string& restored_keystore_key_for_bootstrapping, | |
| 37 InternalComponentsFactory* internal_components_factory, | |
| 38 Encryptor* encryptor, | |
| 39 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | |
| 40 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, | |
| 41 CancelationSignal* cancelation_signal) { | |
| 42 if (SyncRollbackManagerBase::InitInternal( | 26 if (SyncRollbackManagerBase::InitInternal( |
| 43 database_location, | 27 args->database_location, |
| 44 internal_components_factory, | 28 args->internal_components_factory, |
| 45 unrecoverable_error_handler.Pass(), | 29 args->unrecoverable_error_handler.Pass(), |
| 46 report_unrecoverable_error_function)) { | 30 args->report_unrecoverable_error_function)) { |
| 47 change_delegate_ = change_delegate; | 31 change_delegate_ = args->change_delegate; |
| 48 | 32 |
| 49 for (size_t i = 0; i < workers.size(); ++i) { | 33 for (size_t i = 0; i < args->workers.size(); ++i) { |
| 50 ModelSafeGroup group = workers[i]->GetModelSafeGroup(); | 34 ModelSafeGroup group = args->workers[i]->GetModelSafeGroup(); |
| 51 CHECK(workers_.find(group) == workers_.end()); | 35 CHECK(workers_.find(group) == workers_.end()); |
| 52 workers_[group] = workers[i]; | 36 workers_[group] = args->workers[i]; |
| 53 } | 37 } |
| 54 | 38 |
| 55 rollback_ready_types_ = GetUserShare()->directory->InitialSyncEndedTypes(); | 39 rollback_ready_types_ = GetUserShare()->directory->InitialSyncEndedTypes(); |
| 56 rollback_ready_types_.RetainAll(BackupTypes()); | 40 rollback_ready_types_.RetainAll(BackupTypes()); |
| 57 } | 41 } |
| 58 } | 42 } |
| 59 | 43 |
| 60 void SyncRollbackManager::StartSyncingNormally( | 44 void SyncRollbackManager::StartSyncingNormally( |
| 61 const ModelSafeRoutingInfo& routing_info){ | 45 const ModelSafeRoutingInfo& routing_info){ |
| 62 if (rollback_ready_types_.Empty()) { | 46 if (rollback_ready_types_.Empty()) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 113 } |
| 130 | 114 |
| 131 void SyncRollbackManager::NotifyRollbackDone() { | 115 void SyncRollbackManager::NotifyRollbackDone() { |
| 132 SyncProtocolError error; | 116 SyncProtocolError error; |
| 133 error.action = ROLLBACK_DONE; | 117 error.action = ROLLBACK_DONE; |
| 134 FOR_EACH_OBSERVER(SyncManager::Observer, *GetObservers(), | 118 FOR_EACH_OBSERVER(SyncManager::Observer, *GetObservers(), |
| 135 OnActionableError(error)); | 119 OnActionableError(error)); |
| 136 } | 120 } |
| 137 | 121 |
| 138 } // namespace syncer | 122 } // namespace syncer |
| OLD | NEW |