[Sync] Put everything in sync/api into csync namespace

BUG=128060
TEST=
TBR=pkasting@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144385 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index dc8b522..c8f2e66 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -110,24 +110,24 @@
 //  3) There is an update after an update for the same GUID. We prune earlier
 //     ones just to save bandwidth (Sync would normally coalesce them).
 bool ShouldRemoveSyncChange(size_t index,
-                            SyncChangeList* change_list,
+                            csync::SyncChangeList* change_list,
                             const SyncDataMap* sync_data) {
   DCHECK(index < change_list->size());
-  const SyncChange& change_i = (*change_list)[index];
+  const csync::SyncChange& change_i = (*change_list)[index];
   const std::string guid = change_i.sync_data().GetSpecifics()
       .search_engine().sync_guid();
-  SyncChange::SyncChangeType type = change_i.change_type();
-  if ((type == SyncChange::ACTION_UPDATE ||
-       type == SyncChange::ACTION_DELETE) &&
+  csync::SyncChange::SyncChangeType type = change_i.change_type();
+  if ((type == csync::SyncChange::ACTION_UPDATE ||
+       type == csync::SyncChange::ACTION_DELETE) &&
        sync_data->find(guid) == sync_data->end())
     return true;
-  if (type == SyncChange::ACTION_ADD &&
+  if (type == csync::SyncChange::ACTION_ADD &&
       sync_data->find(guid) != sync_data->end())
     return true;
-  if (type == SyncChange::ACTION_UPDATE) {
+  if (type == csync::SyncChange::ACTION_UPDATE) {
     for (size_t j = index + 1; j < change_list->size(); j++) {
-      const SyncChange& change_j = (*change_list)[j];
-      if ((SyncChange::ACTION_UPDATE == change_j.change_type()) &&
+      const csync::SyncChange& change_j = (*change_list)[j];
+      if ((csync::SyncChange::ACTION_UPDATE == change_j.change_type()) &&
           (change_j.sync_data().GetSpecifics().search_engine().sync_guid() ==
               guid))
         return true;
@@ -137,12 +137,12 @@
 }
 
 // Remove SyncChanges that should not be sent to the server from |change_list|.
-// This is done to eliminate incorrect SyncChanges added by the merge and
+// This is done to eliminate incorrect csync::SyncChanges added by the merge and
 // conflict resolution logic when it is unsure of whether or not an entry is new
 // from Sync or originally from the local model. This also removes changes that
 // would be otherwise be coalesced by Sync in order to save bandwidth.
 void PruneSyncChanges(const SyncDataMap* sync_data,
-                      SyncChangeList* change_list) {
+                      csync::SyncChangeList* change_list) {
   for (size_t i = 0; i < change_list->size(); ) {
     if (ShouldRemoveSyncChange(i, change_list, sync_data))
       change_list->erase(change_list->begin() + i);
@@ -863,11 +863,11 @@
   }
 }
 
-SyncDataList TemplateURLService::GetAllSyncData(
+csync::SyncDataList TemplateURLService::GetAllSyncData(
     syncable::ModelType type) const {
   DCHECK_EQ(syncable::SEARCH_ENGINES, type);
 
-  SyncDataList current_data;
+  csync::SyncDataList current_data;
   for (TemplateURLVector::const_iterator iter = template_urls_.begin();
       iter != template_urls_.end(); ++iter) {
     // We don't sync extension keywords.
@@ -884,11 +884,11 @@
   return current_data;
 }
 
-SyncError TemplateURLService::ProcessSyncChanges(
+csync::SyncError TemplateURLService::ProcessSyncChanges(
     const tracked_objects::Location& from_here,
-    const SyncChangeList& change_list) {
+    const csync::SyncChangeList& change_list) {
   if (!models_associated_) {
-    SyncError error(FROM_HERE, "Models not yet associated.",
+    csync::SyncError error(FROM_HERE, "Models not yet associated.",
                     syncable::SEARCH_ENGINES);
     return error;
   }
@@ -902,9 +902,9 @@
   AutoReset<DefaultSearchChangeOrigin> change_origin(&dsp_change_origin_,
       DSP_CHANGE_SYNC_UNINTENTIONAL);
 
-  SyncChangeList new_changes;
-  SyncError error;
-  for (SyncChangeList::const_iterator iter = change_list.begin();
+  csync::SyncChangeList new_changes;
+  csync::SyncError error;
+  for (csync::SyncChangeList::const_iterator iter = change_list.begin();
       iter != change_list.end(); ++iter) {
     DCHECK_EQ(syncable::SEARCH_ENGINES, iter->sync_data().GetDataType());
 
@@ -923,7 +923,7 @@
     // need to undergo conflict resolution.
     TemplateURL* existing_keyword_turl =
         FindNonExtensionTemplateURLForKeyword(turl->keyword());
-    if (iter->change_type() == SyncChange::ACTION_DELETE) {
+    if (iter->change_type() == csync::SyncChange::ACTION_DELETE) {
       if (!existing_turl) {
         NOTREACHED() << "Unexpected sync change state.";
         error = sync_error_factory_->CreateAndUploadError(
@@ -948,7 +948,7 @@
           SetDefaultSearchProvider(FindNewDefaultSearchProvider());
         }
       }
-    } else if (iter->change_type() == SyncChange::ACTION_ADD) {
+    } else if (iter->change_type() == csync::SyncChange::ACTION_ADD) {
       if (existing_turl) {
         NOTREACHED() << "Unexpected sync change state.";
         error = sync_error_factory_->CreateAndUploadError(
@@ -968,7 +968,7 @@
         // Possibly set the newly added |turl| as the default search provider.
         SetDefaultSearchProviderIfNewlySynced(guid);
       }
-    } else if (iter->change_type() == SyncChange::ACTION_UPDATE) {
+    } else if (iter->change_type() == csync::SyncChange::ACTION_UPDATE) {
       if (!existing_turl) {
         NOTREACHED() << "Unexpected sync change state.";
         error = sync_error_factory_->CreateAndUploadError(
@@ -1010,11 +1010,11 @@
   return error;
 }
 
-SyncError TemplateURLService::MergeDataAndStartSyncing(
+csync::SyncError TemplateURLService::MergeDataAndStartSyncing(
     syncable::ModelType type,
-    const SyncDataList& initial_sync_data,
-    scoped_ptr<SyncChangeProcessor> sync_processor,
-    scoped_ptr<SyncErrorFactory> sync_error_factory) {
+    const csync::SyncDataList& initial_sync_data,
+    scoped_ptr<csync::SyncChangeProcessor> sync_processor,
+    scoped_ptr<csync::SyncErrorFactory> sync_error_factory) {
   DCHECK(loaded_);
   DCHECK_EQ(type, syncable::SEARCH_ENGINES);
   DCHECK(!sync_processor_.get());
@@ -1045,9 +1045,9 @@
   AutoReset<DefaultSearchChangeOrigin> change_origin(&dsp_change_origin_,
       DSP_CHANGE_SYNC_UNINTENTIONAL);
 
-  SyncChangeList new_changes;
+  csync::SyncChangeList new_changes;
 
-  // Build maps of our sync GUIDs to SyncData.
+  // Build maps of our sync GUIDs to csync::SyncData.
   SyncDataMap local_data_map = CreateGUIDToSyncDataMap(
       GetAllSyncData(syncable::SEARCH_ENGINES));
   SyncDataMap sync_data_map = CreateGUIDToSyncDataMap(initial_sync_data);
@@ -1066,7 +1066,7 @@
       // This entry was deleted before the initial sync began (possibly through
       // preprocessing in TemplateURLService's loading code). Ignore it and send
       // an ACTION_DELETE up to the server.
-      new_changes.push_back(SyncChange(SyncChange::ACTION_DELETE,
+      new_changes.push_back(csync::SyncChange(csync::SyncChange::ACTION_DELETE,
                                        iter->second));
       continue;
     }
@@ -1087,7 +1087,8 @@
       } else if (sync_turl->last_modified() < local_turl->last_modified()) {
         // Otherwise, we know we have newer data, so update Sync with our
         // data fields.
-        new_changes.push_back(SyncChange(SyncChange::ACTION_UPDATE,
+        new_changes.push_back(
+            csync::SyncChange(csync::SyncChange::ACTION_UPDATE,
             local_data_map[local_turl->sync_guid()]));
       }
       local_data_map.erase(iter->first);
@@ -1129,14 +1130,16 @@
   // be pushed as ADDs to sync.
   for (SyncDataMap::const_iterator iter = local_data_map.begin();
       iter != local_data_map.end(); ++iter) {
-    new_changes.push_back(SyncChange(SyncChange::ACTION_ADD, iter->second));
+    new_changes.push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_ADD, iter->second));
   }
 
   // Do some post-processing on the change list to ensure that we are sending
   // valid changes to sync_processor_.
   PruneSyncChanges(&sync_data_map, &new_changes);
 
-  SyncError error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
+  csync::SyncError error =
+      sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
   if (error.IsSet())
     return error;
 
@@ -1145,7 +1148,7 @@
   pre_sync_deletes_.clear();
 
   models_associated_ = true;
-  return SyncError();
+  return csync::SyncError();
 }
 
 void TemplateURLService::StopSyncing(syncable::ModelType type) {
@@ -1157,8 +1160,8 @@
 
 void TemplateURLService::ProcessTemplateURLChange(
     const TemplateURL* turl,
-    SyncChange::SyncChangeType type) {
-  DCHECK_NE(type, SyncChange::ACTION_INVALID);
+    csync::SyncChange::SyncChangeType type) {
+  DCHECK_NE(type, csync::SyncChange::ACTION_INVALID);
   DCHECK(turl);
 
   if (!models_associated_)
@@ -1177,16 +1180,16 @@
   if (turl->created_by_policy())
     return;
 
-  SyncChangeList changes;
+  csync::SyncChangeList changes;
 
-  SyncData sync_data = CreateSyncDataFromTemplateURL(*turl);
-  changes.push_back(SyncChange(type, sync_data));
+  csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl);
+  changes.push_back(csync::SyncChange(type, sync_data));
 
   sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
 }
 
 // static
-SyncData TemplateURLService::CreateSyncDataFromTemplateURL(
+csync::SyncData TemplateURLService::CreateSyncDataFromTemplateURL(
     const TemplateURL& turl) {
   sync_pb::EntitySpecifics specifics;
   sync_pb::SearchEngineSpecifics* se_specifics =
@@ -1205,7 +1208,7 @@
   se_specifics->set_instant_url(turl.instant_url());
   se_specifics->set_last_modified(turl.last_modified().ToInternalValue());
   se_specifics->set_sync_guid(turl.sync_guid());
-  return SyncData::CreateLocalData(se_specifics->sync_guid(),
+  return csync::SyncData::CreateLocalData(se_specifics->sync_guid(),
                                    se_specifics->keyword(),
                                    specifics);
 }
@@ -1214,8 +1217,8 @@
 TemplateURL* TemplateURLService::CreateTemplateURLFromTemplateURLAndSyncData(
     Profile* profile,
     TemplateURL* existing_turl,
-    const SyncData& sync_data,
-    SyncChangeList* change_list) {
+    const csync::SyncData& sync_data,
+    csync::SyncChangeList* change_list) {
   DCHECK(change_list);
 
   sync_pb::SearchEngineSpecifics specifics =
@@ -1224,7 +1227,8 @@
   // Past bugs might have caused either of these fields to be empty.  Just
   // delete this data off the server.
   if (specifics.url().empty() || specifics.sync_guid().empty()) {
-    change_list->push_back(SyncChange(SyncChange::ACTION_DELETE, sync_data));
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_DELETE, sync_data));
     return NULL;
   }
 
@@ -1259,8 +1263,9 @@
   DCHECK(!turl->IsExtensionKeyword());
   if (reset_keyword) {
     turl->ResetKeywordIfNecessary(true);
-    SyncData sync_data = CreateSyncDataFromTemplateURL(*turl);
-    change_list->push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
+    csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl);
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_UPDATE, sync_data));
   } else if (turl->IsGoogleSearchURLWithReplaceableKeyword()) {
     if (!existing_turl) {
       // We're adding a new TemplateURL that uses the Google base URL, so set
@@ -1281,9 +1286,10 @@
 
 // static
 SyncDataMap TemplateURLService::CreateGUIDToSyncDataMap(
-    const SyncDataList& sync_data) {
+    const csync::SyncDataList& sync_data) {
   SyncDataMap data_map;
-  for (SyncDataList::const_iterator i(sync_data.begin()); i != sync_data.end();
+  for (csync::SyncDataList::const_iterator i(sync_data.begin());
+       i != sync_data.end();
        ++i)
     data_map[i->GetSpecifics().search_engine().sync_guid()] = *i;
   return data_map;
@@ -1715,7 +1721,7 @@
     service_->UpdateKeyword(existing_turl->data());
 
   // Inform sync of the update.
-  ProcessTemplateURLChange(existing_turl, SyncChange::ACTION_UPDATE);
+  ProcessTemplateURLChange(existing_turl, csync::SyncChange::ACTION_UPDATE);
 
   if (default_search_provider_ == existing_turl) {
     bool success = SetDefaultSearchProviderNoNotify(existing_turl);
@@ -2046,7 +2052,7 @@
 
   // Inform sync the change to the show_in_default_list flag.
   if (url)
-    ProcessTemplateURLChange(url, SyncChange::ACTION_UPDATE);
+    ProcessTemplateURLChange(url, csync::SyncChange::ACTION_UPDATE);
   return true;
 }
 
@@ -2095,7 +2101,7 @@
 
     // Inform sync of the addition. Note that this will assign a GUID to
     // template_url and add it to the guid_to_template_map_.
-    ProcessTemplateURLChange(template_url, SyncChange::ACTION_ADD);
+    ProcessTemplateURLChange(template_url, csync::SyncChange::ACTION_ADD);
   }
 
   return true;
@@ -2125,7 +2131,7 @@
     service_->RemoveKeyword(template_url->id());
 
   // Inform sync of the deletion.
-  ProcessTemplateURLChange(template_url, SyncChange::ACTION_DELETE);
+  ProcessTemplateURLChange(template_url, csync::SyncChange::ACTION_DELETE);
 
   if (profile_) {
     content::Source<Profile> source(profile_);
@@ -2237,7 +2243,7 @@
 bool TemplateURLService::ResolveSyncKeywordConflict(
     TemplateURL* sync_turl,
     TemplateURL* local_turl,
-    SyncChangeList* change_list) {
+    csync::SyncChangeList* change_list) {
   DCHECK(loaded_);
   DCHECK(sync_turl);
   DCHECK(local_turl);
@@ -2251,8 +2257,9 @@
       (local_turl == GetDefaultSearchProvider());
   const bool can_replace_local = CanReplace(local_turl);
   if (CanReplace(sync_turl) && (local_is_better || !can_replace_local)) {
-    SyncData sync_data = CreateSyncDataFromTemplateURL(*sync_turl);
-    change_list->push_back(SyncChange(SyncChange::ACTION_DELETE, sync_data));
+    csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*sync_turl);
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_DELETE, sync_data));
     return false;
   }
   if (can_replace_local) {
@@ -2263,8 +2270,9 @@
     // than having just been brought down, then this is wrong, because the
     // server doesn't yet know about this entity; but in this case,
     // PruneSyncChanges() will prune out the ACTION_DELETE we create here.
-    SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
-    change_list->push_back(SyncChange(SyncChange::ACTION_DELETE, sync_data));
+    csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_DELETE, sync_data));
     Remove(local_turl);
   } else if (local_is_better) {
     string16 new_keyword = UniquifyKeyword(*sync_turl);
@@ -2272,8 +2280,9 @@
     sync_turl->data_.SetKeyword(new_keyword);
     // If we update the cloud TURL, we need to push an update back to sync
     // informing it that something has changed.
-    SyncData sync_data = CreateSyncDataFromTemplateURL(*sync_turl);
-    change_list->push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
+    csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*sync_turl);
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_UPDATE, sync_data));
   } else {
     string16 new_keyword = UniquifyKeyword(*local_turl);
     TemplateURLData data(local_turl->data());
@@ -2290,8 +2299,9 @@
     // server won't know about this entity until it processes the ACTION_ADD our
     // caller will later generate; but in this case, PruneSyncChanges() will
     // prune out the ACTION_UPDATE we create here.
-    SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
-    change_list->push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
+    csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_UPDATE, sync_data));
   }
   return true;
 }
@@ -2306,7 +2316,7 @@
 void TemplateURLService::MergeSyncAndLocalURLDuplicates(
     TemplateURL* sync_turl,
     TemplateURL* local_turl,
-    SyncChangeList* change_list) {
+    csync::SyncChangeList* change_list) {
   DCHECK(loaded_);
   DCHECK(sync_turl);
   DCHECK(local_turl);
@@ -2324,8 +2334,9 @@
 
     // See comments in ResolveSyncKeywordConflict() regarding generating an
     // ACTION_DELETE manually since Remove() won't do it.
-    SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
-    change_list->push_back(SyncChange(SyncChange::ACTION_DELETE, sync_data));
+    csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_DELETE, sync_data));
     Remove(local_turl);
 
     // Force the local ID to kInvalidTemplateURLID so we can add it.
@@ -2339,8 +2350,9 @@
     // the server, and the next time local_url is synced, it is recognized by
     // having the same GUID.
     ResetTemplateURLGUID(local_turl, sync_turl->sync_guid());
-    SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
-    change_list->push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
+    csync::SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl);
+    change_list->push_back(
+        csync::SyncChange(csync::SyncChange::ACTION_UPDATE, sync_data));
   }
 }