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

Unified Diff: chrome/browser/search_engines/template_url_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: Comment 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/search_engines/template_url_service.cc
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index 016a349ab9e147e81e71a74fcefbd739f2e6411f..c90d80b75562b4760d5d013919c3342da0c0ad19 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -115,7 +115,6 @@ TemplateURLService::TemplateURLService(Profile* profile)
time_provider_(&base::Time::Now),
models_associated_(false),
processing_syncer_changes_(false),
- sync_processor_(NULL),
pending_synced_default_search_(false) {
DCHECK(profile_);
Init(NULL, 0);
@@ -134,7 +133,6 @@ TemplateURLService::TemplateURLService(const Initializer* initializers,
time_provider_(&base::Time::Now),
models_associated_(false),
processing_syncer_changes_(false),
- sync_processor_(NULL),
pending_synced_default_search_(false) {
Init(initializers, count);
}
@@ -820,11 +818,12 @@ SyncError TemplateURLService::ProcessSyncChanges(
SyncError TemplateURLService::MergeDataAndStartSyncing(
syncable::ModelType type,
const SyncDataList& initial_sync_data,
- SyncChangeProcessor* sync_processor) {
+ scoped_ptr<SyncChangeProcessor> sync_processor) {
DCHECK(loaded());
DCHECK_EQ(type, syncable::SEARCH_ENGINES);
- DCHECK(!sync_processor_);
- sync_processor_ = sync_processor;
+ DCHECK(!sync_processor_.get());
+ DCHECK(sync_processor.get());
+ sync_processor_ = sync_processor.Pass();
// We just started syncing, so set our wait-for-default flag if we are
// expecting a default from Sync.
@@ -932,7 +931,7 @@ SyncError TemplateURLService::MergeDataAndStartSyncing(
void TemplateURLService::StopSyncing(syncable::ModelType type) {
DCHECK_EQ(type, syncable::SEARCH_ENGINES);
models_associated_ = false;
- sync_processor_ = NULL;
+ sync_processor_.reset();
}
void TemplateURLService::ProcessTemplateURLChange(
@@ -1599,7 +1598,8 @@ void TemplateURLService::SetDefaultSearchProviderNoNotify(
// If we are syncing, we want to set the synced pref that will notify other
// instances to change their default to this new search provider.
- if (sync_processor_ && url && !url->sync_guid().empty() && GetPrefs()) {
+ if (sync_processor_.get() && url && !url->sync_guid().empty() &&
+ GetPrefs()) {
GetPrefs()->SetString(prefs::kSyncedDefaultSearchProviderGUID,
url->sync_guid());
}
@@ -1845,7 +1845,7 @@ void TemplateURLService::MergeSyncAndLocalURLDuplicates(
void TemplateURLService::SetDefaultSearchProviderIfNewlySynced(
const std::string& guid) {
// If we're not syncing or if default search is managed by policy, ignore.
- if (!sync_processor_ || is_default_search_managed_)
+ if (!sync_processor_.get() || is_default_search_managed_)
return;
PrefService* prefs = GetPrefs();

Powered by Google App Engine
This is Rietveld 408576698