Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: sync/internal_api/sync_backup_manager.cc

Issue 455023003: Let SyncBackupManager keep backup data in memory until shutdown. Only persist (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix sync manager test Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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,
26 args->unrecoverable_error_handler.Pass(), 27 args->unrecoverable_error_handler.Pass(),
27 args->report_unrecoverable_error_function)) { 28 args->report_unrecoverable_error_function)) {
28 GetUserShare()->directory->CollectMetaHandleCounts( 29 GetUserShare()->directory->CollectMetaHandleCounts(
29 &status_.num_entries_by_type, &status_.num_to_delete_entries_by_type); 30 &status_.num_entries_by_type, &status_.num_to_delete_entries_by_type);
30 31
31 HideSyncPreference(PRIORITY_PREFERENCES); 32 HideSyncPreference(PRIORITY_PREFERENCES);
32 HideSyncPreference(PREFERENCES); 33 HideSyncPreference(PREFERENCES);
33 } 34 }
34 } 35 }
35 36
36 void SyncBackupManager::SaveChanges() { 37 void SyncBackupManager::SaveChanges() {
37 if (initialized()) { 38 if (initialized())
38 NormalizeEntries(); 39 NormalizeEntries();
39 GetUserShare()->directory->SaveChanges();
40 }
41 } 40 }
42 41
43 SyncStatus SyncBackupManager::GetDetailedStatus() const { 42 SyncStatus SyncBackupManager::GetDetailedStatus() const {
44 return status_; 43 return status_;
45 } 44 }
46 45
47 ModelTypeSet SyncBackupManager::HandleTransactionEndingChangeEvent( 46 ModelTypeSet SyncBackupManager::HandleTransactionEndingChangeEvent(
48 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, 47 const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
49 syncable::BaseTransaction* trans) { 48 syncable::BaseTransaction* trans) {
50 ModelTypeSet types; 49 ModelTypeSet types;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 entry.PutIsUnsynced(false); 114 entry.PutIsUnsynced(false);
116 115
117 // Don't persist on disk so that if backup is aborted before receiving 116 // Don't persist on disk so that if backup is aborted before receiving
118 // local preference values, values in sync DB are saved. 117 // local preference values, values in sync DB are saved.
119 GetUserShare()->directory->UnmarkDirtyEntry( 118 GetUserShare()->directory->UnmarkDirtyEntry(
120 trans.GetWrappedWriteTrans(), &entry); 119 trans.GetWrappedWriteTrans(), &entry);
121 } 120 }
122 } 121 }
123 } 122 }
124 123
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
125 void SyncBackupManager::RegisterDirectoryTypeDebugInfoObserver( 133 void SyncBackupManager::RegisterDirectoryTypeDebugInfoObserver(
126 syncer::TypeDebugInfoObserver* observer) {} 134 syncer::TypeDebugInfoObserver* observer) {}
127 135
128 void SyncBackupManager::UnregisterDirectoryTypeDebugInfoObserver( 136 void SyncBackupManager::UnregisterDirectoryTypeDebugInfoObserver(
129 syncer::TypeDebugInfoObserver* observer) {} 137 syncer::TypeDebugInfoObserver* observer) {}
130 138
131 bool SyncBackupManager::HasDirectoryTypeDebugInfoObserver( 139 bool SyncBackupManager::HasDirectoryTypeDebugInfoObserver(
132 syncer::TypeDebugInfoObserver* observer) { return false; } 140 syncer::TypeDebugInfoObserver* observer) { return false; }
133 141
134 void SyncBackupManager::RequestEmitDebugInfo() {} 142 void SyncBackupManager::RequestEmitDebugInfo() {}
135 143
136 } // namespace syncer 144 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_backup_manager.h ('k') | sync/internal_api/sync_backup_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698