| 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_base.h" | 5 #include "sync/internal_api/sync_rollback_manager_base.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/internal_components_factory.h" |
| 8 #include "sync/internal_api/public/read_node.h" | 9 #include "sync/internal_api/public/read_node.h" |
| 9 #include "sync/internal_api/public/read_transaction.h" | 10 #include "sync/internal_api/public/read_transaction.h" |
| 10 #include "sync/internal_api/public/write_transaction.h" | 11 #include "sync/internal_api/public/write_transaction.h" |
| 11 #include "sync/syncable/directory_backing_store.h" | 12 #include "sync/syncable/directory_backing_store.h" |
| 12 #include "sync/syncable/mutable_entry.h" | 13 #include "sync/syncable/mutable_entry.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Permanent bookmark folders as defined in bookmark_model_associator.cc. | 17 // Permanent bookmark folders as defined in bookmark_model_associator.cc. |
| 17 // No mobile bookmarks because they only exists with sync enabled. | 18 // No mobile bookmarks because they only exists with sync enabled. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 45 dummy_handler_(new DummyEntryptionHandler), | 46 dummy_handler_(new DummyEntryptionHandler), |
| 46 initialized_(false) { | 47 initialized_(false) { |
| 47 } | 48 } |
| 48 | 49 |
| 49 SyncRollbackManagerBase::~SyncRollbackManagerBase() { | 50 SyncRollbackManagerBase::~SyncRollbackManagerBase() { |
| 50 } | 51 } |
| 51 | 52 |
| 52 bool SyncRollbackManagerBase::InitInternal( | 53 bool SyncRollbackManagerBase::InitInternal( |
| 53 const base::FilePath& database_location, | 54 const base::FilePath& database_location, |
| 54 InternalComponentsFactory* internal_components_factory, | 55 InternalComponentsFactory* internal_components_factory, |
| 55 InternalComponentsFactory::StorageOption storage, | |
| 56 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | 56 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, |
| 57 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { | 57 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { |
| 58 unrecoverable_error_handler_ = unrecoverable_error_handler.Pass(); | 58 unrecoverable_error_handler_ = unrecoverable_error_handler.Pass(); |
| 59 report_unrecoverable_error_function_ = report_unrecoverable_error_function; | 59 report_unrecoverable_error_function_ = report_unrecoverable_error_function; |
| 60 | 60 |
| 61 if (!InitBackupDB(database_location, internal_components_factory, storage)) { | 61 if (!InitBackupDB(database_location, internal_components_factory)) { |
| 62 NotifyInitializationFailure(); | 62 NotifyInitializationFailure(); |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 | 65 |
| 66 initialized_ = true; | 66 initialized_ = true; |
| 67 NotifyInitializationSuccess(); | 67 NotifyInitializationSuccess(); |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 ModelTypeSet SyncRollbackManagerBase::InitialSyncEndedTypes() { | 71 ModelTypeSet SyncRollbackManagerBase::InitialSyncEndedTypes() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 SyncStatus SyncRollbackManagerBase::GetDetailedStatus() const { | 134 SyncStatus SyncRollbackManagerBase::GetDetailedStatus() const { |
| 135 return SyncStatus(); | 135 return SyncStatus(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void SyncRollbackManagerBase::SaveChanges() { | 138 void SyncRollbackManagerBase::SaveChanges() { |
| 139 } | 139 } |
| 140 | 140 |
| 141 void SyncRollbackManagerBase::ShutdownOnSyncThread(ShutdownReason reason) { | 141 void SyncRollbackManagerBase::ShutdownOnSyncThread(ShutdownReason reason) { |
| 142 if (initialized_) { | 142 if (initialized_) { |
| 143 SaveChanges(); |
| 143 share_.directory->Close(); | 144 share_.directory->Close(); |
| 144 share_.directory.reset(); | 145 share_.directory.reset(); |
| 145 initialized_ = false; | 146 initialized_ = false; |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 | 149 |
| 149 UserShare* SyncRollbackManagerBase::GetUserShare() { | 150 UserShare* SyncRollbackManagerBase::GetUserShare() { |
| 150 return &share_; | 151 return &share_; |
| 151 } | 152 } |
| 152 | 153 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 syncer::ModelType type) { | 232 syncer::ModelType type) { |
| 232 ReadTransaction trans(FROM_HERE, GetUserShare()); | 233 ReadTransaction trans(FROM_HERE, GetUserShare()); |
| 233 scoped_ptr<base::ListValue> nodes( | 234 scoped_ptr<base::ListValue> nodes( |
| 234 trans.GetDirectory()->GetNodeDetailsForType(trans.GetWrappedTrans(), | 235 trans.GetDirectory()->GetNodeDetailsForType(trans.GetWrappedTrans(), |
| 235 type)); | 236 type)); |
| 236 return nodes.Pass(); | 237 return nodes.Pass(); |
| 237 } | 238 } |
| 238 | 239 |
| 239 bool SyncRollbackManagerBase::InitBackupDB( | 240 bool SyncRollbackManagerBase::InitBackupDB( |
| 240 const base::FilePath& sync_folder, | 241 const base::FilePath& sync_folder, |
| 241 InternalComponentsFactory* internal_components_factory, | 242 InternalComponentsFactory* internal_components_factory) { |
| 242 InternalComponentsFactory::StorageOption storage) { | |
| 243 base::FilePath backup_db_path = sync_folder.Append( | 243 base::FilePath backup_db_path = sync_folder.Append( |
| 244 syncable::Directory::kSyncDatabaseFilename); | 244 syncable::Directory::kSyncDatabaseFilename); |
| 245 scoped_ptr<syncable::DirectoryBackingStore> backing_store = | 245 scoped_ptr<syncable::DirectoryBackingStore> backing_store = |
| 246 internal_components_factory->BuildDirectoryBackingStore( | 246 internal_components_factory->BuildDirectoryBackingStore( |
| 247 storage, "backup", backup_db_path).Pass(); | 247 "backup", backup_db_path).Pass(); |
| 248 | 248 |
| 249 DCHECK(backing_store.get()); | 249 DCHECK(backing_store.get()); |
| 250 share_.directory.reset( | 250 share_.directory.reset( |
| 251 new syncable::Directory( | 251 new syncable::Directory( |
| 252 backing_store.release(), | 252 backing_store.release(), |
| 253 unrecoverable_error_handler_.get(), | 253 unrecoverable_error_handler_.get(), |
| 254 report_unrecoverable_error_function_, | 254 report_unrecoverable_error_function_, |
| 255 NULL, | 255 NULL, |
| 256 NULL)); | 256 NULL)); |
| 257 return syncable::OPENED == | 257 return syncable::OPENED == |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 322 |
| 323 void SyncRollbackManagerBase::UnregisterDirectoryTypeDebugInfoObserver( | 323 void SyncRollbackManagerBase::UnregisterDirectoryTypeDebugInfoObserver( |
| 324 syncer::TypeDebugInfoObserver* observer) {} | 324 syncer::TypeDebugInfoObserver* observer) {} |
| 325 | 325 |
| 326 bool SyncRollbackManagerBase::HasDirectoryTypeDebugInfoObserver( | 326 bool SyncRollbackManagerBase::HasDirectoryTypeDebugInfoObserver( |
| 327 syncer::TypeDebugInfoObserver* observer) { return false; } | 327 syncer::TypeDebugInfoObserver* observer) { return false; } |
| 328 | 328 |
| 329 void SyncRollbackManagerBase::RequestEmitDebugInfo() {} | 329 void SyncRollbackManagerBase::RequestEmitDebugInfo() {} |
| 330 | 330 |
| 331 } // namespace syncer | 331 } // namespace syncer |
| OLD | NEW |