summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-08 23:40:06 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-08 23:40:06 +0000
commitf6ec8b2db8c6fcaa2466b6294d49260538ca00a4 (patch)
tree839cc2c9f268d67cb34743b753771b3b9114ed5e /chrome
parent1b9c01fef349b0721f65248ae9f762e47218af95 (diff)
downloadchromium_src-f6ec8b2db8c6fcaa2466b6294d49260538ca00a4.zip
chromium_src-f6ec8b2db8c6fcaa2466b6294d49260538ca00a4.tar.gz
chromium_src-f6ec8b2db8c6fcaa2466b6294d49260538ca00a4.tar.bz2
sync: Add location info to unrecoverable errors, and remove the UnrecoverableErrorHandler from model associators since it's illegal to use from there anyway.
BUG=42695 TEST=data type controller unittests Review URL: http://codereview.chromium.org/2002012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49215 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sync/glue/autofill_change_processor.cc72
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller.cc13
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller.h8
-rw-r--r--chrome/browser/sync/glue/autofill_model_associator.cc5
-rw-r--r--chrome/browser/sync/glue/autofill_model_associator.h4
-rw-r--r--chrome/browser/sync/glue/bookmark_change_processor.cc22
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller.cc5
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller.h5
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc10
-rw-r--r--chrome/browser/sync/glue/bookmark_model_associator.cc8
-rw-r--r--chrome/browser/sync/glue/bookmark_model_associator.h12
-rw-r--r--chrome/browser/sync/glue/data_type_controller_mock.h3
-rw-r--r--chrome/browser/sync/glue/password_change_processor.cc41
-rw-r--r--chrome/browser/sync/glue/password_data_type_controller.cc16
-rw-r--r--chrome/browser/sync/glue/password_data_type_controller.h8
-rw-r--r--chrome/browser/sync/glue/password_model_associator.cc5
-rw-r--r--chrome/browser/sync/glue/password_model_associator.h4
-rw-r--r--chrome/browser/sync/glue/preference_change_processor.cc26
-rw-r--r--chrome/browser/sync/glue/preference_change_processor.h2
-rw-r--r--chrome/browser/sync/glue/preference_data_type_controller.cc6
-rw-r--r--chrome/browser/sync/glue/preference_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/preference_data_type_controller_unittest.cc11
-rw-r--r--chrome/browser/sync/glue/preference_model_associator.cc4
-rw-r--r--chrome/browser/sync/glue/preference_model_associator.h5
-rw-r--r--chrome/browser/sync/glue/theme_change_processor.cc18
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller.cc6
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller.h6
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller_unittest.cc9
-rw-r--r--chrome/browser/sync/glue/theme_model_associator.cc8
-rw-r--r--chrome/browser/sync/glue/theme_model_associator.h4
-rw-r--r--chrome/browser/sync/glue/typed_url_change_processor.cc48
-rw-r--r--chrome/browser/sync/glue/typed_url_data_type_controller.cc13
-rw-r--r--chrome/browser/sync/glue/typed_url_data_type_controller.h8
-rw-r--r--chrome/browser/sync/glue/typed_url_model_associator.cc5
-rw-r--r--chrome/browser/sync/glue/typed_url_model_associator.h4
-rw-r--r--chrome/browser/sync/profile_sync_factory_impl.cc15
-rw-r--r--chrome/browser/sync/profile_sync_service.cc16
-rw-r--r--chrome/browser/sync/profile_sync_service.h15
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.h4
-rw-r--r--chrome/browser/sync/profile_sync_service_password_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_preference_unittest.cc17
-rw-r--r--chrome/browser/sync/profile_sync_service_typed_url_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc21
-rw-r--r--chrome/browser/sync/profile_sync_test_util.h17
-rw-r--r--chrome/browser/sync/unrecoverable_error_handler.h7
46 files changed, 303 insertions, 242 deletions
diff --git a/chrome/browser/sync/glue/autofill_change_processor.cc b/chrome/browser/sync/glue/autofill_change_processor.cc
index 4db970d..06e7e86 100644
--- a/chrome/browser/sync/glue/autofill_change_processor.cc
+++ b/chrome/browser/sync/glue/autofill_change_processor.cc
@@ -58,9 +58,9 @@ void AutofillChangeProcessor::Observe(NotificationType type,
sync_api::WriteTransaction trans(share_handle());
sync_api::ReadNode autofill_root(&trans);
if (!autofill_root.InitByTagLookup(kAutofillTag)) {
- error_handler()->OnUnrecoverableError();
- LOG(ERROR) << "Server did not create the top-level autofill node. "
- << "We might be running against an out-of-date server.";
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Server did not create the top-level autofill node. "
+ "We might be running against an out-of-date server.");
return;
}
@@ -92,15 +92,17 @@ void AutofillChangeProcessor::HandleMoveAsideIfNeeded(
string16 label(AutofillModelAssociator::MakeUniqueLabel(profile->Label(),
trans));
if (label.empty()) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "No unique label; can't move aside");
return;
}
tag->assign(AutofillModelAssociator::ProfileLabelToTag(label));
profile->set_label(label);
if (!web_database_->UpdateAutoFillProfile(*profile)) {
- LOG(ERROR) << "Failed to overwrite label for node" << label;
- error_handler()->OnUnrecoverableError();
+ std::string err = "Failed to overwrite label for node ";
+ err += UTF16ToUTF8(label);
+ error_handler()->OnUnrecoverableError(FROM_HERE, err);
return;
}
@@ -120,8 +122,8 @@ void AutofillChangeProcessor::AddAutofillProfileSyncNode(
const std::string& tag, const AutoFillProfile* profile) {
sync_api::WriteNode sync_node(trans);
if (!sync_node.InitUniqueByCreation(syncable::AUTOFILL, autofill, tag)) {
- LOG(ERROR) << "Failed to create autofill sync node.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to create autofill sync node.");
return;
}
sync_node.SetTitle(UTF8ToWide(tag));
@@ -160,13 +162,13 @@ void AutofillChangeProcessor::ObserveAutofillProfileChanged(
}
int64 sync_id = model_associator_->GetSyncIdFromChromeId(tag);
if (sync_api::kInvalidId == sync_id) {
- LOG(ERROR) << "Unexpected notification for: " << tag;
- error_handler()->OnUnrecoverableError();
+ std::string err = "Unexpected notification for: " + tag;
+ error_handler()->OnUnrecoverableError(FROM_HERE, err);
return;
} else {
if (!sync_node.InitByIdLookup(sync_id)) {
- LOG(ERROR) << "Autofill node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Autofill node lookup failed.");
return;
}
WriteAutofillProfile(*change->profile(), &sync_node);
@@ -194,8 +196,8 @@ void AutofillChangeProcessor::ObserveAutofillEntriesChanged(
change->key().value());
if (!sync_node.InitUniqueByCreation(syncable::AUTOFILL,
autofill_root, tag)) {
- LOG(ERROR) << "Failed to create autofill sync node.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to create autofill sync node.");
return;
}
@@ -204,8 +206,8 @@ void AutofillChangeProcessor::ObserveAutofillEntriesChanged(
change->key().name(),
change->key().value(),
&timestamps)) {
- LOG(ERROR) << "Failed to get timestamps.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to get timestamps.");
return;
}
@@ -225,14 +227,14 @@ void AutofillChangeProcessor::ObserveAutofillEntriesChanged(
change->key().name(), change->key().value());
int64 sync_id = model_associator_->GetSyncIdFromChromeId(tag);
if (sync_api::kInvalidId == sync_id) {
- LOG(ERROR) << "Unexpected notification for: " <<
- change->key().name();
- error_handler()->OnUnrecoverableError();
+ std::string err = "Unexpected notification for: " +
+ UTF16ToUTF8(change->key().name());
+ error_handler()->OnUnrecoverableError(FROM_HERE, err);
return;
} else {
if (!sync_node.InitByIdLookup(sync_id)) {
- LOG(ERROR) << "Autofill node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Autofill node lookup failed.");
return;
}
}
@@ -242,8 +244,8 @@ void AutofillChangeProcessor::ObserveAutofillEntriesChanged(
change->key().name(),
change->key().value(),
&timestamps)) {
- LOG(ERROR) << "Failed to get timestamps.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to get timestamps.");
return;
}
@@ -266,13 +268,13 @@ void AutofillChangeProcessor::RemoveSyncNode(const std::string& tag,
sync_api::WriteNode sync_node(trans);
int64 sync_id = model_associator_->GetSyncIdFromChromeId(tag);
if (sync_api::kInvalidId == sync_id) {
- LOG(ERROR) << "Unexpected notification";
- error_handler()->OnUnrecoverableError();
+ std::string err = "Unexpected notification for: " + tag;
+ error_handler()->OnUnrecoverableError(FROM_HERE, err);
return;
} else {
if (!sync_node.InitByIdLookup(sync_id)) {
- LOG(ERROR) << "Autofill node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Autofill node lookup failed.");
return;
}
model_associator_->Disassociate(sync_node.GetId());
@@ -291,8 +293,8 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
sync_api::ReadNode autofill_root(trans);
if (!autofill_root.InitByTagLookup(kAutofillTag)) {
- LOG(ERROR) << "Autofill root node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Autofill root node lookup failed.");
return;
}
@@ -316,8 +318,8 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
// Handle an update or add.
sync_api::ReadNode sync_node(trans);
if (!sync_node.InitByIdLookup(changes[i].id)) {
- LOG(ERROR) << "Autofill node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Autofill node lookup failed.");
return;
}
@@ -337,8 +339,8 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
}
if (!web_database_->UpdateAutofillEntries(new_entries)) {
- LOG(ERROR) << "Could not update autofill entries.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Could not update autofill entries.");
return;
}
@@ -351,8 +353,8 @@ void AutofillChangeProcessor::ApplySyncAutofillEntryDelete(
const sync_pb::AutofillSpecifics& autofill) {
if (!web_database_->RemoveFormElement(
UTF8ToUTF16(autofill.name()), UTF8ToUTF16(autofill.value()))) {
- LOG(ERROR) << "Could not remove autofill node.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Could not remove autofill node.");
return;
}
}
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.cc b/chrome/browser/sync/glue/autofill_data_type_controller.cc
index 1d436ca..9353718 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.cc
@@ -231,18 +231,23 @@ void AutofillDataTypeController::StartFailed(StartResult result) {
StartDone(result, NOT_RUNNING);
}
-void AutofillDataTypeController::OnUnrecoverableError() {
+void AutofillDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(this,
- &AutofillDataTypeController::OnUnrecoverableErrorImpl));
+ &AutofillDataTypeController::OnUnrecoverableErrorImpl,
+ from_here, message));
UMA_HISTOGRAM_COUNTS("Sync.AutofillRunFailures", 1);
}
-void AutofillDataTypeController::OnUnrecoverableErrorImpl() {
+void AutofillDataTypeController::OnUnrecoverableErrorImpl(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- sync_service_->OnUnrecoverableError();
+ sync_service_->OnUnrecoverableError(from_here, message);
}
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.h b/chrome/browser/sync/glue/autofill_data_type_controller.h
index e522dbd..b21332c 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.h
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
#define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
+#include <string>
+
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/waitable_event.h"
@@ -60,7 +62,8 @@ class AutofillDataTypeController : public DataTypeController,
}
// UnrecoverableHandler implementation
- virtual void OnUnrecoverableError();
+ virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
+ const std::string& message);
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
@@ -76,7 +79,8 @@ class AutofillDataTypeController : public DataTypeController,
void StartDoneImpl(StartResult result, State state);
void StopImpl();
void StartFailed(StartResult result);
- void OnUnrecoverableErrorImpl();
+ void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here,
+ const std::string& message);
// Second-half of "Start" implementation, called once personal data has
// loaded.
diff --git a/chrome/browser/sync/glue/autofill_model_associator.cc b/chrome/browser/sync/glue/autofill_model_associator.cc
index b22970c..127df31 100644
--- a/chrome/browser/sync/glue/autofill_model_associator.cc
+++ b/chrome/browser/sync/glue/autofill_model_associator.cc
@@ -32,18 +32,15 @@ static const int kMaxNumAttemptsToFindUniqueLabel = 100;
AutofillModelAssociator::AutofillModelAssociator(
ProfileSyncService* sync_service,
WebDatabase* web_database,
- PersonalDataManager* personal_data,
- UnrecoverableErrorHandler* error_handler)
+ PersonalDataManager* personal_data)
: sync_service_(sync_service),
web_database_(web_database),
personal_data_(personal_data),
- error_handler_(error_handler),
autofill_node_id_(sync_api::kInvalidId),
abort_association_pending_(false) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
DCHECK(sync_service_);
DCHECK(web_database_);
- DCHECK(error_handler_);
DCHECK(personal_data_);
}
diff --git a/chrome/browser/sync/glue/autofill_model_associator.h b/chrome/browser/sync/glue/autofill_model_associator.h
index aa89d61..0e110ea 100644
--- a/chrome/browser/sync/glue/autofill_model_associator.h
+++ b/chrome/browser/sync/glue/autofill_model_associator.h
@@ -49,8 +49,7 @@ class AutofillModelAssociator
static syncable::ModelType model_type() { return syncable::AUTOFILL; }
AutofillModelAssociator(ProfileSyncService* sync_service,
WebDatabase* web_database,
- PersonalDataManager* data_manager,
- UnrecoverableErrorHandler* error_handler);
+ PersonalDataManager* data_manager);
virtual ~AutofillModelAssociator();
// A task used by this class and the change processor to inform the
@@ -204,7 +203,6 @@ class AutofillModelAssociator
ProfileSyncService* sync_service_;
WebDatabase* web_database_;
PersonalDataManager* personal_data_;
- UnrecoverableErrorHandler* error_handler_;
int64 autofill_node_id_;
AutofillToSyncIdMap id_map_;
diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc
index 92a633f..e625fb7 100644
--- a/chrome/browser/sync/glue/bookmark_change_processor.cc
+++ b/chrome/browser/sync/glue/bookmark_change_processor.cc
@@ -77,7 +77,7 @@ void BookmarkChangeProcessor::RemoveOneSyncNode(
sync_api::WriteTransaction* trans, const BookmarkNode* node) {
sync_api::WriteNode sync_node(trans);
if (!model_associator_->InitSyncNodeFromChromeId(node->id(), &sync_node)) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, std::string());
return;
}
// This node should have no children.
@@ -158,8 +158,8 @@ 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)) {
- LOG(WARNING) << "Sync node creation failed; recovery unlikely";
- error_handler->OnUnrecoverableError();
+ error_handler->OnUnrecoverableError(FROM_HERE,
+ "Sync node creation failed; recovery unlikely");
return sync_api::kInvalidId;
}
@@ -196,7 +196,7 @@ void BookmarkChangeProcessor::BookmarkNodeChanged(BookmarkModel* model,
// Lookup the sync node that's associated with |node|.
sync_api::WriteNode sync_node(&trans);
if (!model_associator_->InitSyncNodeFromChromeId(node->id(), &sync_node)) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, std::string());
return;
}
@@ -230,13 +230,13 @@ void BookmarkChangeProcessor::BookmarkNodeMoved(BookmarkModel* model,
// Lookup the sync node that's associated with |child|.
sync_api::WriteNode sync_node(&trans);
if (!model_associator_->InitSyncNodeFromChromeId(child->id(), &sync_node)) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, std::string());
return;
}
if (!PlaceSyncNode(MOVE, new_parent, new_index, &trans, &sync_node,
model_associator_, error_handler())) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, std::string());
return;
}
}
@@ -259,7 +259,7 @@ void BookmarkChangeProcessor::BookmarkNodeChildrenReordered(
sync_api::WriteNode sync_child(&trans);
if (!model_associator_->InitSyncNodeFromChromeId(node->GetChild(i)->id(),
&sync_child)) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, std::string());
return;
}
DCHECK_EQ(sync_child.GetParentId(),
@@ -267,7 +267,7 @@ void BookmarkChangeProcessor::BookmarkNodeChildrenReordered(
if (!PlaceSyncNode(MOVE, node, i, &trans, &sync_child,
model_associator_, error_handler())) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, std::string());
return;
}
}
@@ -281,7 +281,7 @@ bool BookmarkChangeProcessor::PlaceSyncNode(MoveOrCreate operation,
sync_api::ReadNode sync_parent(trans);
if (!associator->InitSyncNodeFromChromeId(parent->id(), &sync_parent)) {
LOG(WARNING) << "Parent lookup failed";
- error_handler->OnUnrecoverableError();
+ error_handler->OnUnrecoverableError(FROM_HERE, std::string());
return false;
}
@@ -412,8 +412,8 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel(
sync_api::ReadNode src(trans);
if (!src.InitByIdLookup(changes[i].id)) {
- LOG(ERROR) << "ApplyModelChanges was passed a bad ID";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "ApplyModelChanges was passed a bad ID");
return;
}
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller.cc b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
index 92abb7a..e234247 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
@@ -87,10 +87,11 @@ void BookmarkDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
-void BookmarkDataTypeController::OnUnrecoverableError() {
+void BookmarkDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here, const std::string& message) {
// The ProfileSyncService will invoke our Stop() method in response to this.
UMA_HISTOGRAM_COUNTS("Sync.BookmarkRunFailures", 1);
- sync_service_->OnUnrecoverableError();
+ sync_service_->OnUnrecoverableError(from_here, message);
}
void BookmarkDataTypeController::Observe(NotificationType type,
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller.h b/chrome/browser/sync/glue/bookmark_data_type_controller.h
index ecb6255..7a43c73 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller.h
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__
#define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__
+#include <string>
+
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
@@ -60,7 +62,8 @@ class BookmarkDataTypeController : public DataTypeController,
}
// UnrecoverableErrorHandler interface.
- virtual void OnUnrecoverableError();
+ virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
+ const std::string& message);
// NotificationObserver interface.
virtual void Observe(NotificationType type,
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 d5466ea..be12787 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
@@ -28,7 +28,7 @@ using browser_sync::DataTypeController;
using browser_sync::ModelAssociatorMock;
using testing::_;
using testing::DoAll;
-using testing::Invoke;
+using testing::InvokeWithoutArgs;
using testing::Return;
using testing::SetArgumentPointee;
@@ -214,13 +214,13 @@ TEST_F(BookmarkDataTypeControllerTest, OnUnrecoverableError) {
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(service_, OnUnrecoverableError()).
- WillOnce(Invoke(bookmark_dtc_.get(),
- &BookmarkDataTypeController::Stop));
+ EXPECT_CALL(service_, OnUnrecoverableError(_,_)).
+ WillOnce(InvokeWithoutArgs(bookmark_dtc_.get(),
+ &BookmarkDataTypeController::Stop));
SetStopExpectations();
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
// This should cause bookmark_dtc_->Stop() to be called.
- bookmark_dtc_->OnUnrecoverableError();
+ bookmark_dtc_->OnUnrecoverableError(FROM_HERE, "Test");
}
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc
index ce40157..26e50c2 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.cc
+++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
@@ -155,12 +155,13 @@ const BookmarkNode* BookmarkNodeIdIndex::Find(int64 id) const {
BookmarkModelAssociator::BookmarkModelAssociator(
ProfileSyncService* sync_service,
- UnrecoverableErrorHandler* error_handler)
+ UnrecoverableErrorHandler* persist_ids_error_handler)
: sync_service_(sync_service),
- error_handler_(error_handler),
+ persist_ids_error_handler_(persist_ids_error_handler),
ALLOW_THIS_IN_INITIALIZER_LIST(persist_associations_(this)) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(sync_service_);
+ DCHECK(persist_ids_error_handler_);
}
BookmarkModelAssociator::~BookmarkModelAssociator() {
@@ -455,7 +456,8 @@ void BookmarkModelAssociator::PersistAssociations() {
int64 sync_id = *iter;
sync_api::WriteNode sync_node(&trans);
if (!sync_node.InitByIdLookup(sync_id)) {
- error_handler_->OnUnrecoverableError();
+ persist_ids_error_handler_->OnUnrecoverableError(FROM_HERE,
+ "Could not lookup bookmark node for ID persistence.");
return;
}
const BookmarkNode* node = GetChromeNodeFromSyncId(sync_id);
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.h b/chrome/browser/sync/glue/bookmark_model_associator.h
index e4bf930..4d0d640 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.h
+++ b/chrome/browser/sync/glue/bookmark_model_associator.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/task.h"
+#include "chrome/browser/sync/unrecoverable_error_handler.h"
#include "chrome/browser/sync/glue/model_associator.h"
class BookmarkNode;
@@ -26,7 +27,6 @@ class ProfileSyncService;
namespace browser_sync {
class BookmarkChangeProcessor;
-class UnrecoverableErrorHandler;
// Contains all model association related logic:
// * Algorithm to associate bookmark model and sync model.
@@ -37,7 +37,7 @@ class BookmarkModelAssociator
public:
static syncable::ModelType model_type() { return syncable::BOOKMARKS; }
BookmarkModelAssociator(ProfileSyncService* sync_service,
- UnrecoverableErrorHandler* error_handler);
+ UnrecoverableErrorHandler* persist_ids_error_handler);
virtual ~BookmarkModelAssociator();
// AssociatorInterface implementation.
@@ -87,15 +87,15 @@ class BookmarkModelAssociator
// thread.
}
+ // Returns sync service instance.
+ ProfileSyncService* sync_service() { return sync_service_; }
+
protected:
// Stores the id of the node with the given tag in |sync_id|.
// Returns of that node was found successfully.
// Tests override this.
virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id);
- // Returns sync service instance.
- ProfileSyncService* sync_service() { return sync_service_; }
-
private:
typedef std::map<int64, int64> BookmarkIdToSyncIdMap;
typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap;
@@ -128,7 +128,7 @@ class BookmarkModelAssociator
const sync_api::BaseNode* sync_node) const;
ProfileSyncService* sync_service_;
- UnrecoverableErrorHandler* error_handler_;
+ UnrecoverableErrorHandler* persist_ids_error_handler_;
BookmarkIdToSyncIdMap id_map_;
SyncIdToBookmarkNodeMap id_map_inverse_;
// Stores sync ids for dirty associations.
diff --git a/chrome/browser/sync/glue/data_type_controller_mock.h b/chrome/browser/sync/glue/data_type_controller_mock.h
index 914e98f..e9d1be6 100644
--- a/chrome/browser/sync/glue/data_type_controller_mock.h
+++ b/chrome/browser/sync/glue/data_type_controller_mock.h
@@ -19,7 +19,8 @@ class DataTypeControllerMock : public DataTypeController {
MOCK_CONST_METHOD0(name, const char*());
MOCK_METHOD0(model_safe_group, browser_sync::ModelSafeGroup());
MOCK_METHOD0(state, State());
- MOCK_METHOD0(OnUnrecoverableError, void());
+ MOCK_METHOD2(OnUnrecoverableError, void(const tracked_objects::Location&,
+ const std::string&));
};
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/password_change_processor.cc b/chrome/browser/sync/glue/password_change_processor.cc
index 57a377d..7a115b1 100644
--- a/chrome/browser/sync/glue/password_change_processor.cc
+++ b/chrome/browser/sync/glue/password_change_processor.cc
@@ -55,9 +55,9 @@ void PasswordChangeProcessor::Observe(NotificationType type,
sync_api::ReadNode password_root(&trans);
if (!password_root.InitByTagLookup(kPasswordTag)) {
- error_handler()->OnUnrecoverableError();
- LOG(ERROR) << "Server did not create the top-level password node. "
- << "We might be running against an out-of-date server.";
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Server did not create the top-level password node. "
+ "We might be running against an out-of-date server.");
return;
}
@@ -71,8 +71,8 @@ void PasswordChangeProcessor::Observe(NotificationType type,
sync_api::WriteNode sync_node(&trans);
if (!sync_node.InitUniqueByCreation(syncable::PASSWORD,
password_root, tag)) {
- LOG(ERROR) << "Failed to create password sync node.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to create password sync node.");
return;
}
@@ -84,13 +84,13 @@ void PasswordChangeProcessor::Observe(NotificationType type,
sync_api::WriteNode sync_node(&trans);
int64 sync_id = model_associator_->GetSyncIdFromChromeId(tag);
if (sync_api::kInvalidId == sync_id) {
- LOG(ERROR) << "Unexpected notification for: " << tag;
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Unexpected notification for: ");
return;
} else {
if (!sync_node.InitByIdLookup(sync_id)) {
- LOG(ERROR) << "Password node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Password node lookup failed.");
return;
}
}
@@ -102,13 +102,13 @@ void PasswordChangeProcessor::Observe(NotificationType type,
sync_api::WriteNode sync_node(&trans);
int64 sync_id = model_associator_->GetSyncIdFromChromeId(tag);
if (sync_api::kInvalidId == sync_id) {
- LOG(ERROR) << "Unexpected notification";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Unexpected notification");
return;
} else {
if (!sync_node.InitByIdLookup(sync_id)) {
- LOG(ERROR) << "Password node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Password node lookup failed.");
return;
}
model_associator_->Disassociate(sync_node.GetId());
@@ -131,8 +131,8 @@ void PasswordChangeProcessor::ApplyChangesFromSyncModel(
sync_api::ReadNode password_root(trans);
if (!password_root.InitByTagLookup(kPasswordTag)) {
- LOG(ERROR) << "Password root node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Password root node lookup failed.");
return;
}
@@ -144,8 +144,8 @@ void PasswordChangeProcessor::ApplyChangesFromSyncModel(
sync_api::ReadNode sync_node(trans);
if (!sync_node.InitByIdLookup(changes[i].id)) {
- LOG(ERROR) << "Password node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Password node lookup failed.");
return;
}
@@ -155,8 +155,8 @@ void PasswordChangeProcessor::ApplyChangesFromSyncModel(
sync_pb::PasswordSpecificsData password_data;
if (!sync_node.GetPasswordSpecifics(&password_data)) {
- LOG(ERROR) << "Could not read password specifics";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Could not read password specifics");
return;
}
webkit_glue::PasswordForm password;
@@ -177,8 +177,7 @@ void PasswordChangeProcessor::ApplyChangesFromSyncModel(
if (!model_associator_->WriteToPasswordStore(&new_passwords,
&updated_passwords,
&deleted_passwords)) {
- LOG(ERROR) << "Error writing passwords";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, "Error writing passwords");
return;
}
diff --git a/chrome/browser/sync/glue/password_data_type_controller.cc b/chrome/browser/sync/glue/password_data_type_controller.cc
index 50f4e86..f198d5c 100644
--- a/chrome/browser/sync/glue/password_data_type_controller.cc
+++ b/chrome/browser/sync/glue/password_data_type_controller.cc
@@ -129,16 +129,20 @@ void PasswordDataTypeController::StartFailed(StartResult result) {
StartDone(result, NOT_RUNNING);
}
-void PasswordDataTypeController::OnUnrecoverableError() {
+void PasswordDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here, const std::string& message) {
ChromeThread::PostTask(
- ChromeThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &PasswordDataTypeController::OnUnrecoverableErrorImpl));
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this,
+ &PasswordDataTypeController::OnUnrecoverableErrorImpl,
+ from_here, message));
}
-void PasswordDataTypeController::OnUnrecoverableErrorImpl() {
+void PasswordDataTypeController::OnUnrecoverableErrorImpl(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- sync_service_->OnUnrecoverableError();
+ sync_service_->OnUnrecoverableError(from_here, message);
}
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/password_data_type_controller.h b/chrome/browser/sync/glue/password_data_type_controller.h
index 8d04b23..83ba139 100644
--- a/chrome/browser/sync/glue/password_data_type_controller.h
+++ b/chrome/browser/sync/glue/password_data_type_controller.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SYNC_GLUE_PASSWORD_DATA_TYPE_CONTROLLER_H__
#define CHROME_BROWSER_SYNC_GLUE_PASSWORD_DATA_TYPE_CONTROLLER_H__
+#include <string>
+
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/sync/profile_sync_service.h"
@@ -56,7 +58,8 @@ class PasswordDataTypeController : public DataTypeController {
}
// UnrecoverableHandler implementation
- virtual void OnUnrecoverableError();
+ virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
+ const std::string& message);
private:
void StartImpl();
@@ -64,7 +67,8 @@ class PasswordDataTypeController : public DataTypeController {
void StartDoneImpl(StartResult result, State state);
void StopImpl();
void StartFailed(StartResult result);
- void OnUnrecoverableErrorImpl();
+ void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here,
+ const std::string& message);
void set_state(State state) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
diff --git a/chrome/browser/sync/glue/password_model_associator.cc b/chrome/browser/sync/glue/password_model_associator.cc
index 923ee7b..2812fe0 100644
--- a/chrome/browser/sync/glue/password_model_associator.cc
+++ b/chrome/browser/sync/glue/password_model_associator.cc
@@ -22,17 +22,14 @@ const char kPasswordTag[] = "google_chrome_passwords";
PasswordModelAssociator::PasswordModelAssociator(
ProfileSyncService* sync_service,
- PasswordStore* password_store,
- UnrecoverableErrorHandler* error_handler)
+ PasswordStore* password_store)
: sync_service_(sync_service),
password_store_(password_store),
- error_handler_(error_handler),
password_node_id_(sync_api::kInvalidId),
abort_association_pending_(false),
expected_loop_(MessageLoop::current()) {
DCHECK(sync_service_);
DCHECK(password_store_);
- DCHECK(error_handler_);
#if defined(OS_MACOSX)
DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::UI));
#else
diff --git a/chrome/browser/sync/glue/password_model_associator.h b/chrome/browser/sync/glue/password_model_associator.h
index 55ebce0..ad3738b 100644
--- a/chrome/browser/sync/glue/password_model_associator.h
+++ b/chrome/browser/sync/glue/password_model_associator.h
@@ -52,8 +52,7 @@ class PasswordModelAssociator
static syncable::ModelType model_type() { return syncable::PASSWORD; }
PasswordModelAssociator(ProfileSyncService* sync_service,
- PasswordStore* password_store,
- UnrecoverableErrorHandler* error_handler);
+ PasswordStore* password_store);
virtual ~PasswordModelAssociator() { }
// PerDataTypeAssociatorInterface implementation.
@@ -136,7 +135,6 @@ class PasswordModelAssociator
ProfileSyncService* sync_service_;
PasswordStore* password_store_;
- UnrecoverableErrorHandler* error_handler_;
int64 password_node_id_;
// Abort association pending flag and lock. If this is set to true
diff --git a/chrome/browser/sync/glue/preference_change_processor.cc b/chrome/browser/sync/glue/preference_change_processor.cc
index 3afa35e..8e11f9d 100644
--- a/chrome/browser/sync/glue/preference_change_processor.cc
+++ b/chrome/browser/sync/glue/preference_change_processor.cc
@@ -61,20 +61,20 @@ void PreferenceChangeProcessor::Observe(NotificationType type,
int64 sync_id = model_associator_->GetSyncIdFromChromeId(*name);
if (sync_api::kInvalidId == sync_id) {
- LOG(ERROR) << "Unexpected notification for: " << *name;
- error_handler()->OnUnrecoverableError();
+ std::wstring err = L"Unexpected notification for: " + *name;
+ error_handler()->OnUnrecoverableError(FROM_HERE, WideToUTF8(err));
return;
} else {
if (!node.InitByIdLookup(sync_id)) {
- LOG(ERROR) << "Preference node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Preference node lookup failed.");
return;
}
}
if (!WritePreference(&node, *name, preference->GetValue())) {
- LOG(ERROR) << "Failed to update preference node.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to update preference node.");
return;
}
}
@@ -102,8 +102,8 @@ void PreferenceChangeProcessor::ApplyChangesFromSyncModel(
}
if (!node.InitByIdLookup(changes[i].id)) {
- LOG(ERROR) << "Preference node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Preference node lookup failed.");
return;
}
DCHECK(syncable::PREFERENCES == node.GetModelType());
@@ -154,8 +154,8 @@ bool PreferenceChangeProcessor::WritePreference(
std::string serialized;
JSONStringValueSerializer json(&serialized);
if (!json.Serialize(*value)) {
- LOG(ERROR) << "Failed to serialize preference value.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to serialize preference value.");
return false;
}
@@ -175,9 +175,9 @@ Value* PreferenceChangeProcessor::ReadPreference(
base::JSONReader reader;
scoped_ptr<Value> value(reader.JsonToValue(preference.value(), false, false));
if (!value.get()) {
- LOG(ERROR) << "Failed to deserialize preference value: "
- << reader.GetErrorMessage();
- error_handler()->OnUnrecoverableError();
+ std::string err = "Failed to deserialize preference value: " +
+ reader.GetErrorMessage();
+ error_handler()->OnUnrecoverableError(FROM_HERE, err);
return NULL;
}
*name = UTF8ToWide(preference.name());
diff --git a/chrome/browser/sync/glue/preference_change_processor.h b/chrome/browser/sync/glue/preference_change_processor.h
index 4820b33..10f16bcb 100644
--- a/chrome/browser/sync/glue/preference_change_processor.h
+++ b/chrome/browser/sync/glue/preference_change_processor.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SYNC_GLUE_PREFERENCE_CHANGE_PROCESSOR_H_
#define CHROME_BROWSER_SYNC_GLUE_PREFERENCE_CHANGE_PROCESSOR_H_
+#include <string>
+
#include "base/scoped_ptr.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/sync/engine/syncapi.h"
diff --git a/chrome/browser/sync/glue/preference_data_type_controller.cc b/chrome/browser/sync/glue/preference_data_type_controller.cc
index 463e5a5..03c4beb 100644
--- a/chrome/browser/sync/glue/preference_data_type_controller.cc
+++ b/chrome/browser/sync/glue/preference_data_type_controller.cc
@@ -85,10 +85,12 @@ void PreferenceDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
-void PreferenceDataTypeController::OnUnrecoverableError() {
+void PreferenceDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
UMA_HISTOGRAM_COUNTS("Sync.PreferenceRunFailures", 1);
- sync_service_->OnUnrecoverableError();
+ sync_service_->OnUnrecoverableError(from_here, message);
}
void PreferenceDataTypeController::FinishStart(StartResult result) {
diff --git a/chrome/browser/sync/glue/preference_data_type_controller.h b/chrome/browser/sync/glue/preference_data_type_controller.h
index a433b4b..d38bf36 100644
--- a/chrome/browser/sync/glue/preference_data_type_controller.h
+++ b/chrome/browser/sync/glue/preference_data_type_controller.h
@@ -50,7 +50,8 @@ class PreferenceDataTypeController : public DataTypeController {
}
// UnrecoverableErrorHandler interface.
- virtual void OnUnrecoverableError();
+ virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
+ const std::string& message);
private:
// Helper method to run the stashed start callback with a given result.
diff --git a/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc b/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc
index a003516..74b1a4b 100644
--- a/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
+#include "base/tracked_objects.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/sync/glue/preference_data_type_controller.h"
#include "chrome/browser/sync/glue/change_processor_mock.h"
@@ -21,7 +22,7 @@ using browser_sync::DataTypeController;
using browser_sync::ModelAssociatorMock;
using testing::_;
using testing::DoAll;
-using testing::Invoke;
+using testing::InvokeWithoutArgs;
using testing::Return;
using testing::SetArgumentPointee;
@@ -159,13 +160,13 @@ TEST_F(PreferenceDataTypeControllerTest, OnUnrecoverableError) {
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(service_, OnUnrecoverableError()).
- WillOnce(Invoke(preference_dtc_.get(),
- &PreferenceDataTypeController::Stop));
+ EXPECT_CALL(service_, OnUnrecoverableError(_,_)).
+ WillOnce(InvokeWithoutArgs(preference_dtc_.get(),
+ &PreferenceDataTypeController::Stop));
SetStopExpectations();
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
preference_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
// This should cause preference_dtc_->Stop() to be called.
- preference_dtc_->OnUnrecoverableError();
+ preference_dtc_->OnUnrecoverableError(FROM_HERE, "Test");
}
diff --git a/chrome/browser/sync/glue/preference_model_associator.cc b/chrome/browser/sync/glue/preference_model_associator.cc
index dcb7f32..03794a3 100644
--- a/chrome/browser/sync/glue/preference_model_associator.cc
+++ b/chrome/browser/sync/glue/preference_model_associator.cc
@@ -20,10 +20,8 @@
namespace browser_sync {
PreferenceModelAssociator::PreferenceModelAssociator(
- ProfileSyncService* sync_service,
- UnrecoverableErrorHandler* error_handler)
+ ProfileSyncService* sync_service)
: sync_service_(sync_service),
- error_handler_(error_handler),
preferences_node_id_(sync_api::kInvalidId) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(sync_service_);
diff --git a/chrome/browser/sync/glue/preference_model_associator.h b/chrome/browser/sync/glue/preference_model_associator.h
index a449b3c..89f2fb9 100644
--- a/chrome/browser/sync/glue/preference_model_associator.h
+++ b/chrome/browser/sync/glue/preference_model_associator.h
@@ -30,8 +30,7 @@ class PreferenceModelAssociator
std::wstring> {
public:
static syncable::ModelType model_type() { return syncable::PREFERENCES; }
- PreferenceModelAssociator(ProfileSyncService* sync_service,
- UnrecoverableErrorHandler* error_handler);
+ PreferenceModelAssociator(ProfileSyncService* sync_service);
virtual ~PreferenceModelAssociator();
// Returns the list of preference names that should be monitored for
@@ -87,7 +86,6 @@ class PreferenceModelAssociator
// |sync_id| with that node's id.
virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id);
- protected:
// Returns sync service instance.
ProfileSyncService* sync_service() { return sync_service_; }
@@ -96,7 +94,6 @@ class PreferenceModelAssociator
typedef std::map<int64, std::wstring> SyncIdToPreferenceNameMap;
ProfileSyncService* sync_service_;
- UnrecoverableErrorHandler* error_handler_;
std::set<std::wstring> synced_preferences_;
int64 preferences_node_id_;
diff --git a/chrome/browser/sync/glue/theme_change_processor.cc b/chrome/browser/sync/glue/theme_change_processor.cc
index ec61f65..c44dbb1 100644
--- a/chrome/browser/sync/glue/theme_change_processor.cc
+++ b/chrome/browser/sync/glue/theme_change_processor.cc
@@ -112,9 +112,9 @@ void ThemeChangeProcessor::Observe(NotificationType type,
sync_api::WriteNode node(&trans);
if (!node.InitByClientTagLookup(syncable::THEMES,
kCurrentThemeClientTag)) {
- LOG(ERROR) << "Could not create node with client tag: "
- << kCurrentThemeClientTag;
- error_handler()->OnUnrecoverableError();
+ std::string err = "Could not create node with client tag: ";
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ err + kCurrentThemeClientTag);
return;
}
@@ -144,8 +144,9 @@ void ThemeChangeProcessor::ApplyChangesFromSyncModel(
// we can remove the extra logic below. See:
// http://code.google.com/p/chromium/issues/detail?id=41696 .
if (change_count < 1) {
- LOG(ERROR) << "Unexpected change_count: " << change_count;
- error_handler()->OnUnrecoverableError();
+ std::string err("Unexpected change_count: ");
+ err += change_count;
+ error_handler()->OnUnrecoverableError(FROM_HERE, err);
return;
}
if (change_count > 1) {
@@ -155,7 +156,8 @@ void ThemeChangeProcessor::ApplyChangesFromSyncModel(
const sync_api::SyncManager::ChangeRecord& change =
changes[change_count - 1];
if (change.action != sync_api::SyncManager::ChangeRecord::ACTION_UPDATE) {
- LOG(WARNING) << "strange theme change.action: " << change.action;
+ std::string err = "strange theme change.action " + change.action;
+ error_handler()->OnUnrecoverableError(FROM_HERE, err);
}
sync_pb::ThemeSpecifics theme_specifics;
// If the action is a delete, simply use the default values for
@@ -163,8 +165,8 @@ void ThemeChangeProcessor::ApplyChangesFromSyncModel(
if (change.action != sync_api::SyncManager::ChangeRecord::ACTION_DELETE) {
sync_api::ReadNode node(trans);
if (!node.InitByIdLookup(change.id)) {
- LOG(ERROR) << "Theme node lookup failed";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Theme node lookup failed.");
return;
}
DCHECK_EQ(node.GetModelType(), syncable::THEMES);
diff --git a/chrome/browser/sync/glue/theme_data_type_controller.cc b/chrome/browser/sync/glue/theme_data_type_controller.cc
index d789289..c99bc7f 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.cc
+++ b/chrome/browser/sync/glue/theme_data_type_controller.cc
@@ -85,10 +85,12 @@ void ThemeDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
-void ThemeDataTypeController::OnUnrecoverableError() {
+void ThemeDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
UMA_HISTOGRAM_COUNTS("Sync.ThemeRunFailures", 1);
- sync_service_->OnUnrecoverableError();
+ sync_service_->OnUnrecoverableError(from_here, message);
}
void ThemeDataTypeController::FinishStart(StartResult result) {
diff --git a/chrome/browser/sync/glue/theme_data_type_controller.h b/chrome/browser/sync/glue/theme_data_type_controller.h
index b5eed10..a808290 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.h
+++ b/chrome/browser/sync/glue/theme_data_type_controller.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SYNC_GLUE_THEME_DATA_TYPE_CONTROLLER_H_
#define CHROME_BROWSER_SYNC_GLUE_THEME_DATA_TYPE_CONTROLLER_H_
+#include <string>
+
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
@@ -53,7 +55,9 @@ class ThemeDataTypeController : public DataTypeController {
}
// UnrecoverableErrorHandler interface.
- virtual void OnUnrecoverableError();
+ virtual void OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message);
private:
// Helper method to run the stashed start callback with a given result.
diff --git a/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc b/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc
index 29b6cb7..73496b3 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc
@@ -22,7 +22,7 @@ using browser_sync::DataTypeController;
using browser_sync::ModelAssociatorMock;
using testing::_;
using testing::DoAll;
-using testing::Invoke;
+using testing::InvokeWithoutArgs;
using testing::Return;
using testing::SetArgumentPointee;
@@ -162,12 +162,13 @@ TEST_F(ThemeDataTypeControllerTest, OnUnrecoverableError) {
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(service_, OnUnrecoverableError()).
- WillOnce(Invoke(theme_dtc_.get(), &ThemeDataTypeController::Stop));
+ EXPECT_CALL(service_, OnUnrecoverableError(_,_)).
+ WillOnce(InvokeWithoutArgs(theme_dtc_.get(),
+ &ThemeDataTypeController::Stop));
SetStopExpectations();
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
theme_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
// This should cause theme_dtc_->Stop() to be called.
- theme_dtc_->OnUnrecoverableError();
+ theme_dtc_->OnUnrecoverableError(FROM_HERE, "Test");
}
diff --git a/chrome/browser/sync/glue/theme_model_associator.cc b/chrome/browser/sync/glue/theme_model_associator.cc
index 4681063..c50ceb2 100644
--- a/chrome/browser/sync/glue/theme_model_associator.cc
+++ b/chrome/browser/sync/glue/theme_model_associator.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/sync/glue/theme_util.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/protocol/theme_specifics.pb.h"
-#include "chrome/browser/sync/unrecoverable_error_handler.h"
namespace browser_sync {
@@ -29,12 +28,9 @@ static const char kNoThemesFolderError[] =
} // namespace
ThemeModelAssociator::ThemeModelAssociator(
- ProfileSyncService* sync_service,
- UnrecoverableErrorHandler* error_handler)
- : sync_service_(sync_service),
- error_handler_(error_handler) {
+ ProfileSyncService* sync_service)
+ : sync_service_(sync_service) {
DCHECK(sync_service_);
- DCHECK(error_handler_);
}
ThemeModelAssociator::~ThemeModelAssociator() {}
diff --git a/chrome/browser/sync/glue/theme_model_associator.h b/chrome/browser/sync/glue/theme_model_associator.h
index cb0ae6d..ff0cac9 100644
--- a/chrome/browser/sync/glue/theme_model_associator.h
+++ b/chrome/browser/sync/glue/theme_model_associator.h
@@ -19,8 +19,7 @@ class UnrecoverableErrorHandler;
// sync themes model.
class ThemeModelAssociator : public AssociatorInterface {
public:
- ThemeModelAssociator(ProfileSyncService* sync_service,
- UnrecoverableErrorHandler* error_handler);
+ ThemeModelAssociator(ProfileSyncService* sync_service);
virtual ~ThemeModelAssociator();
// Used by profile_sync_test_util.h.
@@ -38,7 +37,6 @@ class ThemeModelAssociator : public AssociatorInterface {
private:
ProfileSyncService* sync_service_;
- UnrecoverableErrorHandler* error_handler_;
DISALLOW_COPY_AND_ASSIGN(ThemeModelAssociator);
};
diff --git a/chrome/browser/sync/glue/typed_url_change_processor.cc b/chrome/browser/sync/glue/typed_url_change_processor.cc
index e659f23..e033b34 100644
--- a/chrome/browser/sync/glue/typed_url_change_processor.cc
+++ b/chrome/browser/sync/glue/typed_url_change_processor.cc
@@ -70,8 +70,8 @@ void TypedUrlChangeProcessor::HandleURLsModified(
++url) {
if (!history_backend_->GetVisitsForURL(url->id(),
&(visit_vectors[url->id()]))) {
- error_handler()->OnUnrecoverableError();
- LOG(ERROR) << "Could not get the url's visits.";
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Could not get the url's visits.");
return;
}
DCHECK(!visit_vectors[url->id()].empty());
@@ -81,9 +81,9 @@ void TypedUrlChangeProcessor::HandleURLsModified(
sync_api::ReadNode typed_url_root(&trans);
if (!typed_url_root.InitByTagLookup(kTypedUrlTag)) {
- error_handler()->OnUnrecoverableError();
- LOG(ERROR) << "Server did not create the top-level typed_url node. We "
- << "might be running against an out-of-date server.";
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Server did not create the top-level typed_url node. We "
+ "might be running against an out-of-date server.");
return;
}
@@ -98,8 +98,8 @@ void TypedUrlChangeProcessor::HandleURLsModified(
DCHECK(static_cast<size_t>(url->visit_count()) == visits.size());
if (static_cast<size_t>(url->visit_count()) != visits.size()) {
- error_handler()->OnUnrecoverableError();
- LOG(ERROR) << "Visit count does not match.";
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Visit count does not match.");
return;
}
@@ -110,8 +110,8 @@ void TypedUrlChangeProcessor::HandleURLsModified(
sync_api::WriteNode create_node(&trans);
if (!create_node.InitUniqueByCreation(syncable::TYPED_URLS,
typed_url_root, tag)) {
- LOG(ERROR) << "Failed to create typed_url sync node.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Failed to create typed_url sync node.");
return;
}
@@ -129,7 +129,7 @@ void TypedUrlChangeProcessor::HandleURLsDeleted(
if (details->all_history) {
if (!model_associator_->DeleteAllNodes(&trans)) {
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE, std::string());
return;
}
} else {
@@ -140,8 +140,8 @@ void TypedUrlChangeProcessor::HandleURLsDeleted(
model_associator_->GetSyncIdFromChromeId(url->spec());
if (sync_api::kInvalidId != sync_id) {
if (!sync_node.InitByIdLookup(sync_id)) {
- LOG(ERROR) << "Typed url node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Typed url node lookup failed.");
return;
}
model_associator_->Disassociate(sync_node.GetId());
@@ -160,8 +160,8 @@ void TypedUrlChangeProcessor::HandleURLsVisited(
history::VisitVector visits;
if (!history_backend_->GetVisitsForURL(details->row.id(), &visits) ||
visits.empty()) {
- error_handler()->OnUnrecoverableError();
- LOG(ERROR) << "Could not get the url's visits.";
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Could not get the url's visits.");
return;
}
@@ -190,8 +190,8 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel(
sync_api::ReadNode typed_url_root(trans);
if (!typed_url_root.InitByTagLookup(kTypedUrlTag)) {
- LOG(ERROR) << "TypedUrl root node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "TypedUrl root node lookup failed.");
return;
}
@@ -205,8 +205,8 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel(
sync_api::ReadNode sync_node(trans);
if (!sync_node.InitByIdLookup(changes[i].id)) {
- LOG(ERROR) << "TypedUrl node lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "TypedUrl node lookup failed.");
return;
}
@@ -255,15 +255,15 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel(
} else {
history::URLRow old_url;
if (!history_backend_->GetURL(url, &old_url)) {
- LOG(ERROR) << "TypedUrl db lookup failed.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "TypedUrl db lookup failed.");
return;
}
history::VisitVector visits;
if (!history_backend_->GetVisitsForURL(old_url.id(), &visits)) {
- LOG(ERROR) << "Could not get the url's visits.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Could not get the url's visits.");
return;
}
@@ -299,8 +299,8 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel(
if (!model_associator_->WriteToHistoryBackend(&titles, &new_urls,
&updated_urls,
&new_visits, &deleted_visits)) {
- LOG(ERROR) << "Could not write to the history backend.";
- error_handler()->OnUnrecoverableError();
+ error_handler()->OnUnrecoverableError(FROM_HERE,
+ "Could not write to the history backend.");
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 3d97107..732dbce 100644
--- a/chrome/browser/sync/glue/typed_url_data_type_controller.cc
+++ b/chrome/browser/sync/glue/typed_url_data_type_controller.cc
@@ -188,17 +188,22 @@ void TypedUrlDataTypeController::StartFailed(StartResult result) {
StartDone(result, NOT_RUNNING);
}
-void TypedUrlDataTypeController::OnUnrecoverableError() {
+void TypedUrlDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(this,
- &TypedUrlDataTypeController::OnUnrecoverableErrorImpl));
+ &TypedUrlDataTypeController::OnUnrecoverableErrorImpl,
+ from_here, message));
}
-void TypedUrlDataTypeController::OnUnrecoverableErrorImpl() {
+void TypedUrlDataTypeController::OnUnrecoverableErrorImpl(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
UMA_HISTOGRAM_COUNTS("Sync.TypedUrlRunFailures", 1);
- sync_service_->OnUnrecoverableError();
+ sync_service_->OnUnrecoverableError(from_here, message);
}
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/typed_url_data_type_controller.h b/chrome/browser/sync/glue/typed_url_data_type_controller.h
index edfba68..e8b3a31 100644
--- a/chrome/browser/sync/glue/typed_url_data_type_controller.h
+++ b/chrome/browser/sync/glue/typed_url_data_type_controller.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__
#define CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__
+#include <string>
+
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/cancelable_request.h"
@@ -64,7 +66,8 @@ class TypedUrlDataTypeController : public DataTypeController,
}
// UnrecoverableHandler implementation
- virtual void OnUnrecoverableError();
+ virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
+ const std::string& message);
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
@@ -84,7 +87,8 @@ class TypedUrlDataTypeController : public DataTypeController,
void StartDoneImpl(StartResult result, State state);
void StopImpl();
void StartFailed(StartResult result);
- void OnUnrecoverableErrorImpl();
+ void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here,
+ const std::string& message);
void set_state(State state) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
diff --git a/chrome/browser/sync/glue/typed_url_model_associator.cc b/chrome/browser/sync/glue/typed_url_model_associator.cc
index b5f60f1..0c9ff62 100644
--- a/chrome/browser/sync/glue/typed_url_model_associator.cc
+++ b/chrome/browser/sync/glue/typed_url_model_associator.cc
@@ -19,16 +19,13 @@ const char kTypedUrlTag[] = "google_chrome_typed_urls";
TypedUrlModelAssociator::TypedUrlModelAssociator(
ProfileSyncService* sync_service,
- history::HistoryBackend* history_backend,
- UnrecoverableErrorHandler* error_handler)
+ history::HistoryBackend* history_backend)
: sync_service_(sync_service),
history_backend_(history_backend),
- error_handler_(error_handler),
typed_url_node_id_(sync_api::kInvalidId),
expected_loop_(MessageLoop::current()) {
DCHECK(sync_service_);
DCHECK(history_backend_);
- DCHECK(error_handler_);
DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::UI));
}
diff --git a/chrome/browser/sync/glue/typed_url_model_associator.h b/chrome/browser/sync/glue/typed_url_model_associator.h
index 5aea994..9aad390 100644
--- a/chrome/browser/sync/glue/typed_url_model_associator.h
+++ b/chrome/browser/sync/glue/typed_url_model_associator.h
@@ -56,8 +56,7 @@ class TypedUrlModelAssociator
static syncable::ModelType model_type() { return syncable::TYPED_URLS; }
TypedUrlModelAssociator(ProfileSyncService* sync_service,
- history::HistoryBackend* history_backend,
- UnrecoverableErrorHandler* error_handler);
+ history::HistoryBackend* history_backend);
virtual ~TypedUrlModelAssociator() { }
// PerDataTypeAssociatorInterface implementation.
@@ -146,7 +145,6 @@ class TypedUrlModelAssociator
ProfileSyncService* sync_service_;
history::HistoryBackend* history_backend_;
- UnrecoverableErrorHandler* error_handler_;
int64 typed_url_node_id_;
MessageLoop* expected_loop_;
diff --git a/chrome/browser/sync/profile_sync_factory_impl.cc b/chrome/browser/sync/profile_sync_factory_impl.cc
index e7b5e57..0c75936 100644
--- a/chrome/browser/sync/profile_sync_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_factory_impl.cc
@@ -133,8 +133,7 @@ ProfileSyncFactoryImpl::CreateAutofillSyncComponents(
AutofillModelAssociator* model_associator =
new AutofillModelAssociator(profile_sync_service,
web_database,
- personal_data,
- error_handler);
+ personal_data);
AutofillChangeProcessor* change_processor =
new AutofillChangeProcessor(model_associator,
web_database,
@@ -163,8 +162,7 @@ ProfileSyncFactoryImpl::CreatePasswordSyncComponents(
UnrecoverableErrorHandler* error_handler) {
PasswordModelAssociator* model_associator =
new PasswordModelAssociator(profile_sync_service,
- password_store,
- error_handler);
+ password_store);
PasswordChangeProcessor* change_processor =
new PasswordChangeProcessor(model_associator,
password_store,
@@ -177,8 +175,7 @@ ProfileSyncFactoryImpl::CreatePreferenceSyncComponents(
ProfileSyncService* profile_sync_service,
UnrecoverableErrorHandler* error_handler) {
PreferenceModelAssociator* model_associator =
- new PreferenceModelAssociator(profile_sync_service,
- error_handler);
+ new PreferenceModelAssociator(profile_sync_service);
PreferenceChangeProcessor* change_processor =
new PreferenceChangeProcessor(model_associator,
error_handler);
@@ -190,8 +187,7 @@ ProfileSyncFactoryImpl::CreateThemeSyncComponents(
ProfileSyncService* profile_sync_service,
UnrecoverableErrorHandler* error_handler) {
ThemeModelAssociator* model_associator =
- new ThemeModelAssociator(profile_sync_service,
- error_handler);
+ new ThemeModelAssociator(profile_sync_service);
ThemeChangeProcessor* change_processor =
new ThemeChangeProcessor(error_handler);
return SyncComponents(model_associator, change_processor);
@@ -204,8 +200,7 @@ ProfileSyncFactoryImpl::CreateTypedUrlSyncComponents(
browser_sync::UnrecoverableErrorHandler* error_handler) {
TypedUrlModelAssociator* model_associator =
new TypedUrlModelAssociator(profile_sync_service,
- history_backend,
- error_handler);
+ history_backend);
TypedUrlChangeProcessor* change_processor =
new TypedUrlChangeProcessor(model_associator,
history_backend,
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index e6cd161..2820805 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -400,10 +400,15 @@ const wchar_t* ProfileSyncService::GetPrefNameForDataType(
// An invariant has been violated. Transition to an error state where we try
// to do as little work as possible, to avoid further corruption or crashes.
-void ProfileSyncService::OnUnrecoverableError() {
+void ProfileSyncService::OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
unrecoverable_error_detected_ = true;
- // TODO(sync) remove this unrecoverable_error_detected_ variable_ as it only
- // affects ShouldPushChanges().
+ unrecoverable_error_message_ = message;
+ unrecoverable_error_location_.reset(
+ new tracked_objects::Location(from_here.function_name(),
+ from_here.file_name(),
+ from_here.line_number()));
// Shut all data types down.
if (data_type_manager_.get())
@@ -414,6 +419,9 @@ void ProfileSyncService::OnUnrecoverableError() {
FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable.";
+ std::string location;
+ from_here.Write(true, true, &location);
+ LOG(ERROR) << location;
if (WizardIsVisible()) {
// We've hit an error in the middle of a startup process- shutdown all the
@@ -678,7 +686,7 @@ void ProfileSyncService::Observe(NotificationType type,
DataTypeManager::ConfigureResult result =
*(Details<DataTypeManager::ConfigureResult>(details).ptr());
if (result != DataTypeManager::OK) {
- OnUnrecoverableError();
+ OnUnrecoverableError(FROM_HERE, "Sync Configuration failed.");
return;
}
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 2054675..9d97e4d 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -205,6 +205,13 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
bool unrecoverable_error_detected() const {
return unrecoverable_error_detected_;
}
+ const std::string& unrecoverable_error_message() {
+ return unrecoverable_error_message_;
+ }
+ tracked_objects::Location unrecoverable_error_location() {
+ return unrecoverable_error_location_.get() ?
+ *unrecoverable_error_location_.get() : tracked_objects::Location();
+ }
bool UIShouldDepictAuthInProgress() const {
return is_auth_in_progress_;
@@ -246,7 +253,9 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
static bool IsSyncEnabled();
// UnrecoverableErrorHandler implementation.
- virtual void OnUnrecoverableError();
+ virtual void OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message);
browser_sync::SyncBackendHost* backend() { return backend_.get(); }
@@ -406,6 +415,10 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// doing any work that might corrupt things further.
bool unrecoverable_error_detected_;
+ // A message sent when an unrecoverable error occurred.
+ std::string unrecoverable_error_message_;
+ scoped_ptr<tracked_objects::Location> unrecoverable_error_location_;
+
// Which peer-to-peer notification method to use.
browser_sync::NotificationMethod notification_method_;
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index 3183d31..4ca8e6e 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -122,7 +122,7 @@ class PersonalDataManagerMock: public PersonalDataManager {
ACTION_P4(MakeAutofillSyncComponents, service, wd, pdm, dtc) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
AutofillModelAssociator* model_associator =
- new AutofillModelAssociator(service, wd, pdm, dtc);
+ new AutofillModelAssociator(service, wd, pdm);
AutofillChangeProcessor* change_processor =
new AutofillChangeProcessor(model_associator, wd, pdm, dtc);
return ProfileSyncFactory::SyncComponents(model_associator,
diff --git a/chrome/browser/sync/profile_sync_service_mock.h b/chrome/browser/sync/profile_sync_service_mock.h
index 539c275..75fa615 100644
--- a/chrome/browser/sync/profile_sync_service_mock.h
+++ b/chrome/browser/sync/profile_sync_service_mock.h
@@ -31,7 +31,9 @@ class ProfileSyncServiceMock : public ProfileSyncService {
MOCK_METHOD0(OnUserAcceptedMergeAndSync, void());
MOCK_METHOD0(OnUserCancelledDialog, void());
MOCK_CONST_METHOD0(GetAuthenticatedUsername, string16());
- MOCK_METHOD0(OnUnrecoverableError, void());
+ MOCK_METHOD2(OnUnrecoverableError,
+ void(const tracked_objects::Location& location,
+ const std::string& message));
MOCK_METHOD2(ActivateDataType,
void(browser_sync::DataTypeController* data_type_controller,
browser_sync::ChangeProcessor* change_processor));
diff --git a/chrome/browser/sync/profile_sync_service_password_unittest.cc b/chrome/browser/sync/profile_sync_service_password_unittest.cc
index 4038f8e..969b201 100644
--- a/chrome/browser/sync/profile_sync_service_password_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_password_unittest.cc
@@ -71,7 +71,7 @@ using webkit_glue::PasswordForm;
ACTION_P3(MakePasswordSyncComponents, service, ps, dtc) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
PasswordModelAssociator* model_associator =
- new PasswordModelAssociator(service, ps, dtc);
+ new PasswordModelAssociator(service, ps);
PasswordChangeProcessor* change_processor =
new PasswordChangeProcessor(model_associator, ps, dtc);
return ProfileSyncFactory::SyncComponents(model_associator,
diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
index 3b0f68d..79a1c6b 100644
--- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
@@ -29,6 +29,19 @@ using sync_api::SyncManager;
using testing::_;
using testing::Return;
+class TestPreferenceModelAssociator : public PreferenceModelAssociator {
+ public:
+ TestPreferenceModelAssociator(ProfileSyncService* service)
+ : PreferenceModelAssociator(service),
+ helper_(new TestModelAssociatorHelper()) {
+ }
+ virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id) {
+ return helper_->GetSyncIdForTaggedNode(this, tag, sync_id);
+ }
+ private:
+ scoped_ptr<TestModelAssociatorHelper> helper_;
+};
+
class ProfileSyncServicePreferenceTest : public testing::Test {
protected:
ProfileSyncServicePreferenceTest()
@@ -54,9 +67,7 @@ class ProfileSyncServicePreferenceTest : public testing::Test {
true));
// Register the preference data type.
- model_associator_ =
- new TestModelAssociator<PreferenceModelAssociator>(service_.get(),
- service_.get());
+ model_associator_ = new TestPreferenceModelAssociator(service_.get());
change_processor_ = new PreferenceChangeProcessor(model_associator_,
service_.get());
EXPECT_CALL(factory_, CreatePreferenceSyncComponents(_, _)).
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
index 6194c6a..cfe1642 100644
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
@@ -115,7 +115,7 @@ ACTION_P2(RunTaskOnDBThread, thread, backend) {
ACTION_P3(MakeTypedUrlSyncComponents, service, hb, dtc) {
TypedUrlModelAssociator* model_associator =
- new TypedUrlModelAssociator(service, hb, dtc);
+ new TypedUrlModelAssociator(service, hb);
TypedUrlChangeProcessor* change_processor =
new TypedUrlChangeProcessor(model_associator, hb, service);
return ProfileSyncFactory::SyncComponents(model_associator, change_processor);
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index c00b8a6..bcc6be7 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -41,15 +41,22 @@ using browser_sync::DataTypeController;
using browser_sync::ModelAssociator;
using browser_sync::SyncBackendHost;
using browser_sync::SyncBackendHostMock;
+using browser_sync::UnrecoverableErrorHandler;
using testing::_;
using testing::Return;
-class TestBookmarkModelAssociator :
- public TestModelAssociator<BookmarkModelAssociator> {
+class TestBookmarkModelAssociator : public BookmarkModelAssociator {
public:
- explicit TestBookmarkModelAssociator(ProfileSyncService* service)
- : TestModelAssociator<BookmarkModelAssociator>(service, service) {
+ TestBookmarkModelAssociator(ProfileSyncService* service,
+ UnrecoverableErrorHandler* persist_ids_error_handler)
+ : BookmarkModelAssociator(service, persist_ids_error_handler),
+ helper_(new TestModelAssociatorHelper()) {
}
+ virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id) {
+ return helper_->GetSyncIdForTaggedNode(this, tag, sync_id);
+ }
+ private:
+ scoped_ptr<TestModelAssociatorHelper> helper_;
};
// FakeServerChange constructs a list of sync_api::ChangeRecords while modifying
@@ -235,7 +242,8 @@ class ProfileSyncServiceTest : public testing::Test {
false, true));
// Register the bookmark data type.
- model_associator_ = new TestBookmarkModelAssociator(service_.get());
+ model_associator_ = new TestBookmarkModelAssociator(service_.get(),
+ service_.get());
change_processor_ = new BookmarkChangeProcessor(model_associator_,
service_.get());
EXPECT_CALL(factory_, CreateBookmarkSyncComponents(_, _)).
@@ -1337,7 +1345,8 @@ TEST_F(ProfileSyncServiceTestWithData, MAYBE_TestStartupWithOldSyncData) {
false, true));
profile_->GetPrefs()->SetBoolean(prefs::kSyncHasSetupCompleted, false);
- model_associator_ = new TestBookmarkModelAssociator(service_.get());
+ model_associator_ = new TestBookmarkModelAssociator(service_.get(),
+ service_.get());
change_processor_ = new BookmarkChangeProcessor(model_associator_,
service_.get());
EXPECT_CALL(factory_, CreateBookmarkSyncComponents(_, _)).
diff --git a/chrome/browser/sync/profile_sync_test_util.h b/chrome/browser/sync/profile_sync_test_util.h
index 4dbc1cc..c1b0caa 100644
--- a/chrome/browser/sync/profile_sync_test_util.h
+++ b/chrome/browser/sync/profile_sync_test_util.h
@@ -58,16 +58,11 @@ ACTION_P(InvokeTask, task) {
task->Run();
}
-template <class ModelAssociatorImpl>
-class TestModelAssociator : public ModelAssociatorImpl {
+class TestModelAssociatorHelper {
public:
- explicit TestModelAssociator(
- ProfileSyncService* service,
- browser_sync::UnrecoverableErrorHandler* error_handler)
- : ModelAssociatorImpl(service, error_handler) {
- }
-
- virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id) {
+ template <class ModelAssociatorImpl>
+ bool GetSyncIdForTaggedNode(ModelAssociatorImpl* associator,
+ const std::string& tag, int64* sync_id) {
std::wstring tag_wide;
if (!UTF8ToWide(tag.c_str(), tag.length(), &tag_wide)) {
NOTREACHED() << "Unable to convert UTF8 to wide for string: " << tag;
@@ -75,7 +70,7 @@ class TestModelAssociator : public ModelAssociatorImpl {
}
sync_api::WriteTransaction trans(
- ModelAssociatorImpl::sync_service()->backend()->GetUserShareHandle());
+ associator->sync_service()->backend()->GetUserShareHandle());
sync_api::ReadNode root(&trans);
root.InitByRootLookup();
@@ -110,7 +105,7 @@ class TestModelAssociator : public ModelAssociatorImpl {
return true;
}
- ~TestModelAssociator() {}
+ ~TestModelAssociatorHelper() {}
};
class ProfileSyncServiceObserverMock : public ProfileSyncServiceObserver {
diff --git a/chrome/browser/sync/unrecoverable_error_handler.h b/chrome/browser/sync/unrecoverable_error_handler.h
index 2bad8c5..d8950e6 100644
--- a/chrome/browser/sync/unrecoverable_error_handler.h
+++ b/chrome/browser/sync/unrecoverable_error_handler.h
@@ -5,6 +5,10 @@
#ifndef CHROME_BROWSER_SYNC_UNRECOVERABLE_ERROR_HANDLER_H_
#define CHROME_BROWSER_SYNC_UNRECOVERABLE_ERROR_HANDLER_H_
+#include <string>
+
+#include "base/tracked.h"
+
namespace browser_sync {
class UnrecoverableErrorHandler {
@@ -13,7 +17,8 @@ class UnrecoverableErrorHandler {
// syncer model are inconsistent, or similar. The ProfileSyncService will
// try to avoid doing any work to avoid crashing or corrupting things
// further, and will report an error status if queried.
- virtual void OnUnrecoverableError() = 0;
+ virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
+ const std::string& message) = 0;
protected:
virtual ~UnrecoverableErrorHandler() { }
};