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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const std::string& restored_key_for_bootstrapping, | 32 const std::string& restored_key_for_bootstrapping, |
33 const std::string& restored_keystore_key_for_bootstrapping, | 33 const std::string& restored_keystore_key_for_bootstrapping, |
34 InternalComponentsFactory* internal_components_factory, | 34 InternalComponentsFactory* internal_components_factory, |
35 Encryptor* encryptor, | 35 Encryptor* encryptor, |
36 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | 36 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, |
37 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, | 37 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, |
38 CancelationSignal* cancelation_signal) { | 38 CancelationSignal* cancelation_signal) { |
39 if (SyncRollbackManagerBase::InitInternal( | 39 if (SyncRollbackManagerBase::InitInternal( |
40 database_location, | 40 database_location, |
41 internal_components_factory, | 41 internal_components_factory, |
| 42 InternalComponentsFactory::STORAGE_ON_DISK_DEFERRED, |
42 unrecoverable_error_handler.Pass(), | 43 unrecoverable_error_handler.Pass(), |
43 report_unrecoverable_error_function)) { | 44 report_unrecoverable_error_function)) { |
44 GetUserShare()->directory->CollectMetaHandleCounts( | 45 GetUserShare()->directory->CollectMetaHandleCounts( |
45 &status_.num_entries_by_type, &status_.num_to_delete_entries_by_type); | 46 &status_.num_entries_by_type, &status_.num_to_delete_entries_by_type); |
46 | 47 |
47 HideSyncPreference(PRIORITY_PREFERENCES); | 48 HideSyncPreference(PRIORITY_PREFERENCES); |
48 HideSyncPreference(PREFERENCES); | 49 HideSyncPreference(PREFERENCES); |
49 } | 50 } |
50 } | 51 } |
51 | 52 |
52 void SyncBackupManager::SaveChanges() { | 53 void SyncBackupManager::SaveChanges() { |
53 if (initialized()) { | 54 if (initialized()) |
54 NormalizeEntries(); | 55 NormalizeEntries(); |
55 GetUserShare()->directory->SaveChanges(); | |
56 } | |
57 } | 56 } |
58 | 57 |
59 SyncStatus SyncBackupManager::GetDetailedStatus() const { | 58 SyncStatus SyncBackupManager::GetDetailedStatus() const { |
60 return status_; | 59 return status_; |
61 } | 60 } |
62 | 61 |
63 ModelTypeSet SyncBackupManager::HandleTransactionEndingChangeEvent( | 62 ModelTypeSet SyncBackupManager::HandleTransactionEndingChangeEvent( |
64 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 63 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
65 syncable::BaseTransaction* trans) { | 64 syncable::BaseTransaction* trans) { |
66 ModelTypeSet types; | 65 ModelTypeSet types; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 entry.PutIsUnsynced(false); | 130 entry.PutIsUnsynced(false); |
132 | 131 |
133 // Don't persist on disk so that if backup is aborted before receiving | 132 // Don't persist on disk so that if backup is aborted before receiving |
134 // local preference values, values in sync DB are saved. | 133 // local preference values, values in sync DB are saved. |
135 GetUserShare()->directory->UnmarkDirtyEntry( | 134 GetUserShare()->directory->UnmarkDirtyEntry( |
136 trans.GetWrappedWriteTrans(), &entry); | 135 trans.GetWrappedWriteTrans(), &entry); |
137 } | 136 } |
138 } | 137 } |
139 } | 138 } |
140 | 139 |
| 140 void SyncBackupManager::ShutdownOnSyncThread(ShutdownReason reason) { |
| 141 if (reason == SWITCH_MODE_SYNC) { |
| 142 NormalizeEntries(); |
| 143 GetUserShare()->directory->SaveChanges(); |
| 144 } |
| 145 |
| 146 SyncRollbackManagerBase::ShutdownOnSyncThread(reason); |
| 147 } |
| 148 |
141 void SyncBackupManager::RegisterDirectoryTypeDebugInfoObserver( | 149 void SyncBackupManager::RegisterDirectoryTypeDebugInfoObserver( |
142 syncer::TypeDebugInfoObserver* observer) {} | 150 syncer::TypeDebugInfoObserver* observer) {} |
143 | 151 |
144 void SyncBackupManager::UnregisterDirectoryTypeDebugInfoObserver( | 152 void SyncBackupManager::UnregisterDirectoryTypeDebugInfoObserver( |
145 syncer::TypeDebugInfoObserver* observer) {} | 153 syncer::TypeDebugInfoObserver* observer) {} |
146 | 154 |
147 bool SyncBackupManager::HasDirectoryTypeDebugInfoObserver( | 155 bool SyncBackupManager::HasDirectoryTypeDebugInfoObserver( |
148 syncer::TypeDebugInfoObserver* observer) { return false; } | 156 syncer::TypeDebugInfoObserver* observer) { return false; } |
149 | 157 |
150 void SyncBackupManager::RequestEmitDebugInfo() {} | 158 void SyncBackupManager::RequestEmitDebugInfo() {} |
151 | 159 |
152 } // namespace syncer | 160 } // namespace syncer |
OLD | NEW |