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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 9749012: [Sync] Have SyncableService's take ownership of their SyncChangeProcessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser_tests Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index af61980d276af50bd8114af8b1447f01789446af..370381968256c5d85698ff54a883e226eca6fb38 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -1258,13 +1258,19 @@ namespace {
} // namespace
ExtensionService::SyncBundle::SyncBundle()
- : filter(IsSyncableNone),
- sync_processor(NULL) {
+ : filter(IsSyncableNone) {
}
ExtensionService::SyncBundle::~SyncBundle() {
}
+void ExtensionService::SyncBundle::Reset() {
+ filter = IsSyncableNone;
+ synced_extensions.clear();
+ pending_sync_data.clear();
+ sync_processor.reset();
+}
+
bool ExtensionService::SyncBundle::HasExtensionId(const std::string& id) const {
return synced_extensions.find(id) != synced_extensions.end();
}
@@ -1349,9 +1355,7 @@ ExtensionService::SyncBundle* ExtensionService::GetSyncBundleForModelType(
SyncError ExtensionService::MergeDataAndStartSyncing(
syncable::ModelType type,
const SyncDataList& initial_sync_data,
- SyncChangeProcessor* sync_processor) {
- CHECK(sync_processor);
-
+ scoped_ptr<SyncChangeProcessor> sync_processor) {
SyncBundle* bundle = NULL;
switch (type) {
@@ -1368,8 +1372,9 @@ SyncError ExtensionService::MergeDataAndStartSyncing(
default:
LOG(FATAL) << "Got " << type << " ModelType";
}
-
- bundle->sync_processor = sync_processor;
+ DCHECK(!bundle->sync_processor.get());
+ DCHECK(sync_processor.get());
+ bundle->sync_processor = sync_processor.Pass();
// Process extensions from sync.
for (SyncDataList::const_iterator i = initial_sync_data.begin();
@@ -1405,8 +1410,7 @@ SyncError ExtensionService::MergeDataAndStartSyncing(
void ExtensionService::StopSyncing(syncable::ModelType type) {
SyncBundle* bundle = GetSyncBundleForModelType(type);
CHECK(bundle);
- // This is the simplest way to clear out the bundle.
- *bundle = SyncBundle();
+ bundle->Reset();
}
SyncDataList ExtensionService::GetAllSyncData(syncable::ModelType type) const {

Powered by Google App Engine
This is Rietveld 408576698