summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-17 15:54:29 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-17 15:54:29 +0000
commit3f98fd98f1cff6aa30fddf33a4db91e4dc3d86af (patch)
tree81029562515c79ac858e05e281ee2071e7af8fae
parentc2b751fae48c117978396cab4e4a017b626f6a02 (diff)
downloadchromium_src-3f98fd98f1cff6aa30fddf33a4db91e4dc3d86af.zip
chromium_src-3f98fd98f1cff6aa30fddf33a4db91e4dc3d86af.tar.gz
chromium_src-3f98fd98f1cff6aa30fddf33a4db91e4dc3d86af.tar.bz2
[Sync] Have MergeDataAndStartSyncing return a SyncMergeResult
This will allow us to track merge statistics for datatypes. For now none of the datatypes fill the SyncMergeResult with anything other than an error. BUG=158576 TBR=stevet@chromium.org Review URL: https://chromiumcodereview.appspot.com/11365241 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168446 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/app_notification_manager.cc19
-rw-r--r--chrome/browser/extensions/app_notification_manager.h2
-rw-r--r--chrome/browser/extensions/app_notification_manager_sync_unittest.cc4
-rw-r--r--chrome/browser/extensions/extension_service.cc4
-rw-r--r--chrome/browser/extensions/extension_service.h2
-rw-r--r--chrome/browser/extensions/settings/settings_apitest.cc2
-rw-r--r--chrome/browser/extensions/settings/settings_backend.cc4
-rw-r--r--chrome/browser/extensions/settings/settings_backend.h2
-rw-r--r--chrome/browser/extensions/test_extension_service.cc4
-rw-r--r--chrome/browser/extensions/test_extension_service.h2
-rw-r--r--chrome/browser/history/history.cc4
-rw-r--r--chrome/browser/history/history.h2
-rw-r--r--chrome/browser/prefs/pref_model_associator.cc14
-rw-r--r--chrome/browser/prefs/pref_model_associator.h2
-rw-r--r--chrome/browser/search_engines/template_url_service.cc13
-rw-r--r--chrome/browser/search_engines/template_url_service.h2
-rw-r--r--chrome/browser/search_engines/template_url_service_sync_unittest.cc38
-rw-r--r--chrome/browser/sync/glue/new_non_frontend_data_type_controller.cc5
-rw-r--r--chrome/browser/sync/glue/ui_data_type_controller.cc12
-rw-r--r--chrome/browser/themes/theme_syncable_service.cc9
-rw-r--r--chrome/browser/themes/theme_syncable_service.h2
-rw-r--r--chrome/browser/themes/theme_syncable_service_unittest.cc33
-rw-r--r--chrome/browser/webdata/autocomplete_syncable_service.cc20
-rw-r--r--chrome/browser/webdata/autocomplete_syncable_service.h2
-rw-r--r--chrome/browser/webdata/autofill_profile_syncable_service.cc23
-rw-r--r--chrome/browser/webdata/autofill_profile_syncable_service.h2
-rw-r--r--sync/api/fake_syncable_service.cc7
-rw-r--r--sync/api/fake_syncable_service.h2
-rw-r--r--sync/api/sync_merge_result.cc2
-rw-r--r--sync/api/sync_merge_result.h3
-rw-r--r--sync/api/syncable_service.h9
31 files changed, 143 insertions, 108 deletions
diff --git a/chrome/browser/extensions/app_notification_manager.cc b/chrome/browser/extensions/app_notification_manager.cc
index 2dbaaf4..2d8cfcf 100644
--- a/chrome/browser/extensions/app_notification_manager.cc
+++ b/chrome/browser/extensions/app_notification_manager.cc
@@ -285,12 +285,13 @@ syncer::SyncError AppNotificationManager::ProcessSyncChanges(
return error;
}
-syncer::SyncError AppNotificationManager::MergeDataAndStartSyncing(
+syncer::SyncMergeResult AppNotificationManager::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ syncer::SyncMergeResult merge_result(type);
// AppNotificationDataTypeController ensures that modei is fully should before
// this method is called by waiting until the load notification is received
// from AppNotificationManager.
@@ -324,10 +325,11 @@ syncer::SyncError AppNotificationManager::MergeDataAndStartSyncing(
// Local notification should always match with sync notification as
// notifications are immutable.
if (local_notif->is_local() || !sync_notif->Equals(*local_notif)) {
- return sync_error_factory_->CreateAndUploadError(
+ merge_result.set_error(sync_error_factory_->CreateAndUploadError(
FROM_HERE,
"MergeDataAndStartSyncing failed: local notification and sync "
- "notification have same guid but different data.");
+ "notification have same guid but different data."));
+ return merge_result;
}
} else {
// Sync model has a notification that local model does not, add it.
@@ -345,11 +347,12 @@ syncer::SyncError AppNotificationManager::MergeDataAndStartSyncing(
iter->second));
}
- syncer::SyncError error;
- if (new_changes.size() > 0)
- error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
- models_associated_ = !error.IsSet();
- return error;
+ if (new_changes.size() > 0) {
+ merge_result.set_error(
+ sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
+ }
+ models_associated_ = !merge_result.error().IsSet();
+ return merge_result;
}
void AppNotificationManager::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/extensions/app_notification_manager.h b/chrome/browser/extensions/app_notification_manager.h
index 71a1ba0..405b349 100644
--- a/chrome/browser/extensions/app_notification_manager.h
+++ b/chrome/browser/extensions/app_notification_manager.h
@@ -76,7 +76,7 @@ class AppNotificationManager
const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) OVERRIDE;
// Associate and merge sync data model with our data model.
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/extensions/app_notification_manager_sync_unittest.cc b/chrome/browser/extensions/app_notification_manager_sync_unittest.cc
index b761c58..f1e79f1 100644
--- a/chrome/browser/extensions/app_notification_manager_sync_unittest.cc
+++ b/chrome/browser/extensions/app_notification_manager_sync_unittest.cc
@@ -479,7 +479,7 @@ TEST_F(AppNotificationManagerSyncTest, ModelAssocBothNonEmptyTitleMismatch) {
syncer::APP_NOTIFICATIONS,
initial_data,
PassProcessor(),
- error_handler.PassAs<syncer::SyncErrorFactory>());
+ error_handler.PassAs<syncer::SyncErrorFactory>()).error();
EXPECT_TRUE(sync_error.IsSet());
EXPECT_EQ(syncer::APP_NOTIFICATIONS, sync_error.type());
@@ -512,7 +512,7 @@ TEST_F(AppNotificationManagerSyncTest, ModelAssocBothNonEmptyMatchesLocal) {
syncer::APP_NOTIFICATIONS,
initial_data,
PassProcessor(),
- error_handler.PassAs<syncer::SyncErrorFactory>());
+ error_handler.PassAs<syncer::SyncErrorFactory>()).error();
EXPECT_TRUE(sync_error.IsSet());
EXPECT_EQ(syncer::APP_NOTIFICATIONS, sync_error.type());
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 503dd2e..872a9ee 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -1287,7 +1287,7 @@ void ExtensionService::CheckForUpdatesSoon() {
}
}
-syncer::SyncError ExtensionService::MergeDataAndStartSyncing(
+syncer::SyncMergeResult ExtensionService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -1340,7 +1340,7 @@ syncer::SyncError ExtensionService::MergeDataAndStartSyncing(
app_sync_bundle_.ProcessSyncChangeList(sync_change_list);
}
- return syncer::SyncError();
+ return syncer::SyncMergeResult(type);
}
void ExtensionService::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 7fa2eb1..4f8d737 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -461,7 +461,7 @@ class ExtensionService
virtual void CheckForUpdatesSoon() OVERRIDE;
// syncer::SyncableService implementation.
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/extensions/settings/settings_apitest.cc b/chrome/browser/extensions/settings/settings_apitest.cc
index cbcbca8..2232e8b 100644
--- a/chrome/browser/extensions/settings/settings_apitest.cc
+++ b/chrome/browser/extensions/settings/settings_apitest.cc
@@ -207,7 +207,7 @@ class ExtensionSettingsApiTest : public ExtensionApiTest {
scoped_ptr<syncer::SyncChangeProcessor>(
new SyncChangeProcessorDelegate(sync_processor)),
scoped_ptr<syncer::SyncErrorFactory>(
- new syncer::SyncErrorFactoryMock())).IsSet());
+ new syncer::SyncErrorFactoryMock())).error().IsSet());
}
void SendChangesToSyncableService(
diff --git a/chrome/browser/extensions/settings/settings_backend.cc b/chrome/browser/extensions/settings/settings_backend.cc
index 988a564..37b635bf 100644
--- a/chrome/browser/extensions/settings/settings_backend.cc
+++ b/chrome/browser/extensions/settings/settings_backend.cc
@@ -168,7 +168,7 @@ syncer::SyncDataList SettingsBackend::GetAllSyncData(
return all_sync_data;
}
-syncer::SyncError SettingsBackend::MergeDataAndStartSyncing(
+syncer::SyncMergeResult SettingsBackend::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -231,7 +231,7 @@ syncer::SyncError SettingsBackend::MergeDataAndStartSyncing(
GetOrCreateStorageWithSyncData(it->first, *it->second);
}
- return syncer::SyncError();
+ return syncer::SyncMergeResult(type);
}
syncer::SyncError SettingsBackend::ProcessSyncChanges(
diff --git a/chrome/browser/extensions/settings/settings_backend.h b/chrome/browser/extensions/settings/settings_backend.h
index 95c6428..3a3bab5 100644
--- a/chrome/browser/extensions/settings/settings_backend.h
+++ b/chrome/browser/extensions/settings/settings_backend.h
@@ -50,7 +50,7 @@ class SettingsBackend : public syncer::SyncableService {
// syncer::SyncableService implementation.
virtual syncer::SyncDataList GetAllSyncData(
syncer::ModelType type) const OVERRIDE;
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/extensions/test_extension_service.cc b/chrome/browser/extensions/test_extension_service.cc
index 8ab1122..8dfedfb 100644
--- a/chrome/browser/extensions/test_extension_service.cc
+++ b/chrome/browser/extensions/test_extension_service.cc
@@ -79,13 +79,13 @@ void TestExtensionService::CheckForUpdatesSoon() {
ADD_FAILURE();
}
-syncer::SyncError TestExtensionService::MergeDataAndStartSyncing(
+syncer::SyncMergeResult TestExtensionService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) {
ADD_FAILURE();
- return syncer::SyncError();
+ return syncer::SyncMergeResult(type);
}
void TestExtensionService::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/extensions/test_extension_service.h b/chrome/browser/extensions/test_extension_service.h
index d4dbb87..0121dab 100644
--- a/chrome/browser/extensions/test_extension_service.h
+++ b/chrome/browser/extensions/test_extension_service.h
@@ -52,7 +52,7 @@ class TestExtensionService : public ExtensionServiceInterface {
virtual void CheckManagementPolicy() OVERRIDE;
virtual void CheckForUpdatesSoon() OVERRIDE;
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 3591e5c..01a0a57 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -915,7 +915,7 @@ base::WeakPtr<HistoryService> HistoryService::AsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
-syncer::SyncError HistoryService::MergeDataAndStartSyncing(
+syncer::SyncMergeResult HistoryService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -927,7 +927,7 @@ syncer::SyncError HistoryService::MergeDataAndStartSyncing(
DCHECK_EQ(it->GetDataType(), syncer::HISTORY_DELETE_DIRECTIVES);
ProcessDeleteDirective(it->GetSpecifics().history_delete_directive());
}
- return syncer::SyncError();
+ return syncer::SyncMergeResult(type);
}
void HistoryService::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 6c5cf34..494f19a 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -633,7 +633,7 @@ class HistoryService : public CancelableRequestProvider,
base::WeakPtr<HistoryService> AsWeakPtr();
// syncer::SyncableService implementation.
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/prefs/pref_model_associator.cc b/chrome/browser/prefs/pref_model_associator.cc
index 894f607..0b3c119 100644
--- a/chrome/browser/prefs/pref_model_associator.cc
+++ b/chrome/browser/prefs/pref_model_associator.cc
@@ -110,7 +110,7 @@ void PrefModelAssociator::InitPrefAndAssociate(
return;
}
-syncer::SyncError PrefModelAssociator::MergeDataAndStartSyncing(
+syncer::SyncMergeResult PrefModelAssociator::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -121,6 +121,7 @@ syncer::SyncError PrefModelAssociator::MergeDataAndStartSyncing(
DCHECK(!sync_processor_.get());
DCHECK(sync_processor.get());
DCHECK(sync_error_factory.get());
+ syncer::SyncMergeResult merge_result(type);
sync_processor_ = sync_processor.Pass();
sync_error_factory_ = sync_error_factory.Pass();
@@ -157,15 +158,14 @@ syncer::SyncError PrefModelAssociator::MergeDataAndStartSyncing(
}
// Push updates to sync.
- syncer::SyncError error =
- sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
- if (error.IsSet()) {
- return error;
- }
+ merge_result.set_error(
+ sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
+ if (merge_result.error().IsSet())
+ return merge_result;
models_associated_ = true;
pref_service_->OnIsSyncingChanged();
- return syncer::SyncError();
+ return merge_result;
}
void PrefModelAssociator::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/prefs/pref_model_associator.h b/chrome/browser/prefs/pref_model_associator.h
index a5cfbdd..aaeeded 100644
--- a/chrome/browser/prefs/pref_model_associator.h
+++ b/chrome/browser/prefs/pref_model_associator.h
@@ -43,7 +43,7 @@ class PrefModelAssociator
virtual syncer::SyncError ProcessSyncChanges(
const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) OVERRIDE;
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index 381811a..e10e5b8 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -1110,7 +1110,7 @@ syncer::SyncError TemplateURLService::ProcessSyncChanges(
return error;
}
-syncer::SyncError TemplateURLService::MergeDataAndStartSyncing(
+syncer::SyncMergeResult TemplateURLService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -1120,6 +1120,7 @@ syncer::SyncError TemplateURLService::MergeDataAndStartSyncing(
DCHECK(!sync_processor_.get());
DCHECK(sync_processor.get());
DCHECK(sync_error_factory.get());
+ syncer::SyncMergeResult merge_result(type);
sync_processor_ = sync_processor.Pass();
sync_error_factory_ = sync_error_factory.Pass();
@@ -1233,17 +1234,17 @@ syncer::SyncError TemplateURLService::MergeDataAndStartSyncing(
LogDuplicatesHistogram(GetTemplateURLs());
- syncer::SyncError error =
- sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
- if (error.IsSet())
- return error;
+ merge_result.set_error(
+ sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
+ if (merge_result.error().IsSet())
+ return merge_result;
// The ACTION_DELETEs from this set are processed. Empty it so we don't try to
// reuse them on the next call to MergeDataAndStartSyncing.
pre_sync_deletes_.clear();
models_associated_ = true;
- return syncer::SyncError();
+ return merge_result;
}
void TemplateURLService::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/search_engines/template_url_service.h b/chrome/browser/search_engines/template_url_service.h
index 510f11c..eea98e3 100644
--- a/chrome/browser/search_engines/template_url_service.h
+++ b/chrome/browser/search_engines/template_url_service.h
@@ -286,7 +286,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// Merge initial search engine data from Sync and push any local changes up
// to Sync. This may send notifications if local search engines are added,
// updated or removed.
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
index 5ba4974..223cda6 100644
--- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
@@ -1276,9 +1276,11 @@ TEST_F(TemplateURLServiceSyncTest, MergeTwoClientsDupesAndConflicts) {
TEST_F(TemplateURLServiceSyncTest, StopSyncing) {
syncer::SyncError error =
- model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
- CreateInitialSyncData(), PassProcessor(),
- CreateAndPassSyncErrorFactory());
+ model()->MergeDataAndStartSyncing(
+ syncer::SEARCH_ENGINES,
+ CreateInitialSyncData(),
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory()).error();
ASSERT_FALSE(error.IsSet());
model()->StopSyncing(syncer::SEARCH_ENGINES);
@@ -1297,9 +1299,11 @@ TEST_F(TemplateURLServiceSyncTest, StopSyncing) {
TEST_F(TemplateURLServiceSyncTest, SyncErrorOnInitialSync) {
processor()->set_erroneous(true);
syncer::SyncError error =
- model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
- CreateInitialSyncData(), PassProcessor(),
- CreateAndPassSyncErrorFactory());
+ model()->MergeDataAndStartSyncing(
+ syncer::SEARCH_ENGINES,
+ CreateInitialSyncData(),
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory()).error();
EXPECT_TRUE(error.IsSet());
// Ensure that if the initial merge was erroneous, then subsequence attempts
@@ -1322,9 +1326,11 @@ TEST_F(TemplateURLServiceSyncTest, SyncErrorOnLaterSync) {
// Ensure that if the SyncProcessor succeeds in the initial merge, but fails
// in future ProcessSyncChanges, we still return an error.
syncer::SyncError error =
- model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
- CreateInitialSyncData(), PassProcessor(),
- CreateAndPassSyncErrorFactory());
+ model()->MergeDataAndStartSyncing(
+ syncer::SEARCH_ENGINES,
+ CreateInitialSyncData(),
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory()).error();
ASSERT_FALSE(error.IsSet());
syncer::SyncChangeList changes;
@@ -1346,8 +1352,11 @@ TEST_F(TemplateURLServiceSyncTest, MergeTwiceWithSameSyncData) {
"key1", 10)); // earlier
syncer::SyncError error =
- model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
- initial_data, PassProcessor(), CreateAndPassSyncErrorFactory());
+ model()->MergeDataAndStartSyncing(
+ syncer::SEARCH_ENGINES,
+ initial_data,
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory()).error();
ASSERT_FALSE(error.IsSet());
// We should have updated the original TemplateURL with Sync's version.
@@ -1373,8 +1382,11 @@ TEST_F(TemplateURLServiceSyncTest, MergeTwiceWithSameSyncData) {
model()->StopSyncing(syncer::SEARCH_ENGINES);
sync_processor_delegate_.reset(new SyncChangeProcessorDelegate(
sync_processor_.get()));
- error = model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
- initial_data, PassProcessor(), CreateAndPassSyncErrorFactory());
+ error = model()->MergeDataAndStartSyncing(
+ syncer::SEARCH_ENGINES,
+ initial_data,
+ PassProcessor(),
+ CreateAndPassSyncErrorFactory()).error();
ASSERT_FALSE(error.IsSet());
// Check that the TemplateURL was not modified.
diff --git a/chrome/browser/sync/glue/new_non_frontend_data_type_controller.cc b/chrome/browser/sync/glue/new_non_frontend_data_type_controller.cc
index f510c99..f352b79 100644
--- a/chrome/browser/sync/glue/new_non_frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/new_non_frontend_data_type_controller.cc
@@ -285,7 +285,7 @@ void NewNonFrontendDataTypeController::
// TODO(zea): Call shared_change_processor_->GetAllSyncData(..) before
// and after MergeDataAndStartSyncing and store the item counts into
// syncer_merge_result.
- error =
+ local_merge_result =
local_service_->MergeDataAndStartSyncing(
type(),
initial_sync_data,
@@ -294,8 +294,7 @@ void NewNonFrontendDataTypeController::
scoped_ptr<syncer::SyncErrorFactory>(
new SharedChangeProcessorRef(shared_change_processor)));
RecordAssociationTime(base::TimeTicks::Now() - start_time);
- if (error.IsSet()) {
- local_merge_result.set_error(error);
+ if (local_merge_result.error().IsSet()) {
StartDone(ASSOCIATION_FAILED,
local_merge_result,
syncer_merge_result);
diff --git a/chrome/browser/sync/glue/ui_data_type_controller.cc b/chrome/browser/sync/glue/ui_data_type_controller.cc
index 51fbf2d..797e4a4 100644
--- a/chrome/browser/sync/glue/ui_data_type_controller.cc
+++ b/chrome/browser/sync/glue/ui_data_type_controller.cc
@@ -170,12 +170,8 @@ void UIDataTypeController::Associate() {
}
// Passes a reference to |shared_change_processor_|.
- // TODO(zea): have SyncableService return a SyncMergeResult and pass that on
- // to the ModelAssociationManager.
- // TODO(zea): Call shared_change_processor_->GetAllSyncData(..) before
- // and after MergeDataAndStartSyncing and store the item counts into
- // syncer_merge_result.
- error = local_service_->MergeDataAndStartSyncing(
+ syncer_merge_result.set_num_items_after_association(initial_sync_data.size());
+ local_merge_result = local_service_->MergeDataAndStartSyncing(
type(),
initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor>(
@@ -183,8 +179,8 @@ void UIDataTypeController::Associate() {
scoped_ptr<syncer::SyncErrorFactory>(
new SharedChangeProcessorRef(shared_change_processor_)));
RecordAssociationTime(base::TimeTicks::Now() - start_time);
- if (error.IsSet()) {
- local_merge_result.set_error(error);
+
+ if (local_merge_result.error().IsSet()) {
StartDone(ASSOCIATION_FAILED,
local_merge_result,
syncer_merge_result);
diff --git a/chrome/browser/themes/theme_syncable_service.cc b/chrome/browser/themes/theme_syncable_service.cc
index 063347e..5b969d2 100644
--- a/chrome/browser/themes/theme_syncable_service.cc
+++ b/chrome/browser/themes/theme_syncable_service.cc
@@ -56,7 +56,7 @@ void ThemeSyncableService::OnThemeChange() {
}
}
-syncer::SyncError ThemeSyncableService::MergeDataAndStartSyncing(
+syncer::SyncMergeResult ThemeSyncableService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -66,6 +66,7 @@ syncer::SyncError ThemeSyncableService::MergeDataAndStartSyncing(
DCHECK(sync_processor.get());
DCHECK(error_handler.get());
+ syncer::SyncMergeResult merge_result(type);
sync_processor_ = sync_processor.Pass();
sync_error_handler_ = error_handler.Pass();
@@ -86,12 +87,14 @@ syncer::SyncError ThemeSyncableService::MergeDataAndStartSyncing(
++sync_data) {
if (sync_data->GetSpecifics().has_theme()) {
MaybeSetTheme(current_specifics, *sync_data);
- return syncer::SyncError();
+ return merge_result;
}
}
// No theme specifics are found. Create one according to current theme.
- return ProcessNewTheme(syncer::SyncChange::ACTION_ADD, current_specifics);
+ merge_result.set_error(ProcessNewTheme(
+ syncer::SyncChange::ACTION_ADD, current_specifics));
+ return merge_result;
}
void ThemeSyncableService::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/themes/theme_syncable_service.h b/chrome/browser/themes/theme_syncable_service.h
index 0ce64c0..408fd0e 100644
--- a/chrome/browser/themes/theme_syncable_service.h
+++ b/chrome/browser/themes/theme_syncable_service.h
@@ -33,7 +33,7 @@ class ThemeSyncableService : public syncer::SyncableService {
void OnThemeChange();
// syncer::SyncableService implementation.
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/themes/theme_syncable_service_unittest.cc b/chrome/browser/themes/theme_syncable_service_unittest.cc
index e7f9a2d..e82369a 100644
--- a/chrome/browser/themes/theme_syncable_service_unittest.cc
+++ b/chrome/browser/themes/theme_syncable_service_unittest.cc
@@ -277,7 +277,8 @@ TEST_F(ThemeSyncableServiceTest, SetCurrentThemeDefaultTheme) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(sync_pb::ThemeSpecifics()),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
EXPECT_TRUE(fake_theme_service_->UsingDefaultTheme());
}
@@ -291,7 +292,8 @@ TEST_F(ThemeSyncableServiceTest, SetCurrentThemeSystemTheme) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(theme_specifics),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
EXPECT_TRUE(fake_theme_service_->UsingNativeTheme());
}
@@ -308,7 +310,8 @@ TEST_F(ThemeSyncableServiceTest, SetCurrentThemeCustomTheme) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(theme_specifics),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
EXPECT_EQ(fake_theme_service_->theme_extension(), theme_extension_.get());
}
@@ -320,7 +323,8 @@ TEST_F(ThemeSyncableServiceTest, DontResetThemeWhenSpecificsAreEqual) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(sync_pb::ThemeSpecifics()),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
EXPECT_FALSE(fake_theme_service_->is_dirty());
}
@@ -335,7 +339,8 @@ TEST_F(ThemeSyncableServiceTest, UpdateThemeSpecificsFromCurrentTheme) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, syncer::SyncDataList(), fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
ASSERT_EQ(1u, change_list.size());
@@ -378,7 +383,8 @@ TEST_F(ThemeSyncableServiceTest, ProcessSyncThemeChange) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(sync_pb::ThemeSpecifics()),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
// Don't expect theme change initially because specifics are equal.
EXPECT_FALSE(fake_theme_service_->is_dirty());
@@ -413,7 +419,8 @@ TEST_F(ThemeSyncableServiceTest, OnThemeChangeByUser) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(sync_pb::ThemeSpecifics()),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
EXPECT_EQ(0u, change_list.size());
@@ -442,7 +449,8 @@ TEST_F(ThemeSyncableServiceTest, StopSync) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(sync_pb::ThemeSpecifics()),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(error.IsSet()) << error.message();
EXPECT_EQ(0u, change_list.size());
@@ -475,7 +483,8 @@ TEST_F(ThemeSyncableServiceTest, RestoreSystemThemeBitWhenChangeToCustomTheme) {
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(theme_specifics),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
// Change to custom theme and notify theme_sync_service_.
// use_system_theme_by_default bit should be preserved.
@@ -502,7 +511,8 @@ TEST_F(ThemeSyncableServiceTest,
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(theme_specifics),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_FALSE(fake_theme_service_->is_dirty());
// Change to default theme and notify theme_sync_service_.
@@ -544,7 +554,8 @@ TEST_F(ThemeSyncableServiceTest,
syncer::SyncError error = theme_sync_service_->MergeDataAndStartSyncing(
syncer::THEMES, MakeThemeDataList(theme_specifics),
fake_change_processor_.Pass(),
- scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
+ scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())).
+ error();
EXPECT_EQ(fake_theme_service_->theme_extension(), theme_extension_.get());
// Change to default theme and notify theme_sync_service_.
diff --git a/chrome/browser/webdata/autocomplete_syncable_service.cc b/chrome/browser/webdata/autocomplete_syncable_service.cc
index 451ebfe..b583be1 100644
--- a/chrome/browser/webdata/autocomplete_syncable_service.cc
+++ b/chrome/browser/webdata/autocomplete_syncable_service.cc
@@ -115,7 +115,7 @@ AutocompleteSyncableService::AutocompleteSyncableService()
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
}
-syncer::SyncError AutocompleteSyncableService::MergeDataAndStartSyncing(
+syncer::SyncMergeResult AutocompleteSyncableService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -126,12 +126,14 @@ syncer::SyncError AutocompleteSyncableService::MergeDataAndStartSyncing(
DCHECK(error_handler.get());
VLOG(1) << "Associating Autocomplete: MergeDataAndStartSyncing";
+ syncer::SyncMergeResult merge_result(type);
error_handler_ = error_handler.Pass();
std::vector<AutofillEntry> entries;
if (!LoadAutofillData(&entries)) {
- return error_handler_->CreateAndUploadError(
+ merge_result.set_error(error_handler_->CreateAndUploadError(
FROM_HERE,
- "Could not get the autocomplete data from WebDatabase.");
+ "Could not get the autocomplete data from WebDatabase."));
+ return merge_result;
}
AutocompleteEntryMap new_db_entries;
@@ -154,9 +156,10 @@ syncer::SyncError AutocompleteSyncableService::MergeDataAndStartSyncing(
}
if (!SaveChangesToWebData(new_synced_entries)) {
- return error_handler_->CreateAndUploadError(
+ merge_result.set_error(error_handler_->CreateAndUploadError(
FROM_HERE,
- "Failed to update webdata.");
+ "Failed to update webdata."));
+ return merge_result;
}
WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_);
@@ -176,10 +179,9 @@ syncer::SyncError AutocompleteSyncableService::MergeDataAndStartSyncing(
web_data_service_->RemoveExpiredFormElements();
}
- syncer::SyncError error =
- sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
-
- return error;
+ merge_result.set_error(
+ sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
+ return merge_result;
}
void AutocompleteSyncableService::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/webdata/autocomplete_syncable_service.h b/chrome/browser/webdata/autocomplete_syncable_service.h
index caa3439..e543955 100644
--- a/chrome/browser/webdata/autocomplete_syncable_service.h
+++ b/chrome/browser/webdata/autocomplete_syncable_service.h
@@ -50,7 +50,7 @@ class AutocompleteSyncableService
static syncer::ModelType model_type() { return syncer::AUTOFILL; }
// syncer::SyncableService implementation.
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.cc b/chrome/browser/webdata/autofill_profile_syncable_service.cc
index 334edf4..e2c8e9d 100644
--- a/chrome/browser/webdata/autofill_profile_syncable_service.cc
+++ b/chrome/browser/webdata/autofill_profile_syncable_service.cc
@@ -57,7 +57,8 @@ AutofillProfileSyncableService::AutofillProfileSyncableService()
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
}
-syncer::SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing(
+syncer::SyncMergeResult
+AutofillProfileSyncableService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -68,10 +69,12 @@ syncer::SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing(
DCHECK(sync_error_factory.get());
DVLOG(1) << "Associating Autofill: MergeDataAndStartSyncing";
+ syncer::SyncMergeResult merge_result(type);
sync_error_factory_ = sync_error_factory.Pass();
if (!LoadAutofillData(&profiles_.get())) {
- return sync_error_factory_->CreateAndUploadError(
- FROM_HERE, "Could not get the autofill data from WebDatabase.");
+ merge_result.set_error(sync_error_factory_->CreateAndUploadError(
+ FROM_HERE, "Could not get the autofill data from WebDatabase."));
+ return merge_result;
}
if (DLOG_IS_ON(INFO)) {
@@ -131,9 +134,10 @@ syncer::SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing(
}
if (!SaveChangesToWebData(bundle)) {
- return sync_error_factory_->CreateAndUploadError(
+ merge_result.set_error(sync_error_factory_->CreateAndUploadError(
FROM_HERE,
- "Failed to update webdata.");
+ "Failed to update webdata."));
+ return merge_result;
}
syncer::SyncChangeList new_changes;
@@ -153,13 +157,14 @@ syncer::SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing(
CreateData(*(bundle.profiles_to_sync_back[i]))));
}
- syncer::SyncError error;
- if (!new_changes.empty())
- error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
+ if (!new_changes.empty()) {
+ merge_result.set_error(
+ sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
+ }
WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_);
- return error;
+ return merge_result;
}
void AutofillProfileSyncableService::StopSyncing(syncer::ModelType type) {
diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.h b/chrome/browser/webdata/autofill_profile_syncable_service.h
index 10af923..44c88cf 100644
--- a/chrome/browser/webdata/autofill_profile_syncable_service.h
+++ b/chrome/browser/webdata/autofill_profile_syncable_service.h
@@ -47,7 +47,7 @@ class AutofillProfileSyncableService
static syncer::ModelType model_type() { return syncer::AUTOFILL_PROFILE; }
// syncer::SyncableService implementation.
- virtual syncer::SyncError MergeDataAndStartSyncing(
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
diff --git a/sync/api/fake_syncable_service.cc b/sync/api/fake_syncable_service.cc
index 731b24d..0d76f2e 100644
--- a/sync/api/fake_syncable_service.cc
+++ b/sync/api/fake_syncable_service.cc
@@ -30,17 +30,20 @@ bool FakeSyncableService::syncing() const {
}
// SyncableService implementation.
-SyncError FakeSyncableService::MergeDataAndStartSyncing(
+SyncMergeResult FakeSyncableService::MergeDataAndStartSyncing(
ModelType type,
const SyncDataList& initial_sync_data,
scoped_ptr<SyncChangeProcessor> sync_processor,
scoped_ptr<SyncErrorFactory> sync_error_factory) {
+ SyncMergeResult merge_result(type);
sync_processor_ = sync_processor.Pass();
type_ = type;
if (!merge_data_and_start_syncing_error_.IsSet()) {
syncing_ = true;
+ } else {
+ merge_result.set_error(merge_data_and_start_syncing_error_);
}
- return merge_data_and_start_syncing_error_;
+ return merge_result;
}
void FakeSyncableService::StopSyncing(ModelType type) {
diff --git a/sync/api/fake_syncable_service.h b/sync/api/fake_syncable_service.h
index 5a501ae..3d77a80 100644
--- a/sync/api/fake_syncable_service.h
+++ b/sync/api/fake_syncable_service.h
@@ -27,7 +27,7 @@ class FakeSyncableService : public SyncableService {
bool syncing() const;
// SyncableService implementation.
- virtual SyncError MergeDataAndStartSyncing(
+ virtual SyncMergeResult MergeDataAndStartSyncing(
ModelType type,
const SyncDataList& initial_sync_data,
scoped_ptr<SyncChangeProcessor> sync_processor,
diff --git a/sync/api/sync_merge_result.cc b/sync/api/sync_merge_result.cc
index c2253b3..0caf57b 100644
--- a/sync/api/sync_merge_result.cc
+++ b/sync/api/sync_merge_result.cc
@@ -20,7 +20,7 @@ SyncMergeResult::~SyncMergeResult() {
// Setters.
void SyncMergeResult::set_error(SyncError error) {
- DCHECK_EQ(model_type_, error.type());
+ DCHECK(!error.IsSet() || model_type_ == error.type());
error_ = error;
}
diff --git a/sync/api/sync_merge_result.h b/sync/api/sync_merge_result.h
index 41accfd..baa4eb4 100644
--- a/sync/api/sync_merge_result.h
+++ b/sync/api/sync_merge_result.h
@@ -26,8 +26,7 @@ class SyncMergeResult {
// Default copy and assign welcome.
// Setters.
- // Note: |error.IsSet()| must be true, and |error.type()| must match
- // model_type_
+ // Note: if |error.IsSet()| is true, |error.type()| must match model_type_
void set_error(SyncError error);
void set_num_items_before_association(int num_items_before_association);
void set_num_items_after_association(int num_items_after_association);
diff --git a/sync/api/syncable_service.h b/sync/api/syncable_service.h
index 5f84d85..571c2e7 100644
--- a/sync/api/syncable_service.h
+++ b/sync/api/syncable_service.h
@@ -13,6 +13,7 @@
#include "sync/api/sync_change_processor.h"
#include "sync/api/sync_data.h"
#include "sync/api/sync_error.h"
+#include "sync/api/sync_merge_result.h"
#include "sync/internal_api/public/base/model_type.h"
namespace syncer {
@@ -33,10 +34,10 @@ class SyncableService : public SyncChangeProcessor,
// two. After this, the SyncableService's local data should match the server
// data, and the service should be ready to receive and process any further
// SyncChange's as they occur.
- // Returns: A default SyncError (IsSet() == false) if no errors were
- // encountered, and a filled SyncError (IsSet() == true)
- // otherwise.
- virtual SyncError MergeDataAndStartSyncing(
+ // Returns: a SyncMergeResult whose error field reflects whether an error
+ // was encountered while merging the two models. The merge result
+ // may also contain optional merge statistics.
+ virtual SyncMergeResult MergeDataAndStartSyncing(
ModelType type,
const SyncDataList& initial_sync_data,
scoped_ptr<SyncChangeProcessor> sync_processor,