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

Side by Side Diff: components/sync/engine/fake_sync_manager.cc

Issue 2580033002: [Sync] Ensure that CONFIGURE_CLEAN types get unapplied before configuration (Closed)
Patch Set: Adjusted comment Created 4 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/sync/engine/fake_sync_manager.h" 5 #include "components/sync/engine/fake_sync_manager.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 21 matching lines...) Expand all
32 : initial_sync_ended_types_(initial_sync_ended_types), 32 : initial_sync_ended_types_(initial_sync_ended_types),
33 progress_marker_types_(progress_marker_types), 33 progress_marker_types_(progress_marker_types),
34 configure_fail_types_(configure_fail_types), 34 configure_fail_types_(configure_fail_types),
35 last_configure_reason_(CONFIGURE_REASON_UNKNOWN), 35 last_configure_reason_(CONFIGURE_REASON_UNKNOWN),
36 num_invalidations_received_(0) { 36 num_invalidations_received_(0) {
37 fake_encryption_handler_ = base::MakeUnique<FakeSyncEncryptionHandler>(); 37 fake_encryption_handler_ = base::MakeUnique<FakeSyncEncryptionHandler>();
38 } 38 }
39 39
40 FakeSyncManager::~FakeSyncManager() {} 40 FakeSyncManager::~FakeSyncManager() {}
41 41
42 ModelTypeSet FakeSyncManager::GetAndResetCleanedTypes() { 42 ModelTypeSet FakeSyncManager::GetAndResetPurgedTypes() {
43 ModelTypeSet cleaned_types = cleaned_types_; 43 ModelTypeSet purged_types = purged_types_;
44 cleaned_types_.Clear(); 44 purged_types_.Clear();
45 return cleaned_types; 45 return purged_types;
46 }
47
48 ModelTypeSet FakeSyncManager::GetAndResetUnappliedTypes() {
49 ModelTypeSet unapplied_types = unapplied_types_;
50 unapplied_types_.Clear();
51 return unapplied_types;
46 } 52 }
47 53
48 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() { 54 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() {
49 ModelTypeSet downloaded_types = downloaded_types_; 55 ModelTypeSet downloaded_types = downloaded_types_;
50 downloaded_types_.Clear(); 56 downloaded_types_.Clear();
51 return downloaded_types; 57 return downloaded_types;
52 } 58 }
53 59
54 ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() { 60 ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() {
55 ModelTypeSet enabled_types = enabled_types_; 61 ModelTypeSet enabled_types = enabled_types_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 113 }
108 114
109 void FakeSyncManager::PurgePartiallySyncedTypes() { 115 void FakeSyncManager::PurgePartiallySyncedTypes() {
110 ModelTypeSet partial_types; 116 ModelTypeSet partial_types;
111 for (ModelTypeSet::Iterator i = progress_marker_types_.First(); i.Good(); 117 for (ModelTypeSet::Iterator i = progress_marker_types_.First(); i.Good();
112 i.Inc()) { 118 i.Inc()) {
113 if (!initial_sync_ended_types_.Has(i.Get())) 119 if (!initial_sync_ended_types_.Has(i.Get()))
114 partial_types.Put(i.Get()); 120 partial_types.Put(i.Get());
115 } 121 }
116 progress_marker_types_.RemoveAll(partial_types); 122 progress_marker_types_.RemoveAll(partial_types);
117 cleaned_types_.PutAll(partial_types); 123 purged_types_.PutAll(partial_types);
118 } 124 }
119 125
120 void FakeSyncManager::PurgeDisabledTypes(ModelTypeSet to_purge, 126 void FakeSyncManager::PurgeDisabledTypes(ModelTypeSet to_purge,
121 ModelTypeSet to_journal, 127 ModelTypeSet to_journal,
122 ModelTypeSet to_unapply) { 128 ModelTypeSet to_unapply) {
123 // Simulate cleaning up disabled types. 129 // Simulate cleaning up disabled types.
124 // TODO(sync): consider only cleaning those types that were recently disabled, 130 // TODO(sync): consider only cleaning those types that were recently disabled,
125 // if this isn't the first cleanup, which more accurately reflects the 131 // if this isn't the first cleanup, which more accurately reflects the
126 // behavior of the real cleanup logic. 132 // behavior of the real cleanup logic.
127 GetUserShare()->directory->PurgeEntriesWithTypeIn(to_purge, to_journal, 133 GetUserShare()->directory->PurgeEntriesWithTypeIn(to_purge, to_journal,
128 to_unapply); 134 to_unapply);
129 initial_sync_ended_types_.RemoveAll(to_purge); 135 purged_types_.PutAll(to_purge);
130 progress_marker_types_.RemoveAll(to_purge); 136 unapplied_types_.PutAll(to_unapply);
131 cleaned_types_.PutAll(to_purge); 137 // Types from |to_unapply| should retain their server data and progress
138 // markers.
139 initial_sync_ended_types_.RemoveAll(Difference(to_purge, to_unapply));
140 progress_marker_types_.RemoveAll(Difference(to_purge, to_unapply));
132 } 141 }
133 142
134 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { 143 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) {
135 NOTIMPLEMENTED(); 144 NOTIMPLEMENTED();
136 } 145 }
137 146
138 void FakeSyncManager::StartSyncingNormally( 147 void FakeSyncManager::StartSyncingNormally(
139 const ModelSafeRoutingInfo& routing_info, 148 const ModelSafeRoutingInfo& routing_info,
140 base::Time last_poll_time) { 149 base::Time last_poll_time) {
141 // Do nothing. 150 // Do nothing.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 271 }
263 272
264 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch, 273 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch,
265 bool empty_jar) {} 274 bool empty_jar) {}
266 275
267 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { 276 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) {
268 NOTIMPLEMENTED(); 277 NOTIMPLEMENTED();
269 } 278 }
270 279
271 } // namespace syncer 280 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/fake_sync_manager.h ('k') | components/sync/test/engine/test_syncable_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698