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

Unified Diff: components/sync/syncable/directory.cc

Issue 2563883006: [Sync] Separate purge types step from sync manager configuration. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/syncable/directory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/syncable/directory.cc
diff --git a/components/sync/syncable/directory.cc b/components/sync/syncable/directory.cc
index ba417e757a4f322bddbcaa6f6e08ebda9df30b1e..42fd457bc24b81b35816b68cd3b36cb4f32882b1 100644
--- a/components/sync/syncable/directory.cc
+++ b/components/sync/syncable/directory.cc
@@ -729,81 +729,77 @@ void Directory::DeleteEntry(const ScopedKernelLock& lock,
}
}
-bool Directory::PurgeEntriesWithTypeIn(ModelTypeSet disabled_types,
+void Directory::PurgeEntriesWithTypeIn(ModelTypeSet disabled_types,
ModelTypeSet types_to_journal,
ModelTypeSet types_to_unapply) {
disabled_types.RemoveAll(ProxyTypes());
-
if (disabled_types.Empty())
- return true;
+ return;
- {
- WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this);
+ WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this);
- OwnedEntryKernelSet entries_to_journal;
+ OwnedEntryKernelSet entries_to_journal;
- {
- ScopedKernelLock lock(this);
+ {
+ ScopedKernelLock lock(this);
- bool found_progress = false;
- for (ModelTypeSet::Iterator iter = disabled_types.First(); iter.Good();
- iter.Inc()) {
- if (!kernel_->persisted_info.HasEmptyDownloadProgress(iter.Get()))
- found_progress = true;
- }
+ bool found_progress = false;
+ for (ModelTypeSet::Iterator iter = disabled_types.First(); iter.Good();
+ iter.Inc()) {
+ if (!kernel_->persisted_info.HasEmptyDownloadProgress(iter.Get()))
+ found_progress = true;
+ }
- // If none of the disabled types have progress markers, there's nothing to
- // purge.
- if (!found_progress)
- return true;
-
- for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin();
- it != kernel_->metahandles_map.end();) {
- EntryKernel* entry = it->second.get();
- const sync_pb::EntitySpecifics& local_specifics = entry->ref(SPECIFICS);
- const sync_pb::EntitySpecifics& server_specifics =
- entry->ref(SERVER_SPECIFICS);
- ModelType local_type = GetModelTypeFromSpecifics(local_specifics);
- ModelType server_type = GetModelTypeFromSpecifics(server_specifics);
-
- // Increment the iterator before (potentially) calling DeleteEntry,
- // otherwise our iterator may be invalidated.
- ++it;
-
- if ((IsRealDataType(local_type) && disabled_types.Has(local_type)) ||
- (IsRealDataType(server_type) && disabled_types.Has(server_type))) {
- if (types_to_unapply.Has(local_type) ||
- types_to_unapply.Has(server_type)) {
- UnapplyEntry(entry);
- } else {
- bool save_to_journal =
- (types_to_journal.Has(local_type) ||
- types_to_journal.Has(server_type)) &&
- (delete_journal_->IsDeleteJournalEnabled(local_type) ||
- delete_journal_->IsDeleteJournalEnabled(server_type));
- DeleteEntry(lock, save_to_journal, entry, &entries_to_journal);
- }
+ // If none of the disabled types have progress markers, there's nothing to
+ // purge.
+ if (!found_progress)
+ return;
+
+ for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin();
+ it != kernel_->metahandles_map.end();) {
+ EntryKernel* entry = it->second.get();
+ const sync_pb::EntitySpecifics& local_specifics = entry->ref(SPECIFICS);
+ const sync_pb::EntitySpecifics& server_specifics =
+ entry->ref(SERVER_SPECIFICS);
+ ModelType local_type = GetModelTypeFromSpecifics(local_specifics);
+ ModelType server_type = GetModelTypeFromSpecifics(server_specifics);
+
+ // Increment the iterator before (potentially) calling DeleteEntry,
+ // otherwise our iterator may be invalidated.
+ ++it;
+
+ if ((IsRealDataType(local_type) && disabled_types.Has(local_type)) ||
+ (IsRealDataType(server_type) && disabled_types.Has(server_type))) {
+ if (types_to_unapply.Has(local_type) ||
+ types_to_unapply.Has(server_type)) {
+ UnapplyEntry(entry);
+ } else {
+ bool save_to_journal =
+ (types_to_journal.Has(local_type) ||
+ types_to_journal.Has(server_type)) &&
+ (delete_journal_->IsDeleteJournalEnabled(local_type) ||
+ delete_journal_->IsDeleteJournalEnabled(server_type));
+ DeleteEntry(lock, save_to_journal, entry, &entries_to_journal);
}
}
+ }
- delete_journal_->AddJournalBatch(&trans, entries_to_journal);
+ delete_journal_->AddJournalBatch(&trans, entries_to_journal);
- // Ensure meta tracking for these data types reflects the purged state.
- for (ModelTypeSet::Iterator it = disabled_types.First(); it.Good();
- it.Inc()) {
- kernel_->persisted_info.transaction_version[it.Get()] = 0;
+ // Ensure meta tracking for these data types reflects the purged state.
+ for (ModelTypeSet::Iterator it = disabled_types.First(); it.Good();
+ it.Inc()) {
+ kernel_->persisted_info.transaction_version[it.Get()] = 0;
- // Don't discard progress markers or context for unapplied types.
- if (!types_to_unapply.Has(it.Get())) {
- kernel_->persisted_info.ResetDownloadProgress(it.Get());
- kernel_->persisted_info.datatype_context[it.Get()].Clear();
- }
+ // Don't discard progress markers or context for unapplied types.
+ if (!types_to_unapply.Has(it.Get())) {
+ kernel_->persisted_info.ResetDownloadProgress(it.Get());
+ kernel_->persisted_info.datatype_context[it.Get()].Clear();
}
-
- kernel_->info_status = KERNEL_SHARE_INFO_DIRTY;
}
+
+ kernel_->info_status = KERNEL_SHARE_INFO_DIRTY;
}
- return true;
}
bool Directory::ResetVersionsForType(BaseWriteTransaction* trans,
« no previous file with comments | « components/sync/syncable/directory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698