summaryrefslogtreecommitdiff
path: root/chrome/browser/sync/glue
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-08-19 13:00:08 +0100
committerTorne (Richard Coles) <torne@google.com>2014-08-19 13:00:08 +0100
commit6e8cce623b6e4fe0c9e4af605d675dd9d0338c38 (patch)
tree8d824ad26fac42e008142b86aa9631b2be7e4705 /chrome/browser/sync/glue
parent4f7316adb45db5ec3c9c1181ba9510c004566df8 (diff)
downloadchromium_org-6e8cce623b6e4fe0c9e4af605d675dd9d0338c38.tar.gz
Merge from Chromium at DEPS revision 290040
This commit was generated by merge_to_master.py. Change-Id: I694ec52d1e0b553f163c2faf4373d63270ab1aac
Diffstat (limited to 'chrome/browser/sync/glue')
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc7
-rw-r--r--chrome/browser/sync/glue/autofill_profile_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/autofill_profile_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/bookmark_change_processor.cc70
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc18
-rw-r--r--chrome/browser/sync/glue/bookmark_model_associator.cc7
-rw-r--r--chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc2
-rw-r--r--chrome/browser/sync/glue/device_info_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/device_info_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/device_info_data_type_controller_unittest.cc3
-rw-r--r--chrome/browser/sync/glue/extension_backed_data_type_controller.cc16
-rw-r--r--chrome/browser/sync/glue/extension_backed_data_type_controller.h1
-rw-r--r--chrome/browser/sync/glue/extension_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/extension_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/extension_setting_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/extension_setting_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/frontend_data_type_controller.cc41
-rw-r--r--chrome/browser/sync/glue/frontend_data_type_controller.h9
-rw-r--r--chrome/browser/sync/glue/frontend_data_type_controller_mock.h6
-rw-r--r--chrome/browser/sync/glue/frontend_data_type_controller_unittest.cc24
-rw-r--r--chrome/browser/sync/glue/non_frontend_data_type_controller.cc54
-rw-r--r--chrome/browser/sync/glue/non_frontend_data_type_controller.h14
-rw-r--r--chrome/browser/sync/glue/non_frontend_data_type_controller_mock.h6
-rw-r--r--chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc17
-rw-r--r--chrome/browser/sync/glue/password_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/password_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/search_engine_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/search_engine_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/search_engine_data_type_controller_unittest.cc3
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_core.cc60
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/typed_url_change_processor.cc76
-rw-r--r--chrome/browser/sync/glue/typed_url_data_type_controller.cc2
36 files changed, 227 insertions, 265 deletions
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.cc b/chrome/browser/sync/glue/autofill_data_type_controller.cc
index 48dec09113..8225b2435e 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.cc
@@ -23,12 +23,10 @@ namespace browser_sync {
AutofillDataTypeController::AutofillDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback)
+ Profile* profile)
: NonUIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
profile_sync_factory),
profile_(profile) {
}
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.h b/chrome/browser/sync/glue/autofill_data_type_controller.h
index 1f4c126fb2..a213d12f6d 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.h
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.h
@@ -27,8 +27,7 @@ class AutofillDataTypeController
public:
AutofillDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback);
+ Profile* profile);
// NonUIDataTypeController implementation.
virtual syncer::ModelType type() const OVERRIDE;
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
index c423c41703..fcdd0e7466 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
@@ -153,12 +153,11 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
autofill_dtc_ =
new AutofillDataTypeController(
- &profile_sync_factory_, &profile_,
- sync_driver::DataTypeController::DisableTypeCallback());
+ &profile_sync_factory_, &profile_);
}
// Passed to AutofillDTC::Start().
- void OnStartFinished(sync_driver::DataTypeController::StartResult result,
+ void OnStartFinished(sync_driver::DataTypeController::ConfigureResult result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
last_start_result_ = result;
@@ -189,7 +188,7 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
scoped_refptr<AutofillDataTypeController> autofill_dtc_;
// Stores arguments of most recent call of OnStartFinished().
- sync_driver::DataTypeController::StartResult last_start_result_;
+ sync_driver::DataTypeController::ConfigureResult last_start_result_;
syncer::SyncError last_start_error_;
base::WeakPtrFactory<SyncAutofillDataTypeControllerTest> weak_ptr_factory_;
};
diff --git a/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc b/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
index f8edcd74a0..990738684d 100644
--- a/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
@@ -24,12 +24,10 @@ namespace browser_sync {
AutofillProfileDataTypeController::AutofillProfileDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback)
+ Profile* profile)
: NonUIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
profile_sync_factory),
profile_(profile),
personal_data_(NULL),
diff --git a/chrome/browser/sync/glue/autofill_profile_data_type_controller.h b/chrome/browser/sync/glue/autofill_profile_data_type_controller.h
index 9b1b4fd81a..9641c67ae2 100644
--- a/chrome/browser/sync/glue/autofill_profile_data_type_controller.h
+++ b/chrome/browser/sync/glue/autofill_profile_data_type_controller.h
@@ -26,8 +26,7 @@ class AutofillProfileDataTypeController
public:
AutofillProfileDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback);
+ Profile* profile);
// NonUIDataTypeController implementation.
virtual syncer::ModelType type() const OVERRIDE;
diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc
index 8e31f924e9..d6c4d6a0d4 100644
--- a/chrome/browser/sync/glue/bookmark_change_processor.cc
+++ b/chrome/browser/sync/glue/bookmark_change_processor.cc
@@ -120,8 +120,11 @@ void BookmarkChangeProcessor::RemoveSyncNodeHierarchy(
syncer::WriteNode topmost_sync_node(&trans);
if (!model_associator_->InitSyncNodeFromChromeId(topmost->id(),
&topmost_sync_node)) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- std::string());
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to init sync node from chrome node",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
// Check that |topmost| has been unlinked.
@@ -163,8 +166,11 @@ void BookmarkChangeProcessor::RemoveAllChildNodes(
syncer::WriteNode topmost_node(trans);
if (!model_associator_->InitSyncNodeFromChromeId(topmost_node_id,
&topmost_node)) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- std::string());
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to init sync node from chrome node",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
const int64 topmost_sync_id = topmost_node.GetId();
@@ -272,8 +278,11 @@ int64 BookmarkChangeProcessor::CreateSyncNode(const BookmarkNode* parent,
// Actually create the node with the appropriate initial position.
if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) {
- error_handler->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Sync node creation failed; recovery unlikely");
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed ot creat sync node.",
+ syncer::BOOKMARKS);
+ error_handler->OnSingleDataTypeUnrecoverableError(error);
return syncer::kInvalidId;
}
@@ -321,8 +330,11 @@ int64 BookmarkChangeProcessor::UpdateSyncNode(
// Lookup the sync node that's associated with |node|.
syncer::WriteNode sync_node(trans);
if (!associator->InitSyncNodeFromChromeId(node->id(), &sync_node)) {
- error_handler->OnSingleDatatypeUnrecoverableError(
- FROM_HERE, "Could not load bookmark node on update.");
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to init sync node from chrome node",
+ syncer::BOOKMARKS);
+ error_handler->OnSingleDataTypeUnrecoverableError(error);
return syncer::kInvalidId;
}
UpdateSyncNodeProperties(node, model, &sync_node);
@@ -356,15 +368,21 @@ void BookmarkChangeProcessor::BookmarkNodeMoved(BookmarkModel* model,
// Lookup the sync node that's associated with |child|.
syncer::WriteNode sync_node(&trans);
if (!model_associator_->InitSyncNodeFromChromeId(child->id(), &sync_node)) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- std::string());
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to init sync node from chrome node",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
if (!PlaceSyncNode(MOVE, new_parent, new_index, &trans, &sync_node,
model_associator_)) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- std::string());
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to place sync node",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
}
@@ -396,8 +414,11 @@ void BookmarkChangeProcessor::BookmarkNodeChildrenReordered(
syncer::WriteNode sync_child(&trans);
if (!model_associator_->InitSyncNodeFromChromeId(child->id(),
&sync_child)) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- std::string());
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to init sync node from chrome node",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
DCHECK_EQ(sync_child.GetParentId(),
@@ -405,8 +426,11 @@ void BookmarkChangeProcessor::BookmarkNodeChildrenReordered(
if (!PlaceSyncNode(MOVE, node, i, &trans, &sync_child,
model_associator_)) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- std::string());
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to place sync node",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
}
@@ -528,8 +552,11 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel(
model->other_node()->child_count(),
base::string16());
if (!foster_parent) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Failed to create foster parent.");
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to create foster parent",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
}
@@ -586,8 +613,11 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel(
syncer::ReadNode src(trans);
if (src.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "ApplyModelChanges was passed a bad ID");
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to load sync node",
+ syncer::BOOKMARKS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
index d8b7ead3c0..3c00de5cf5 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
@@ -335,21 +335,3 @@ TEST_F(SyncBookmarkDataTypeControllerTest, Stop) {
bookmark_dtc_->Stop();
EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
}
-
-TEST_F(SyncBookmarkDataTypeControllerTest, OnSingleDatatypeUnrecoverableError) {
- CreateBookmarkModel(LOAD_MODEL);
- SetStartExpectations();
- SetAssociateExpectations();
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
- WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(service_, DisableDatatype(_)).
- WillOnce(InvokeWithoutArgs(bookmark_dtc_.get(),
- &BookmarkDataTypeController::Stop));
- SetStopExpectations();
-
- EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _, _));
- Start();
- // This should cause bookmark_dtc_->Stop() to be called.
- bookmark_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test");
- base::RunLoop().RunUntilIdle();
-}
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc
index 4ea6b9cbff..c77bf967c7 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.cc
+++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
@@ -730,9 +730,12 @@ void BookmarkModelAssociator::PersistAssociations() {
int64 sync_id = *iter;
syncer::WriteNode sync_node(&trans);
if (sync_node.InitByIdLookup(sync_id) != syncer::BaseNode::INIT_OK) {
- unrecoverable_error_handler_->OnSingleDatatypeUnrecoverableError(
+ syncer::SyncError error(
FROM_HERE,
- "Could not lookup bookmark node for ID persistence.");
+ syncer::SyncError::DATATYPE_ERROR,
+ "Could not lookup bookmark node for ID persistence.",
+ syncer::BOOKMARKS);
+ unrecoverable_error_handler_->OnSingleDataTypeUnrecoverableError(error);
return;
}
const BookmarkNode* node = GetChromeNodeFromSyncId(sync_id);
diff --git a/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc b/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc
index 9c7797bcae..ff0e2b5904 100644
--- a/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc
+++ b/chrome/browser/sync/glue/chrome_report_unrecoverable_error.cc
@@ -20,7 +20,7 @@ void ChromeReportUnrecoverableError() {
}
// We only want to upload |kErrorUploadRatio| ratio of errors.
- const double kErrorUploadRatio = 0.15;
+ const double kErrorUploadRatio = 0.0;
if (kErrorUploadRatio <= 0.0)
return; // We are not allowed to upload errors.
double random_number = base::RandDouble();
diff --git a/chrome/browser/sync/glue/device_info_data_type_controller.cc b/chrome/browser/sync/glue/device_info_data_type_controller.cc
index a8deb06303..81d0fa82f3 100644
--- a/chrome/browser/sync/glue/device_info_data_type_controller.cc
+++ b/chrome/browser/sync/glue/device_info_data_type_controller.cc
@@ -14,12 +14,10 @@ namespace browser_sync {
DeviceInfoDataTypeController::DeviceInfoDataTypeController(
sync_driver::SyncApiComponentFactory* sync_factory,
- LocalDeviceInfoProvider* local_device_info_provider,
- const DisableTypeCallback& disable_callback)
+ LocalDeviceInfoProvider* local_device_info_provider)
: UIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
syncer::DEVICE_INFO,
sync_factory),
local_device_info_provider_(local_device_info_provider) {
diff --git a/chrome/browser/sync/glue/device_info_data_type_controller.h b/chrome/browser/sync/glue/device_info_data_type_controller.h
index 979536fd06..38c7b45f33 100644
--- a/chrome/browser/sync/glue/device_info_data_type_controller.h
+++ b/chrome/browser/sync/glue/device_info_data_type_controller.h
@@ -16,8 +16,7 @@ class DeviceInfoDataTypeController : public sync_driver::UIDataTypeController {
public:
DeviceInfoDataTypeController(
sync_driver::SyncApiComponentFactory* sync_factory,
- LocalDeviceInfoProvider* local_device_info_provider,
- const DisableTypeCallback& disable_callback);
+ LocalDeviceInfoProvider* local_device_info_provider);
private:
virtual ~DeviceInfoDataTypeController();
diff --git a/chrome/browser/sync/glue/device_info_data_type_controller_unittest.cc b/chrome/browser/sync/glue/device_info_data_type_controller_unittest.cc
index 92a94a98f3..0f0a2b9885 100644
--- a/chrome/browser/sync/glue/device_info_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/device_info_data_type_controller_unittest.cc
@@ -38,8 +38,7 @@ class DeviceInfoDataTypeControllerTest : public testing::Test {
controller_ = new DeviceInfoDataTypeController(
&profile_sync_factory_,
- local_device_.get(),
- DataTypeController::DisableTypeCallback());
+ local_device_.get());
load_finished_ = false;
last_type_ = syncer::UNSPECIFIED;
diff --git a/chrome/browser/sync/glue/extension_backed_data_type_controller.cc b/chrome/browser/sync/glue/extension_backed_data_type_controller.cc
index b06f6df0fa..7de4d7e732 100644
--- a/chrome/browser/sync/glue/extension_backed_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_backed_data_type_controller.cc
@@ -30,7 +30,6 @@ std::string IdToHash(const std::string extension_id) {
} // namespace
ExtensionBackedDataTypeController::ExtensionBackedDataTypeController(
- const DisableTypeCallback& disable_callback,
syncer::ModelType type,
const std::string& extension_hash,
sync_driver::SyncApiComponentFactory* sync_factory,
@@ -38,7 +37,6 @@ ExtensionBackedDataTypeController::ExtensionBackedDataTypeController(
: UIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
type,
sync_factory),
extension_hash_(extension_hash),
@@ -75,20 +73,16 @@ void ExtensionBackedDataTypeController::OnExtensionUnloaded(
const extensions::Extension* extension,
extensions::UnloadedExtensionInfo::Reason reason) {
if (DoesExtensionMatch(*extension)) {
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(profile_);
-
// This will trigger purging the datatype from the sync directory. This
// may not always be the right choice, especially in the face of transient
// unloads (e.g. for permission changes). If that becomes a large enough
// issue, we should consider using the extension unload reason to just
// trigger a reconfiguration without disabling (type will be unready).
- syncer::SyncError error(
- FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Extension unloaded",
- type());
- sync_service->DisableDatatype(error);
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_POLICY_ERROR,
+ "Extension unloaded",
+ type());
+ OnSingleDataTypeUnrecoverableError(error);
}
}
diff --git a/chrome/browser/sync/glue/extension_backed_data_type_controller.h b/chrome/browser/sync/glue/extension_backed_data_type_controller.h
index 9d438d299d..d5c6df8bcd 100644
--- a/chrome/browser/sync/glue/extension_backed_data_type_controller.h
+++ b/chrome/browser/sync/glue/extension_backed_data_type_controller.h
@@ -22,7 +22,6 @@ class ExtensionBackedDataTypeController
public extensions::ExtensionRegistryObserver {
public:
ExtensionBackedDataTypeController(
- const DisableTypeCallback& disable_callback,
syncer::ModelType type,
const std::string& extension_hash,
sync_driver::SyncApiComponentFactory* sync_factory,
diff --git a/chrome/browser/sync/glue/extension_data_type_controller.cc b/chrome/browser/sync/glue/extension_data_type_controller.cc
index 7f3e2583ee..cdeead64e5 100644
--- a/chrome/browser/sync/glue/extension_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_data_type_controller.cc
@@ -17,12 +17,10 @@ namespace browser_sync {
ExtensionDataTypeController::ExtensionDataTypeController(
syncer::ModelType type,
sync_driver::SyncApiComponentFactory* sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback)
+ Profile* profile)
: UIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
type,
sync_factory),
profile_(profile) {
diff --git a/chrome/browser/sync/glue/extension_data_type_controller.h b/chrome/browser/sync/glue/extension_data_type_controller.h
index 4cb11139f2..0904d352cc 100644
--- a/chrome/browser/sync/glue/extension_data_type_controller.h
+++ b/chrome/browser/sync/glue/extension_data_type_controller.h
@@ -22,8 +22,7 @@ class ExtensionDataTypeController : public sync_driver::UIDataTypeController {
ExtensionDataTypeController(
syncer::ModelType type, // Either EXTENSIONS or APPS.
sync_driver::SyncApiComponentFactory* sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback);
+ Profile* profile);
private:
virtual ~ExtensionDataTypeController();
diff --git a/chrome/browser/sync/glue/extension_setting_data_type_controller.cc b/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
index dc9e29e98a..9e015d9ae8 100644
--- a/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
@@ -22,12 +22,10 @@ namespace browser_sync {
ExtensionSettingDataTypeController::ExtensionSettingDataTypeController(
syncer::ModelType type,
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback)
+ Profile* profile)
: NonUIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
profile_sync_factory),
type_(type),
profile_(profile) {
diff --git a/chrome/browser/sync/glue/extension_setting_data_type_controller.h b/chrome/browser/sync/glue/extension_setting_data_type_controller.h
index d53e9bff8a..a7215b05cf 100644
--- a/chrome/browser/sync/glue/extension_setting_data_type_controller.h
+++ b/chrome/browser/sync/glue/extension_setting_data_type_controller.h
@@ -30,8 +30,7 @@ class ExtensionSettingDataTypeController
// Either EXTENSION_SETTINGS or APP_SETTINGS.
syncer::ModelType type,
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback);
+ Profile* profile);
// NonFrontendDataTypeController implementation
virtual syncer::ModelType type() const OVERRIDE;
diff --git a/chrome/browser/sync/glue/frontend_data_type_controller.cc b/chrome/browser/sync/glue/frontend_data_type_controller.cc
index 43db0d1ad8..03c592d847 100644
--- a/chrome/browser/sync/glue/frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/frontend_data_type_controller.cc
@@ -30,7 +30,7 @@ FrontendDataTypeController::FrontendDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
Profile* profile,
ProfileSyncService* sync_service)
- : DataTypeController(ui_thread, error_callback, DisableTypeCallback()),
+ : DataTypeController(ui_thread, error_callback),
profile_sync_factory_(profile_sync_factory),
profile_(profile),
sync_service_(sync_service),
@@ -85,7 +85,6 @@ void FrontendDataTypeController::StartAssociating(
const StartCallback& start_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!start_callback.is_null());
- DCHECK(start_callback_.is_null());
DCHECK_EQ(state_, MODEL_LOADED);
start_callback_ = start_callback;
@@ -102,6 +101,9 @@ void FrontendDataTypeController::StartAssociating(
void FrontendDataTypeController::Stop() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (state_ == NOT_RUNNING)
+ return;
+
State prev_state = state_;
state_ = STOPPING;
@@ -113,7 +115,6 @@ void FrontendDataTypeController::Stop() {
// still in MODEL_STARTING.
return;
}
- DCHECK(start_callback_.is_null());
CleanUpState();
@@ -145,17 +146,24 @@ sync_driver::DataTypeController::State FrontendDataTypeController::state()
return state_;
}
-void FrontendDataTypeController::OnSingleDatatypeUnrecoverableError(
- const tracked_objects::Location& from_here, const std::string& message) {
- RecordUnrecoverableError(from_here, message);
- syncer::SyncError error(
- from_here, syncer::SyncError::DATATYPE_ERROR, message, type());
- sync_service_->DisableDatatype(error);
+void FrontendDataTypeController::OnSingleDataTypeUnrecoverableError(
+ const syncer::SyncError& error) {
+ DCHECK_EQ(type(), error.model_type());
+ RecordUnrecoverableError(error.location(), error.message());
+ if (!start_callback_.is_null()) {
+ syncer::SyncMergeResult local_merge_result(type());
+ local_merge_result.set_error(error);
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(start_callback_,
+ RUNTIME_ERROR,
+ local_merge_result,
+ syncer::SyncMergeResult(type())));
+ }
}
FrontendDataTypeController::FrontendDataTypeController()
- : DataTypeController(base::MessageLoopProxy::current(), base::Closure(),
- DisableTypeCallback()),
+ : DataTypeController(base::MessageLoopProxy::current(), base::Closure()),
profile_sync_factory_(NULL),
profile_(NULL),
sync_service_(NULL),
@@ -262,7 +270,7 @@ void FrontendDataTypeController::AbortModelLoad() {
}
void FrontendDataTypeController::StartDone(
- StartResult start_result,
+ ConfigureResult start_result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -279,12 +287,7 @@ void FrontendDataTypeController::StartDone(
RecordStartFailure(start_result);
}
- // We have to release the callback before we call it, since it's possible
- // invoking the callback will trigger a call to STOP(), which will get
- // confused by the non-NULL start_callback_.
- StartCallback callback = start_callback_;
- start_callback_.Reset();
- callback.Run(start_result, local_merge_result, syncer_merge_result);
+ start_callback_.Run(start_result, local_merge_result, syncer_merge_result);
}
void FrontendDataTypeController::RecordAssociationTime(base::TimeDelta time) {
@@ -295,7 +298,7 @@ void FrontendDataTypeController::RecordAssociationTime(base::TimeDelta time) {
#undef PER_DATA_TYPE_MACRO
}
-void FrontendDataTypeController::RecordStartFailure(StartResult result) {
+void FrontendDataTypeController::RecordStartFailure(ConfigureResult result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures",
ModelTypeToHistogramInt(type()),
diff --git a/chrome/browser/sync/glue/frontend_data_type_controller.h b/chrome/browser/sync/glue/frontend_data_type_controller.h
index 4d3a25cae4..dcc24c2a6d 100644
--- a/chrome/browser/sync/glue/frontend_data_type_controller.h
+++ b/chrome/browser/sync/glue/frontend_data_type_controller.h
@@ -62,9 +62,8 @@ class FrontendDataTypeController : public sync_driver::DataTypeController {
virtual State state() const OVERRIDE;
// DataTypeErrorHandler interface.
- virtual void OnSingleDatatypeUnrecoverableError(
- const tracked_objects::Location& from_here,
- const std::string& message) OVERRIDE;
+ virtual void OnSingleDataTypeUnrecoverableError(
+ const syncer::SyncError& error) OVERRIDE;
protected:
friend class FrontendDataTypeControllerMock;
@@ -93,14 +92,14 @@ class FrontendDataTypeController : public sync_driver::DataTypeController {
// Helper method for cleaning up state and running the start callback.
virtual void StartDone(
- StartResult start_result,
+ ConfigureResult start_result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result);
// Record association time.
virtual void RecordAssociationTime(base::TimeDelta time);
// Record causes of start failure.
- virtual void RecordStartFailure(StartResult result);
+ virtual void RecordStartFailure(ConfigureResult result);
virtual sync_driver::AssociatorInterface* model_associator() const;
virtual void set_model_associator(
diff --git a/chrome/browser/sync/glue/frontend_data_type_controller_mock.h b/chrome/browser/sync/glue/frontend_data_type_controller_mock.h
index 6f7434a39a..9ce316437e 100644
--- a/chrome/browser/sync/glue/frontend_data_type_controller_mock.h
+++ b/chrome/browser/sync/glue/frontend_data_type_controller_mock.h
@@ -34,9 +34,9 @@ class FrontendDataTypeControllerMock : public FrontendDataTypeController {
MOCK_METHOD0(StartModels, bool());
MOCK_METHOD0(Associate, bool());
MOCK_METHOD0(CreateSyncComponents, void());
- MOCK_METHOD2(StartFailed, void(StartResult result,
+ MOCK_METHOD2(StartFailed, void(ConfigureResult result,
const syncer::SyncError& error));
- MOCK_METHOD1(FinishStart, void(StartResult result));
+ MOCK_METHOD1(FinishStart, void(ConfigureResult result));
MOCK_METHOD0(CleanUpState, void());
MOCK_CONST_METHOD0(model_associator, sync_driver::AssociatorInterface*());
MOCK_METHOD1(set_model_associator,
@@ -47,7 +47,7 @@ class FrontendDataTypeControllerMock : public FrontendDataTypeController {
MOCK_METHOD2(RecordUnrecoverableError, void(const tracked_objects::Location&,
const std::string&));
MOCK_METHOD1(RecordAssociationTime, void(base::TimeDelta time));
- MOCK_METHOD1(RecordStartFailure, void(StartResult result));
+ MOCK_METHOD1(RecordStartFailure, void(ConfigureResult result));
protected:
virtual ~FrontendDataTypeControllerMock();
diff --git a/chrome/browser/sync/glue/frontend_data_type_controller_unittest.cc b/chrome/browser/sync/glue/frontend_data_type_controller_unittest.cc
index 6f502e0aba..6f0b9bdd79 100644
--- a/chrome/browser/sync/glue/frontend_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/frontend_data_type_controller_unittest.cc
@@ -75,7 +75,7 @@ class FrontendDataTypeControllerFake : public FrontendDataTypeController {
mock_->RecordAssociationTime(time);
}
virtual void RecordStartFailure(
- DataTypeController::StartResult result) OVERRIDE {
+ DataTypeController::ConfigureResult result) OVERRIDE {
mock_->RecordStartFailure(result);
}
private:
@@ -120,7 +120,7 @@ class SyncFrontendDataTypeControllerTest : public testing::Test {
EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_));
}
- void SetActivateExpectations(DataTypeController::StartResult result) {
+ void SetActivateExpectations(DataTypeController::ConfigureResult result) {
EXPECT_CALL(start_callback_, Run(result, _, _));
}
@@ -131,7 +131,7 @@ class SyncFrontendDataTypeControllerTest : public testing::Test {
WillOnce(Return(syncer::SyncError()));
}
- void SetStartFailExpectations(DataTypeController::StartResult result) {
+ void SetStartFailExpectations(DataTypeController::ConfigureResult result) {
if (DataTypeController::IsUnrecoverableResult(result))
EXPECT_CALL(*dtc_mock_.get(), RecordUnrecoverableError(_, _));
EXPECT_CALL(*dtc_mock_.get(), CleanUpState());
@@ -255,21 +255,3 @@ TEST_F(SyncFrontendDataTypeControllerTest, Stop) {
frontend_dtc_->Stop();
EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state());
}
-
-TEST_F(SyncFrontendDataTypeControllerTest, OnSingleDatatypeUnrecoverableError) {
- SetStartExpectations();
- SetAssociateExpectations();
- SetActivateExpectations(DataTypeController::OK);
- EXPECT_CALL(*dtc_mock_.get(), RecordUnrecoverableError(_, "Test"));
- EXPECT_CALL(service_, DisableDatatype(_))
- .WillOnce(InvokeWithoutArgs(frontend_dtc_.get(),
- &FrontendDataTypeController::Stop));
- SetStopExpectations();
- EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state());
- Start();
- EXPECT_EQ(DataTypeController::RUNNING, frontend_dtc_->state());
- // This should cause frontend_dtc_->Stop() to be called.
- frontend_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test");
- PumpLoop();
- EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state());
-}
diff --git a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
index d48a174d4c..ea9d144851 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
@@ -157,16 +157,15 @@ NonFrontendDataTypeController::AssociationResult::AssociationResult(
NonFrontendDataTypeController::AssociationResult::~AssociationResult() {}
// TODO(tim): Legacy controllers are being left behind in componentization
-// effort for now, hence passing null DisableTypeCallback and still having
-// a dependency on ProfileSyncService. That dep can probably be removed
-// without too much work.
+// effort for now, hence still having a dependency on ProfileSyncService.
+// That dep can probably be removed without too much work.
NonFrontendDataTypeController::NonFrontendDataTypeController(
scoped_refptr<base::MessageLoopProxy> ui_thread,
const base::Closure& error_callback,
ProfileSyncComponentsFactory* profile_sync_factory,
Profile* profile,
ProfileSyncService* sync_service)
- : DataTypeController(ui_thread, error_callback, DisableTypeCallback()),
+ : DataTypeController(ui_thread, error_callback),
state_(NOT_RUNNING),
profile_sync_factory_(profile_sync_factory),
profile_(profile),
@@ -253,7 +252,9 @@ void DestroyComponentsInBackend(
void NonFrontendDataTypeController::Stop() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK_NE(state_, NOT_RUNNING);
+
+ if (state_ == NOT_RUNNING)
+ return;
// Deactivate the date type on the UI thread first to stop processing
// sync server changes. This needs to happen before posting task to destroy
@@ -297,21 +298,19 @@ sync_driver::DataTypeController::State NonFrontendDataTypeController::state()
return state_;
}
-void NonFrontendDataTypeController::OnSingleDatatypeUnrecoverableError(
- const tracked_objects::Location& from_here,
- const std::string& message) {
+void NonFrontendDataTypeController::OnSingleDataTypeUnrecoverableError(
+ const syncer::SyncError& error) {
DCHECK(IsOnBackendThread());
- RecordUnrecoverableError(from_here, message);
- BrowserThread::PostTask(BrowserThread::UI, from_here,
+ DCHECK_EQ(type(), error.model_type());
+ RecordUnrecoverableError(error.location(), error.message());
+ BrowserThread::PostTask(BrowserThread::UI, error.location(),
base::Bind(&NonFrontendDataTypeController::DisableImpl,
this,
- from_here,
- message));
+ error));
}
NonFrontendDataTypeController::NonFrontendDataTypeController()
- : DataTypeController(base::MessageLoopProxy::current(), base::Closure(),
- DisableTypeCallback()),
+ : DataTypeController(base::MessageLoopProxy::current(), base::Closure()),
state_(NOT_RUNNING),
profile_sync_factory_(NULL),
profile_(NULL),
@@ -340,7 +339,7 @@ bool NonFrontendDataTypeController::IsOnBackendThread() {
}
void NonFrontendDataTypeController::StartDone(
- DataTypeController::StartResult start_result,
+ DataTypeController::ConfigureResult start_result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -359,7 +358,7 @@ void NonFrontendDataTypeController::StartDone(
}
void NonFrontendDataTypeController::StartDoneImpl(
- DataTypeController::StartResult start_result,
+ DataTypeController::ConfigureResult start_result,
DataTypeController::State new_state,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
@@ -371,22 +370,19 @@ void NonFrontendDataTypeController::StartDoneImpl(
RecordStartFailure(start_result);
}
- DCHECK(!start_callback_.is_null());
- // We have to release the callback before we call it, since it's possible
- // invoking the callback will trigger a call to STOP(), which will get
- // confused by the non-NULL start_callback_.
- StartCallback callback = start_callback_;
- start_callback_.Reset();
- callback.Run(start_result, local_merge_result, syncer_merge_result);
+ start_callback_.Run(start_result, local_merge_result, syncer_merge_result);
}
void NonFrontendDataTypeController::DisableImpl(
- const tracked_objects::Location& from_here,
- const std::string& message) {
+ const syncer::SyncError& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- syncer::SyncError error(
- from_here, syncer::SyncError::DATATYPE_ERROR, message, type());
- profile_sync_service_->DisableDatatype(error);
+ if (!start_callback_.is_null()) {
+ syncer::SyncMergeResult local_merge_result(type());
+ local_merge_result.set_error(error);
+ start_callback_.Run(RUNTIME_ERROR,
+ local_merge_result,
+ syncer::SyncMergeResult(type()));
+ }
}
void NonFrontendDataTypeController::RecordAssociationTime(
@@ -398,7 +394,7 @@ void NonFrontendDataTypeController::RecordAssociationTime(
#undef PER_DATA_TYPE_MACRO
}
-void NonFrontendDataTypeController::RecordStartFailure(StartResult result) {
+void NonFrontendDataTypeController::RecordStartFailure(ConfigureResult result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures",
ModelTypeToHistogramInt(type()),
diff --git a/chrome/browser/sync/glue/non_frontend_data_type_controller.h b/chrome/browser/sync/glue/non_frontend_data_type_controller.h
index fac5890736..e2e5043f91 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller.h
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller.h
@@ -68,9 +68,8 @@ class NonFrontendDataTypeController : public sync_driver::DataTypeController {
// DataTypeErrorHandler interface.
// Note: this is performed on the datatype's thread.
- virtual void OnSingleDatatypeUnrecoverableError(
- const tracked_objects::Location& from_here,
- const std::string& message) OVERRIDE;
+ virtual void OnSingleDataTypeUnrecoverableError(
+ const syncer::SyncError& error) OVERRIDE;
// Callback to receive background association results.
struct AssociationResult {
@@ -134,26 +133,25 @@ class NonFrontendDataTypeController : public sync_driver::DataTypeController {
// Start up complete, update the state and invoke the callback.
// Note: this is performed on the datatype's thread.
virtual void StartDone(
- DataTypeController::StartResult start_result,
+ DataTypeController::ConfigureResult start_result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result);
// UI thread implementation of StartDone.
virtual void StartDoneImpl(
- DataTypeController::StartResult start_result,
+ DataTypeController::ConfigureResult start_result,
DataTypeController::State new_state,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result);
// The actual implementation of Disabling the datatype. This happens
// on the UI thread.
- virtual void DisableImpl(const tracked_objects::Location& from_here,
- const std::string& message);
+ virtual void DisableImpl(const syncer::SyncError& error);
// Record association time. Called on Datatype's thread.
virtual void RecordAssociationTime(base::TimeDelta time);
// Record causes of start failure. Called on UI thread.
- virtual void RecordStartFailure(StartResult result);
+ virtual void RecordStartFailure(ConfigureResult result);
// Handles the reporting of unrecoverable error. It records stuff in
// UMA and reports to breakpad.
diff --git a/chrome/browser/sync/glue/non_frontend_data_type_controller_mock.h b/chrome/browser/sync/glue/non_frontend_data_type_controller_mock.h
index ddf914c35e..d49eee5be5 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller_mock.h
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller_mock.h
@@ -39,11 +39,11 @@ class NonFrontendDataTypeControllerMock : public NonFrontendDataTypeController {
MOCK_METHOD0(CreateSyncComponents,
ProfileSyncComponentsFactory::SyncComponents());
MOCK_METHOD3(StartDone,
- void(DataTypeController::StartResult result,
+ void(DataTypeController::ConfigureResult result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result));
MOCK_METHOD4(StartDoneImpl,
- void(DataTypeController::StartResult result,
+ void(DataTypeController::ConfigureResult result,
DataTypeController::State new_state,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result));
@@ -53,7 +53,7 @@ class NonFrontendDataTypeControllerMock : public NonFrontendDataTypeController {
MOCK_METHOD2(RecordUnrecoverableError, void(const tracked_objects::Location&,
const std::string&));
MOCK_METHOD1(RecordAssociationTime, void(base::TimeDelta time));
- MOCK_METHOD1(RecordStartFailure, void(StartResult result));
+ MOCK_METHOD1(RecordStartFailure, void(ConfigureResult result));
protected:
virtual ~NonFrontendDataTypeControllerMock();
diff --git a/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc b/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc
index 2035f9dc63..605313b994 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc
@@ -97,7 +97,7 @@ class NonFrontendDataTypeControllerFake : public NonFrontendDataTypeController {
mock_->RecordAssociationTime(time);
}
virtual void RecordStartFailure(
- DataTypeController::StartResult result) OVERRIDE {
+ DataTypeController::ConfigureResult result) OVERRIDE {
mock_->RecordStartFailure(result);
}
virtual void DisconnectProcessor(
@@ -160,7 +160,7 @@ class SyncNonFrontendDataTypeControllerTest : public testing::Test {
EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_));
}
- void SetActivateExpectations(DataTypeController::StartResult result) {
+ void SetActivateExpectations(DataTypeController::ConfigureResult result) {
EXPECT_CALL(start_callback_, Run(result, _, _));
}
@@ -171,7 +171,7 @@ class SyncNonFrontendDataTypeControllerTest : public testing::Test {
WillOnce(Return(syncer::SyncError()));
}
- void SetStartFailExpectations(DataTypeController::StartResult result) {
+ void SetStartFailExpectations(DataTypeController::ConfigureResult result) {
if (DataTypeController::IsUnrecoverableResult(result))
EXPECT_CALL(*dtc_mock_.get(), RecordUnrecoverableError(_, _));
if (model_associator_) {
@@ -373,7 +373,7 @@ TEST_F(SyncNonFrontendDataTypeControllerTest, Stop) {
// Disabled due to http://crbug.com/388367
TEST_F(SyncNonFrontendDataTypeControllerTest,
- DISABLED_OnSingleDatatypeUnrecoverableError) {
+ DISABLED_OnSingleDataTypeUnrecoverableError) {
SetStartExpectations();
SetAssociateExpectations();
SetActivateExpectations(DataTypeController::OK);
@@ -387,11 +387,14 @@ TEST_F(SyncNonFrontendDataTypeControllerTest,
WaitForDTC();
EXPECT_EQ(DataTypeController::RUNNING, non_frontend_dtc_->state());
// This should cause non_frontend_dtc_->Stop() to be called.
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "error",
+ non_frontend_dtc_->type());
BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, base::Bind(
- &NonFrontendDataTypeControllerFake::OnSingleDatatypeUnrecoverableError,
+ &NonFrontendDataTypeControllerFake::OnSingleDataTypeUnrecoverableError,
non_frontend_dtc_.get(),
- FROM_HERE,
- std::string("Test")));
+ error));
WaitForDTC();
EXPECT_EQ(DataTypeController::NOT_RUNNING, non_frontend_dtc_->state());
}
diff --git a/chrome/browser/sync/glue/password_data_type_controller.cc b/chrome/browser/sync/glue/password_data_type_controller.cc
index 2ff1b37718..3681b04f66 100644
--- a/chrome/browser/sync/glue/password_data_type_controller.cc
+++ b/chrome/browser/sync/glue/password_data_type_controller.cc
@@ -19,12 +19,10 @@ namespace browser_sync {
PasswordDataTypeController::PasswordDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback)
+ Profile* profile)
: NonUIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
profile_sync_factory),
profile_(profile) {
}
diff --git a/chrome/browser/sync/glue/password_data_type_controller.h b/chrome/browser/sync/glue/password_data_type_controller.h
index 7394f0b8b5..e701a89b20 100644
--- a/chrome/browser/sync/glue/password_data_type_controller.h
+++ b/chrome/browser/sync/glue/password_data_type_controller.h
@@ -24,8 +24,7 @@ class PasswordDataTypeController : public sync_driver::NonUIDataTypeController {
public:
PasswordDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback);
+ Profile* profile);
// NonFrontendDataTypeController implementation
virtual syncer::ModelType type() const OVERRIDE;
diff --git a/chrome/browser/sync/glue/search_engine_data_type_controller.cc b/chrome/browser/sync/glue/search_engine_data_type_controller.cc
index 7a596aa01e..5ac663a6e1 100644
--- a/chrome/browser/sync/glue/search_engine_data_type_controller.cc
+++ b/chrome/browser/sync/glue/search_engine_data_type_controller.cc
@@ -18,12 +18,10 @@ namespace browser_sync {
SearchEngineDataTypeController::SearchEngineDataTypeController(
sync_driver::SyncApiComponentFactory* sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback)
+ Profile* profile)
: UIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
syncer::SEARCH_ENGINES,
sync_factory),
profile_(profile) {
diff --git a/chrome/browser/sync/glue/search_engine_data_type_controller.h b/chrome/browser/sync/glue/search_engine_data_type_controller.h
index b55dafc911..f40a6fa864 100644
--- a/chrome/browser/sync/glue/search_engine_data_type_controller.h
+++ b/chrome/browser/sync/glue/search_engine_data_type_controller.h
@@ -24,8 +24,7 @@ class SearchEngineDataTypeController
public:
SearchEngineDataTypeController(
sync_driver::SyncApiComponentFactory* profile_sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback);
+ Profile* profile);
TemplateURLService::Subscription* GetSubscriptionForTesting();
diff --git a/chrome/browser/sync/glue/search_engine_data_type_controller_unittest.cc b/chrome/browser/sync/glue/search_engine_data_type_controller_unittest.cc
index e8952c5dac..470c11af1d 100644
--- a/chrome/browser/sync/glue/search_engine_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/search_engine_data_type_controller_unittest.cc
@@ -39,8 +39,7 @@ class SyncSearchEngineDataTypeControllerTest : public testing::Test {
// Feed the DTC the profile so it is reused later.
// This allows us to control the associated TemplateURLService.
search_engine_dtc_ = new SearchEngineDataTypeController(
- profile_sync_factory_.get(), &profile_,
- sync_driver::DataTypeController::DisableTypeCallback());
+ profile_sync_factory_.get(), &profile_);
}
virtual void TearDown() {
diff --git a/chrome/browser/sync/glue/sync_backend_host_core.cc b/chrome/browser/sync/glue/sync_backend_host_core.cc
index f73911b076..26f9e0ea81 100644
--- a/chrome/browser/sync/glue/sync_backend_host_core.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_core.cc
@@ -430,22 +430,29 @@ void SyncBackendHostCore::DoInitialize(
sync_manager_ = options->sync_manager_factory->CreateSyncManager(name_);
sync_manager_->AddObserver(this);
- sync_manager_->Init(sync_data_folder_path_,
- options->event_handler,
- options->service_url,
- options->http_bridge_factory.Pass(),
- options->workers,
- options->extensions_activity,
- options->registrar /* as SyncManager::ChangeDelegate */,
- options->credentials,
- options->invalidator_client_id,
- options->restored_key_for_bootstrapping,
- options->restored_keystore_key_for_bootstrapping,
- options->internal_components_factory.get(),
- &encryptor_,
- options->unrecoverable_error_handler.Pass(),
- options->report_unrecoverable_error_function,
- &stop_syncing_signal_);
+
+ syncer::SyncManager::InitArgs args;
+ args.database_location = sync_data_folder_path_;
+ args.event_handler = options->event_handler;
+ args.service_url = options->service_url;
+ args.post_factory = options->http_bridge_factory.Pass();
+ args.workers = options->workers;
+ args.extensions_activity = options->extensions_activity;
+ args.change_delegate = options->registrar; // as SyncManager::ChangeDelegate
+ args.credentials = options->credentials;
+ args.invalidator_client_id = options->invalidator_client_id;
+ args.restored_key_for_bootstrapping = options->restored_key_for_bootstrapping;
+ args.restored_keystore_key_for_bootstrapping =
+ options->restored_keystore_key_for_bootstrapping;
+ args.internal_components_factory =
+ options->internal_components_factory.Pass();
+ args.encryptor = &encryptor_;
+ args.unrecoverable_error_handler =
+ options->unrecoverable_error_handler.Pass();
+ args.report_unrecoverable_error_function =
+ options->report_unrecoverable_error_function;
+ args.cancelation_signal = &stop_syncing_signal_;
+ sync_manager_->Init(&args);
}
void SyncBackendHostCore::DoUpdateCredentials(
@@ -602,20 +609,25 @@ void SyncBackendHostCore::DoConfigureSyncer(
syncer::ModelTypeSet)>& ready_task,
const base::Closure& retry_callback) {
DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
- sync_manager_->ConfigureSyncer(
- reason,
- config_types.to_download,
- config_types.to_purge,
- config_types.to_journal,
- config_types.to_unapply,
- routing_info,
+ DCHECK(!ready_task.is_null());
+ DCHECK(!retry_callback.is_null());
+ base::Closure chained_ready_task(
base::Bind(&SyncBackendHostCore::DoFinishConfigureDataTypes,
weak_ptr_factory_.GetWeakPtr(),
config_types.to_download,
- ready_task),
+ ready_task));
+ base::Closure chained_retry_task(
base::Bind(&SyncBackendHostCore::DoRetryConfiguration,
weak_ptr_factory_.GetWeakPtr(),
retry_callback));
+ sync_manager_->ConfigureSyncer(reason,
+ config_types.to_download,
+ config_types.to_purge,
+ config_types.to_journal,
+ config_types.to_unapply,
+ routing_info,
+ chained_ready_task,
+ chained_retry_task);
}
void SyncBackendHostCore::DoFinishConfigureDataTypes(
diff --git a/chrome/browser/sync/glue/theme_data_type_controller.cc b/chrome/browser/sync/glue/theme_data_type_controller.cc
index 162d9f645f..6e9852e11e 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.cc
+++ b/chrome/browser/sync/glue/theme_data_type_controller.cc
@@ -15,12 +15,10 @@ namespace browser_sync {
ThemeDataTypeController::ThemeDataTypeController(
sync_driver::SyncApiComponentFactory* sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback)
+ Profile* profile)
: UIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
- disable_callback,
syncer::THEMES,
sync_factory),
profile_(profile) {
diff --git a/chrome/browser/sync/glue/theme_data_type_controller.h b/chrome/browser/sync/glue/theme_data_type_controller.h
index 086ef00420..47e24f81d4 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.h
+++ b/chrome/browser/sync/glue/theme_data_type_controller.h
@@ -15,8 +15,7 @@ class ThemeDataTypeController : public sync_driver::UIDataTypeController {
public:
ThemeDataTypeController(
sync_driver::SyncApiComponentFactory* sync_factory,
- Profile* profile,
- const DisableTypeCallback& disable_callback);
+ Profile* profile);
private:
virtual ~ThemeDataTypeController();
diff --git a/chrome/browser/sync/glue/typed_url_change_processor.cc b/chrome/browser/sync/glue/typed_url_change_processor.cc
index 0ef8f7d52d..ae25e4f8bd 100644
--- a/chrome/browser/sync/glue/typed_url_change_processor.cc
+++ b/chrome/browser/sync/glue/typed_url_change_processor.cc
@@ -113,9 +113,11 @@ bool TypedUrlChangeProcessor::CreateOrUpdateSyncNode(
syncer::ReadNode typed_url_root(trans);
if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) !=
syncer::BaseNode::INIT_OK) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Server did not create the top-level typed_url node. We "
- "might be running against an out-of-date server.");
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "No top level folder",
+ syncer::TYPED_URLS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return false;
}
@@ -130,47 +132,24 @@ bool TypedUrlChangeProcessor::CreateOrUpdateSyncNode(
if (result == syncer::BaseNode::INIT_OK) {
model_associator_->WriteToSyncNode(url, visit_vector, &update_node);
} else if (result == syncer::BaseNode::INIT_FAILED_DECRYPT_IF_NECESSARY) {
- // TODO(tim): Investigating bug 121587.
- syncer::Cryptographer* crypto = trans->GetCryptographer();
- syncer::ModelTypeSet encrypted_types(trans->GetEncryptedTypes());
- const sync_pb::EntitySpecifics& specifics =
- update_node.GetEntry()->GetSpecifics();
- CHECK(specifics.has_encrypted());
- const bool can_decrypt = crypto->CanDecrypt(specifics.encrypted());
- const bool agreement = encrypted_types.Has(syncer::TYPED_URLS);
- if (!agreement && !can_decrypt) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Could not InitByIdLookup in CreateOrUpdateSyncNode, "
- " Cryptographer thinks typed urls not encrypted, and CanDecrypt"
- " failed.");
- LOG(ERROR) << "Case 1.";
- } else if (agreement && can_decrypt) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Could not InitByIdLookup on CreateOrUpdateSyncNode, "
- " Cryptographer thinks typed urls are encrypted, and CanDecrypt"
- " succeeded (?!), but DecryptIfNecessary failed.");
- LOG(ERROR) << "Case 2.";
- } else if (agreement) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Could not InitByIdLookup on CreateOrUpdateSyncNode, "
- " Cryptographer thinks typed urls are encrypted, but CanDecrypt"
- " failed.");
- LOG(ERROR) << "Case 3.";
- } else {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Could not InitByIdLookup on CreateOrUpdateSyncNode, "
- " Cryptographer thinks typed urls not encrypted, but CanDecrypt"
- " succeeded (super weird, btw)");
- LOG(ERROR) << "Case 4.";
- }
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to decrypt.",
+ syncer::TYPED_URLS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
+ return false;
} else {
syncer::WriteNode create_node(trans);
syncer::WriteNode::InitUniqueByCreationResult result =
create_node.InitUniqueByCreation(syncer::TYPED_URLS,
typed_url_root, tag);
if (result != syncer::WriteNode::INIT_SUCCESS) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "Failed to create typed_url sync node.");
+
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to create sync node",
+ syncer::TYPED_URLS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return false;
}
@@ -194,8 +173,11 @@ void TypedUrlChangeProcessor::HandleURLsDeleted(
if (details->all_history) {
if (!model_associator_->DeleteAllNodes(&trans)) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- std::string());
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to delete local nodes.",
+ syncer::TYPED_URLS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
} else {
@@ -254,8 +236,11 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel(
syncer::ReadNode typed_url_root(trans);
if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) !=
syncer::BaseNode::INIT_OK) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "TypedUrl root node lookup failed.");
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to init type root.",
+ syncer::TYPED_URLS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
@@ -276,8 +261,11 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel(
syncer::ReadNode sync_node(trans);
if (sync_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) {
- error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
- "TypedUrl node lookup failed.");
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::DATATYPE_ERROR,
+ "Failed to init sync node.",
+ syncer::TYPED_URLS);
+ error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
diff --git a/chrome/browser/sync/glue/typed_url_data_type_controller.cc b/chrome/browser/sync/glue/typed_url_data_type_controller.cc
index 403d6b07b3..caaa099c65 100644
--- a/chrome/browser/sync/glue/typed_url_data_type_controller.cc
+++ b/chrome/browser/sync/glue/typed_url_data_type_controller.cc
@@ -126,7 +126,7 @@ void TypedUrlDataTypeController::OnSavingBrowserHistoryDisabledChanged() {
syncer::SyncError::DATATYPE_POLICY_ERROR,
"History saving is now disabled by policy.",
syncer::TYPED_URLS);
- profile_sync_service()->DisableDatatype(error);
+ OnSingleDataTypeUnrecoverableError(error);
}
}
}