| 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_backup_manager.h" | 5 #include "sync/internal_api/sync_backup_manager.h" |
| 6 | 6 |
| 7 #include "sync/internal_api/public/read_node.h" | 7 #include "sync/internal_api/public/read_node.h" |
| 8 #include "sync/internal_api/public/write_transaction.h" | 8 #include "sync/internal_api/public/write_transaction.h" |
| 9 #include "sync/syncable/directory.h" | 9 #include "sync/syncable/directory.h" |
| 10 #include "sync/syncable/mutable_entry.h" | 10 #include "sync/syncable/mutable_entry.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 namespace syncer { | 13 namespace syncer { |
| 14 | 14 |
| 15 SyncBackupManager::SyncBackupManager() | 15 SyncBackupManager::SyncBackupManager() |
| 16 : in_normalization_(false) { | 16 : in_normalization_(false) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 SyncBackupManager::~SyncBackupManager() { | 19 SyncBackupManager::~SyncBackupManager() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 void SyncBackupManager::Init(InitArgs* args) { | 22 void SyncBackupManager::Init(InitArgs* args) { |
| 23 if (SyncRollbackManagerBase::InitInternal( | 23 if (SyncRollbackManagerBase::InitInternal( |
| 24 args->database_location, | 24 args->database_location, |
| 25 args->internal_components_factory.get(), | 25 args->internal_components_factory.get(), |
| 26 InternalComponentsFactory::STORAGE_ON_DISK_DEFERRED, | |
| 27 args->unrecoverable_error_handler.Pass(), | 26 args->unrecoverable_error_handler.Pass(), |
| 28 args->report_unrecoverable_error_function)) { | 27 args->report_unrecoverable_error_function)) { |
| 29 GetUserShare()->directory->CollectMetaHandleCounts( | 28 GetUserShare()->directory->CollectMetaHandleCounts( |
| 30 &status_.num_entries_by_type, &status_.num_to_delete_entries_by_type); | 29 &status_.num_entries_by_type, &status_.num_to_delete_entries_by_type); |
| 31 | 30 |
| 32 HideSyncPreference(PRIORITY_PREFERENCES); | 31 HideSyncPreference(PRIORITY_PREFERENCES); |
| 33 HideSyncPreference(PREFERENCES); | 32 HideSyncPreference(PREFERENCES); |
| 34 } | 33 } |
| 35 } | 34 } |
| 36 | 35 |
| 37 void SyncBackupManager::SaveChanges() { | 36 void SyncBackupManager::SaveChanges() { |
| 38 if (initialized()) | 37 if (initialized()) { |
| 39 NormalizeEntries(); | 38 NormalizeEntries(); |
| 39 GetUserShare()->directory->SaveChanges(); |
| 40 } |
| 40 } | 41 } |
| 41 | 42 |
| 42 SyncStatus SyncBackupManager::GetDetailedStatus() const { | 43 SyncStatus SyncBackupManager::GetDetailedStatus() const { |
| 43 return status_; | 44 return status_; |
| 44 } | 45 } |
| 45 | 46 |
| 46 ModelTypeSet SyncBackupManager::HandleTransactionEndingChangeEvent( | 47 ModelTypeSet SyncBackupManager::HandleTransactionEndingChangeEvent( |
| 47 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 48 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
| 48 syncable::BaseTransaction* trans) { | 49 syncable::BaseTransaction* trans) { |
| 49 ModelTypeSet types; | 50 ModelTypeSet types; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 entry.PutIsUnsynced(false); | 115 entry.PutIsUnsynced(false); |
| 115 | 116 |
| 116 // Don't persist on disk so that if backup is aborted before receiving | 117 // Don't persist on disk so that if backup is aborted before receiving |
| 117 // local preference values, values in sync DB are saved. | 118 // local preference values, values in sync DB are saved. |
| 118 GetUserShare()->directory->UnmarkDirtyEntry( | 119 GetUserShare()->directory->UnmarkDirtyEntry( |
| 119 trans.GetWrappedWriteTrans(), &entry); | 120 trans.GetWrappedWriteTrans(), &entry); |
| 120 } | 121 } |
| 121 } | 122 } |
| 122 } | 123 } |
| 123 | 124 |
| 124 void SyncBackupManager::ShutdownOnSyncThread(ShutdownReason reason) { | |
| 125 if (reason == SWITCH_MODE_SYNC) { | |
| 126 NormalizeEntries(); | |
| 127 GetUserShare()->directory->SaveChanges(); | |
| 128 } | |
| 129 | |
| 130 SyncRollbackManagerBase::ShutdownOnSyncThread(reason); | |
| 131 } | |
| 132 | |
| 133 void SyncBackupManager::RegisterDirectoryTypeDebugInfoObserver( | 125 void SyncBackupManager::RegisterDirectoryTypeDebugInfoObserver( |
| 134 syncer::TypeDebugInfoObserver* observer) {} | 126 syncer::TypeDebugInfoObserver* observer) {} |
| 135 | 127 |
| 136 void SyncBackupManager::UnregisterDirectoryTypeDebugInfoObserver( | 128 void SyncBackupManager::UnregisterDirectoryTypeDebugInfoObserver( |
| 137 syncer::TypeDebugInfoObserver* observer) {} | 129 syncer::TypeDebugInfoObserver* observer) {} |
| 138 | 130 |
| 139 bool SyncBackupManager::HasDirectoryTypeDebugInfoObserver( | 131 bool SyncBackupManager::HasDirectoryTypeDebugInfoObserver( |
| 140 syncer::TypeDebugInfoObserver* observer) { return false; } | 132 syncer::TypeDebugInfoObserver* observer) { return false; } |
| 141 | 133 |
| 142 void SyncBackupManager::RequestEmitDebugInfo() {} | 134 void SyncBackupManager::RequestEmitDebugInfo() {} |
| 143 | 135 |
| 144 } // namespace syncer | 136 } // namespace syncer |
| OLD | NEW |