[Sync] Have SyncableService's take ownership of their SyncChangeProcessor.

The UIDataTypeController now uses a SharedChangeProcessor, and passes a ref
to the SyncableService's. Every SyncableService now owns its own change
processor. Additionally, we use the ScopedPtr::Pass semantics for passing
around SyncChangeProcessors to ensure SyncableServices properly take
ownership.

This, along with all the test updates it requires (most of the patch) fixes
several leaks introduced in the previous patch to remove the Syncable Service
Adapter. SyncableServiceMock is removed as it didn't play nice with
scoped_ptr parameters (and was hardly used).

BUG=117098,117538
TEST=unit_tests with valgrind/drmemory/heapcheck
[email protected]

Review URL: https://chromiumcodereview.appspot.com/9749012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128578 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/prefs/pref_model_associator.cc b/chrome/browser/prefs/pref_model_associator.cc
index 21c53a2..b70302a8 100644
--- a/chrome/browser/prefs/pref_model_associator.cc
+++ b/chrome/browser/prefs/pref_model_associator.cc
@@ -22,14 +22,12 @@
 PrefModelAssociator::PrefModelAssociator()
     : models_associated_(false),
       processing_syncer_changes_(false),
-      pref_service_(NULL),
-      sync_processor_(NULL) {
+      pref_service_(NULL) {
   DCHECK(CalledOnValidThread());
 }
 
 PrefModelAssociator::~PrefModelAssociator() {
   DCHECK(CalledOnValidThread());
-  sync_processor_ = NULL;
   pref_service_ = NULL;
 }
 
@@ -109,12 +107,13 @@
 SyncError PrefModelAssociator::MergeDataAndStartSyncing(
     syncable::ModelType type,
     const SyncDataList& initial_sync_data,
-    SyncChangeProcessor* sync_processor) {
+    scoped_ptr<SyncChangeProcessor> sync_processor) {
   DCHECK_EQ(type, PREFERENCES);
   DCHECK(CalledOnValidThread());
   DCHECK(pref_service_);
-  DCHECK(!sync_processor_);
-  sync_processor_ = sync_processor;
+  DCHECK(!sync_processor_.get());
+  DCHECK(sync_processor.get());
+  sync_processor_ = sync_processor.Pass();
 
   SyncChangeList new_changes;
   std::set<std::string> remaining_preferences = registered_preferences_;
@@ -161,7 +160,7 @@
 void PrefModelAssociator::StopSyncing(syncable::ModelType type) {
   DCHECK_EQ(type, PREFERENCES);
   models_associated_ = false;
-  sync_processor_ = NULL;
+  sync_processor_.reset();
 }
 
 Value* PrefModelAssociator::MergePreference(
@@ -425,8 +424,6 @@
 
   SyncError error =
       sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
-  if (error.IsSet())
-    StopSyncing(PREFERENCES);
 }
 
 void PrefModelAssociator::SetPrefService(PrefService* pref_service) {