summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authorlipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-21 23:06:02 +0000
committerlipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-21 23:06:02 +0000
commit57e57da99cbee4f2e6c54a95c385dcce23862b96 (patch)
tree376d434a67ead0bee8549c59b9475ab69e1ec7e2 /chrome/browser/sync
parent45ff15ab82140071d8689a63b2fde2164c13c743 (diff)
downloadchromium_src-57e57da99cbee4f2e6c54a95c385dcce23862b96.zip
chromium_src-57e57da99cbee4f2e6c54a95c385dcce23862b96.tar.gz
chromium_src-57e57da99cbee4f2e6c54a95c385dcce23862b96.tar.bz2
This is the second patch in the set. This propagates the unrecoverable error handler from PSS to directory.
BUG=100444 TEST=sync_integration_tests.exe, sync_unit_tests.exe, unit_tests.exe, manual tests Review URL: http://codereview.chromium.org/8799023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rwxr-xr-xchrome/browser/sync/backend_unrecoverable_error_handler.cc30
-rwxr-xr-xchrome/browser/sync/backend_unrecoverable_error_handler.h33
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc15
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h9
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_unittest.cc5
-rw-r--r--chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h1
-rwxr-xr-xchrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.cc10
-rwxr-xr-xchrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h28
-rw-r--r--chrome/browser/sync/internal_api/sync_manager.cc19
-rw-r--r--chrome/browser/sync/internal_api/sync_manager.h5
-rw-r--r--chrome/browser/sync/internal_api/syncapi_unittest.cc5
-rw-r--r--chrome/browser/sync/profile_sync_service.cc7
-rw-r--r--chrome/browser/sync/profile_sync_service.h4
-rw-r--r--chrome/browser/sync/syncable/DEPS2
-rw-r--r--chrome/browser/sync/syncable/directory_manager.cc6
-rw-r--r--chrome/browser/sync/syncable/directory_manager.h5
-rw-r--r--chrome/browser/sync/syncable/syncable.cc10
-rw-r--r--chrome/browser/sync/syncable/syncable.h8
-rw-r--r--chrome/browser/sync/syncable/syncable_mock.cc2
-rw-r--r--chrome/browser/sync/syncable/syncable_mock.h2
-rw-r--r--chrome/browser/sync/syncable/syncable_unittest.cc56
-rw-r--r--chrome/browser/sync/test/engine/test_directory_setter_upper.cc12
-rw-r--r--chrome/browser/sync/test/engine/test_directory_setter_upper.h5
23 files changed, 237 insertions, 42 deletions
diff --git a/chrome/browser/sync/backend_unrecoverable_error_handler.cc b/chrome/browser/sync/backend_unrecoverable_error_handler.cc
new file mode 100755
index 0000000..395505e
--- /dev/null
+++ b/chrome/browser/sync/backend_unrecoverable_error_handler.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/callback.h"
+
+#include "chrome/browser/sync/backend_unrecoverable_error_handler.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+
+using content::BrowserThread;
+
+namespace browser_sync {
+
+BackendUnrecoverableErrorHandler::BackendUnrecoverableErrorHandler(
+ const WeakHandle<ProfileSyncService>& service) : service_(service) {
+}
+
+BackendUnrecoverableErrorHandler::~BackendUnrecoverableErrorHandler() {
+}
+
+void BackendUnrecoverableErrorHandler::OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
+ service_.Call(FROM_HERE,
+ &ProfileSyncService::OnUnrecoverableError,
+ from_here,
+ message);
+}
+
+} // namespace browser_sync
diff --git a/chrome/browser/sync/backend_unrecoverable_error_handler.h b/chrome/browser/sync/backend_unrecoverable_error_handler.h
new file mode 100755
index 0000000..d03426c
--- /dev/null
+++ b/chrome/browser/sync/backend_unrecoverable_error_handler.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SYNC_BACKEND_UNRECOVERABLE_ERROR_HANDLER_H_
+#define CHROME_BROWSER_SYNC_BACKEND_UNRECOVERABLE_ERROR_HANDLER_H_
+#pragma once
+
+#include <string>
+
+#include "base/location.h"
+#include "base/memory/weak_ptr.h"
+
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h"
+#include "chrome/browser/sync/util/weak_handle.h"
+
+class ProfileSyncService;
+namespace browser_sync {
+
+class BackendUnrecoverableErrorHandler : public UnrecoverableErrorHandler {
+ public:
+ BackendUnrecoverableErrorHandler(
+ const WeakHandle<ProfileSyncService>& service);
+ virtual ~BackendUnrecoverableErrorHandler();
+ virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
+ const std::string& message) OVERRIDE;
+
+ private:
+ WeakHandle<ProfileSyncService> service_;
+};
+} // namespace browser_sync
+#endif // CHROME_BROWSER_SYNC_BACKEND_UNRECOVERABLE_ERROR_HANDLER_H_
+
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index bfc74cd..ab3e5f6 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -114,7 +114,8 @@ void SyncBackendHost::Initialize(
const GURL& sync_service_url,
syncable::ModelTypeSet initial_types,
const SyncCredentials& credentials,
- bool delete_sync_data_folder) {
+ bool delete_sync_data_folder,
+ UnrecoverableErrorHandler* unrecoverable_error_handler) {
if (!sync_thread_.Start())
return;
@@ -143,7 +144,8 @@ void SyncBackendHost::Initialize(
&sync_notifier_factory_,
delete_sync_data_folder,
sync_prefs_->GetEncryptionBootstrapToken(),
- false));
+ false,
+ unrecoverable_error_handler));
}
void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
@@ -532,7 +534,8 @@ SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
sync_notifier::SyncNotifierFactory* sync_notifier_factory,
bool delete_sync_data_folder,
const std::string& restored_key_for_bootstrapping,
- bool setup_for_test_mode)
+ bool setup_for_test_mode,
+ UnrecoverableErrorHandler* unrecoverable_error_handler)
: sync_loop(sync_loop),
registrar(registrar),
event_handler(event_handler),
@@ -542,7 +545,8 @@ SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
sync_notifier_factory(sync_notifier_factory),
delete_sync_data_folder(delete_sync_data_folder),
restored_key_for_bootstrapping(restored_key_for_bootstrapping),
- setup_for_test_mode(setup_for_test_mode) {
+ setup_for_test_mode(setup_for_test_mode),
+ unrecoverable_error_handler(unrecoverable_error_handler){
}
SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {}
@@ -762,7 +766,8 @@ void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) {
options.credentials,
options.sync_notifier_factory->CreateSyncNotifier(),
options.restored_key_for_bootstrapping,
- options.setup_for_test_mode);
+ options.setup_for_test_mode,
+ options.unrecoverable_error_handler);
LOG_IF(ERROR, !success) << "Syncapi initialization failed!";
}
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index 24e8dd6..e63c098 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -19,6 +19,7 @@
#include "base/threading/thread.h"
#include "base/timer.h"
#include "chrome/browser/sync/engine/model_safe_worker.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h"
#include "chrome/browser/sync/internal_api/configure_reason.h"
#include "chrome/browser/sync/internal_api/sync_manager.h"
#include "chrome/browser/sync/notifier/sync_notifier_factory.h"
@@ -154,12 +155,14 @@ class SyncBackendHost {
// As a fallback when no cached auth information is available, try to
// bootstrap authentication using |lsid|, if it isn't empty.
// Optionally delete the Sync Data folder (if it's corrupt).
+ // Note: |unrecoverable_error_handler| caould be invoked from any thread.
void Initialize(SyncFrontend* frontend,
const WeakHandle<JsEventHandler>& event_handler,
const GURL& service_url,
syncable::ModelTypeSet initial_types,
const sync_api::SyncCredentials& credentials,
- bool delete_sync_data_folder);
+ bool delete_sync_data_folder,
+ UnrecoverableErrorHandler* unrecoverable_error_handler);
// Called from |frontend_loop| to update SyncCredentials.
void UpdateCredentials(const sync_api::SyncCredentials& credentials);
@@ -270,7 +273,8 @@ class SyncBackendHost {
sync_notifier::SyncNotifierFactory* sync_notifier_factory,
bool delete_sync_data_folder,
const std::string& restored_key_for_bootstrapping,
- bool setup_for_test_mode);
+ bool setup_for_test_mode,
+ UnrecoverableErrorHandler* unrecoverable_error_handler);
~DoInitializeOptions();
MessageLoop* sync_loop;
@@ -285,6 +289,7 @@ class SyncBackendHost {
bool delete_sync_data_folder;
std::string restored_key_for_bootstrapping;
bool setup_for_test_mode;
+ UnrecoverableErrorHandler* unrecoverable_error_handler;
};
// Allows tests to perform alternate core initialization work.
diff --git a/chrome/browser/sync/glue/sync_backend_host_unittest.cc b/chrome/browser/sync/glue/sync_backend_host_unittest.cc
index 50963d1..242d2c4 100644
--- a/chrome/browser/sync/glue/sync_backend_host_unittest.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_unittest.cc
@@ -9,6 +9,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "chrome/browser/sync/engine/model_safe_worker.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h"
#include "chrome/browser/sync/protocol/sync_protocol_error.h"
#include "chrome/browser/sync/sync_prefs.h"
#include "chrome/browser/sync/syncable/model_type.h"
@@ -94,12 +95,14 @@ TEST_F(SyncBackendHostTest, InitShutdown) {
sync_api::SyncCredentials credentials;
credentials.email = "user@example.com";
credentials.sync_token = "sync_token";
+ browser_sync::MockUnrecoverableErrorHandler handler_mock;
backend.Initialize(&mock_frontend,
WeakHandle<JsEventHandler>(),
GURL(k_mock_url),
syncable::ModelTypeSet(),
credentials,
- true);
+ true,
+ &handler_mock);
backend.StopSyncingForShutdown();
backend.Shutdown(false);
}
diff --git a/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h b/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h
index 64cbeb3..bb43dd8c 100644
--- a/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h
+++ b/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h
@@ -27,3 +27,4 @@ class UnrecoverableErrorHandler {
}
#endif // CHROME_BROWSER_SYNC_INTERNAL_API_INCLUDES_UNRECOVERABLE_ERROR_HANDLER_H_
+
diff --git a/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.cc b/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.cc
new file mode 100755
index 0000000..9c144e25
--- /dev/null
+++ b/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.cc
@@ -0,0 +1,10 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h"
+
+namespace browser_sync {
+ MockUnrecoverableErrorHandler::MockUnrecoverableErrorHandler() {}
+ MockUnrecoverableErrorHandler::~MockUnrecoverableErrorHandler() {}
+} // namespace browser_sync
diff --git a/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h b/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h
new file mode 100755
index 0000000..77bdaf9
--- /dev/null
+++ b/chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SYNC_INTERNAL_API_INCLUDES_UNRECOVERABLE_ERROR_HANDLER_MOCK_H_
+#define CHROME_BROWSER_SYNC_INTERNAL_API_INCLUDES_UNRECOVERABLE_ERROR_HANDLER_MOCK_H_
+#pragma once
+#include <string>
+
+#include "base/location.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace browser_sync {
+class MockUnrecoverableErrorHandler : public UnrecoverableErrorHandler {
+ public:
+ MockUnrecoverableErrorHandler();
+ ~MockUnrecoverableErrorHandler();
+ MOCK_METHOD2(OnUnrecoverableError, void(
+ const tracked_objects::Location&,
+ const std::string&));
+};
+
+} // namespace browser_sync
+
+#endif // CHROME_BROWSER_SYNC_INTERNAL_API_INCLUDES_UNRECOVERABLE_ERROR_HANDLER_MOCK_H_
+
diff --git a/chrome/browser/sync/internal_api/sync_manager.cc b/chrome/browser/sync/internal_api/sync_manager.cc
index 8f5bb82..723cbf7 100644
--- a/chrome/browser/sync/internal_api/sync_manager.cc
+++ b/chrome/browser/sync/internal_api/sync_manager.cc
@@ -80,6 +80,7 @@ using browser_sync::SyncEngineEvent;
using browser_sync::SyncEngineEventListener;
using browser_sync::SyncScheduler;
using browser_sync::Syncer;
+using browser_sync::UnrecoverableErrorHandler;
using browser_sync::WeakHandle;
using browser_sync::sessions::SyncSessionContext;
using syncable::DirectoryManager;
@@ -143,6 +144,7 @@ class SyncManager::SyncInternal
initialized_(false),
setup_for_test_mode_(false),
observing_ip_address_changes_(false),
+ unrecoverable_error_handler_(NULL),
created_on_loop_(MessageLoop::current()) {
// Pre-fill |notification_info_map_|.
for (int i = syncable::FIRST_REAL_MODEL_TYPE;
@@ -191,7 +193,8 @@ class SyncManager::SyncInternal
const SyncCredentials& credentials,
sync_notifier::SyncNotifier* sync_notifier,
const std::string& restored_key_for_bootstrapping,
- bool setup_for_test_mode);
+ bool setup_for_test_mode,
+ UnrecoverableErrorHandler* unrecoverable_error_handler);
void CheckServerReachable() {
if (connection_manager()) {
@@ -565,6 +568,8 @@ class SyncManager::SyncInternal
// This is for keeping track of client events to send to the server.
DebugInfoEventListener debug_info_event_listener_;
+ UnrecoverableErrorHandler* unrecoverable_error_handler_;
+
MessageLoop* const created_on_loop_;
};
@@ -697,7 +702,8 @@ bool SyncManager::Init(
const SyncCredentials& credentials,
sync_notifier::SyncNotifier* sync_notifier,
const std::string& restored_key_for_bootstrapping,
- bool setup_for_test_mode) {
+ bool setup_for_test_mode,
+ UnrecoverableErrorHandler* unrecoverable_error_handler) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(post_factory);
DVLOG(1) << "SyncManager starting Init...";
@@ -714,7 +720,8 @@ bool SyncManager::Init(
credentials,
sync_notifier,
restored_key_for_bootstrapping,
- setup_for_test_mode);
+ setup_for_test_mode,
+ unrecoverable_error_handler);
}
void SyncManager::CheckServerReachable() {
@@ -830,7 +837,8 @@ bool SyncManager::SyncInternal::Init(
const SyncCredentials& credentials,
sync_notifier::SyncNotifier* sync_notifier,
const std::string& restored_key_for_bootstrapping,
- bool setup_for_test_mode) {
+ bool setup_for_test_mode,
+ UnrecoverableErrorHandler* unrecoverable_error_handler) {
CHECK(!initialized_);
DCHECK(thread_checker_.CalledOnValidThread());
@@ -860,6 +868,8 @@ bool SyncManager::SyncInternal::Init(
connection_manager()->AddListener(this);
+ unrecoverable_error_handler_ = unrecoverable_error_handler;
+
// Test mode does not use a syncer context or syncer thread.
if (!setup_for_test_mode_) {
// Build a SyncSessionContext and store the worker in it.
@@ -1044,6 +1054,7 @@ bool SyncManager::SyncInternal::OpenDirectory() {
dir_manager()->Open(
username_for_share(),
this,
+ unrecoverable_error_handler_,
browser_sync::MakeWeakHandle(
js_mutation_event_observer_.AsWeakPtr()));
if (!share_opened) {
diff --git a/chrome/browser/sync/internal_api/sync_manager.h b/chrome/browser/sync/internal_api/sync_manager.h
index cc0e462..14ffb6b 100644
--- a/chrome/browser/sync/internal_api/sync_manager.h
+++ b/chrome/browser/sync/internal_api/sync_manager.h
@@ -12,6 +12,7 @@
#include "base/callback_forward.h"
#include "base/time.h"
#include "base/threading/thread_checker.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h"
#include "chrome/browser/sync/internal_api/change_record.h"
#include "chrome/browser/sync/internal_api/configure_reason.h"
#include "chrome/browser/sync/protocol/sync_protocol_error.h"
@@ -440,7 +441,9 @@ class SyncManager {
const SyncCredentials& credentials,
sync_notifier::SyncNotifier* sync_notifier,
const std::string& restored_key_for_bootstrapping,
- bool setup_for_test_mode);
+ bool setup_for_test_mode,
+ browser_sync::UnrecoverableErrorHandler*
+ unrecoverbale_error_handler);
// Checks if the sync server is reachable.
void CheckServerReachable();
diff --git a/chrome/browser/sync/internal_api/syncapi_unittest.cc b/chrome/browser/sync/internal_api/syncapi_unittest.cc
index 53a6521..d65d5b5 100644
--- a/chrome/browser/sync/internal_api/syncapi_unittest.cc
+++ b/chrome/browser/sync/internal_api/syncapi_unittest.cc
@@ -30,6 +30,7 @@
#include "chrome/browser/sync/internal_api/change_record.h"
#include "chrome/browser/sync/internal_api/http_post_provider_factory.h"
#include "chrome/browser/sync/internal_api/http_post_provider_interface.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h"
#include "chrome/browser/sync/internal_api/read_node.h"
#include "chrome/browser/sync/internal_api/read_transaction.h"
#include "chrome/browser/sync/internal_api/sync_manager.h"
@@ -751,13 +752,15 @@ class SyncManagerTest : public testing::Test,
EXPECT_FALSE(sync_notifier_observer_);
EXPECT_FALSE(js_backend_.IsInitialized());
+ browser_sync::MockUnrecoverableErrorHandler handler_mock;
// Takes ownership of |sync_notifier_mock_|.
sync_manager_.Init(temp_dir_.path(),
WeakHandle<JsEventHandler>(),
"bogus", 0, false,
new TestHttpPostProviderFactory(), this, this, "bogus",
credentials, sync_notifier_mock_, "",
- true /* setup_for_test_mode */);
+ true /* setup_for_test_mode */,
+ &handler_mock);
EXPECT_TRUE(sync_notifier_observer_);
EXPECT_TRUE(js_backend_.IsInitialized());
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 2ba31cc..012c516 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -316,13 +316,18 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
if (delete_stale_data)
ClearStaleErrors();
+ backend_unrecoverable_error_handler_.reset(
+ new browser_sync::BackendUnrecoverableErrorHandler(
+ MakeWeakHandle(AsWeakPtr())));
+
backend_->Initialize(
this,
MakeWeakHandle(sync_js_controller_.AsWeakPtr()),
sync_service_url_,
initial_types,
credentials,
- delete_stale_data);
+ delete_stale_data,
+ backend_unrecoverable_error_handler_.get());
}
void ProfileSyncService::CreateBackend() {
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 5d47ee2..110c58a 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -20,6 +20,7 @@
#include "base/task.h"
#include "base/time.h"
#include "base/timer.h"
+#include "chrome/browser/sync/backend_unrecoverable_error_handler.h"
#include "chrome/browser/sync/engine/model_safe_worker.h"
#include "chrome/browser/sync/failed_datatypes_handler.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
@@ -705,6 +706,9 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// keeps track of data types that failed to load.
FailedDatatypesHandler failed_datatypes_handler_;
+ scoped_ptr<browser_sync::BackendUnrecoverableErrorHandler>
+ backend_unrecoverable_error_handler_;
+
DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
};
diff --git a/chrome/browser/sync/syncable/DEPS b/chrome/browser/sync/syncable/DEPS
index cd78103..fdf36f2 100644
--- a/chrome/browser/sync/syncable/DEPS
+++ b/chrome/browser/sync/syncable/DEPS
@@ -14,9 +14,11 @@ include_rules = [
# maybe this file should live in syncable?
"+chrome/browser/sync/engine/model_safe_worker.h",
+ # For the unrecoverable error handler stuff.
"+chrome/common/random.h",
"+chrome/common/sqlite_utils.h",
"-chrome/browser/sync/internal_api",
+ "+chrome/browser/sync/internal_api/includes",
]
diff --git a/chrome/browser/sync/syncable/directory_manager.cc b/chrome/browser/sync/syncable/directory_manager.cc
index c207b3c..54e245f 100644
--- a/chrome/browser/sync/syncable/directory_manager.cc
+++ b/chrome/browser/sync/syncable/directory_manager.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/sync/syncable/syncable.h"
using browser_sync::Cryptographer;
+using browser_sync::UnrecoverableErrorHandler;
namespace syncable {
@@ -45,11 +46,13 @@ DirectoryManager::~DirectoryManager() {
bool DirectoryManager::Open(
const std::string& name,
DirectoryChangeDelegate* delegate,
+ UnrecoverableErrorHandler* unrecoverable_error_handler,
const browser_sync::WeakHandle<TransactionObserver>&
transaction_observer) {
bool was_open = false;
const DirOpenResult result =
OpenImpl(name, GetSyncDataDatabasePath(), delegate,
+ unrecoverable_error_handler,
transaction_observer, &was_open);
return syncable::OPENED == result;
}
@@ -59,6 +62,7 @@ DirOpenResult DirectoryManager::OpenImpl(
const std::string& name,
const FilePath& path,
DirectoryChangeDelegate* delegate,
+ UnrecoverableErrorHandler* unrecoverable_error_handler,
const browser_sync::WeakHandle<TransactionObserver>&
transaction_observer,
bool* was_open) {
@@ -78,7 +82,7 @@ DirOpenResult DirectoryManager::OpenImpl(
return syncable::OPENED;
// Otherwise, open it.
- scoped_ptr<Directory> dir(new Directory);
+ scoped_ptr<Directory> dir(new Directory(unrecoverable_error_handler));
const DirOpenResult result =
dir->Open(path, name, delegate, transaction_observer);
if (syncable::OPENED == result) {
diff --git a/chrome/browser/sync/syncable/directory_manager.h b/chrome/browser/sync/syncable/directory_manager.h
index 243000b..760d785 100644
--- a/chrome/browser/sync/syncable/directory_manager.h
+++ b/chrome/browser/sync/syncable/directory_manager.h
@@ -19,6 +19,7 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/synchronization/lock.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h"
#include "chrome/browser/sync/syncable/dir_open_result.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/util/cryptographer.h"
@@ -48,6 +49,8 @@ class DirectoryManager {
// result is true. Note that events to |delegate| may be sent from
// *any* thread. |transaction_observer| must be initialized.
bool Open(const std::string& name, DirectoryChangeDelegate* delegate,
+ browser_sync::UnrecoverableErrorHandler*
+ unrecoverable_error_handler,
const browser_sync::WeakHandle<TransactionObserver>&
transaction_observer);
@@ -80,6 +83,8 @@ class DirectoryManager {
DirOpenResult OpenImpl(
const std::string& name, const FilePath& path,
DirectoryChangeDelegate* delegate,
+ browser_sync::UnrecoverableErrorHandler*
+ unrecoverable_error_handler,
const browser_sync::WeakHandle<TransactionObserver>&
transaction_observer,
bool* was_open);
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index bf6eb8e..64b6030 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -92,6 +92,7 @@ bool VerifyReferenceIntegrityUnsafe(const syncable::MetahandlesIndex &index) {
} // namespace
using std::string;
+using browser_sync::UnrecoverableErrorHandler;
namespace syncable {
@@ -482,7 +483,10 @@ Directory::Kernel::~Kernel() {
delete metahandles_index;
}
-Directory::Directory() : kernel_(NULL), store_(NULL) {
+Directory::Directory(UnrecoverableErrorHandler* unrecoverable_error_handler)
+ : kernel_(NULL),
+ store_(NULL),
+ unrecoverable_error_handler_(unrecoverable_error_handler) {
}
Directory::~Directory() {
@@ -707,6 +711,10 @@ void Directory::ReindexParentId(EntryKernel* const entry,
}
}
+UnrecoverableErrorHandler* Directory::unrecoverable_error_handler() {
+ return unrecoverable_error_handler_;
+}
+
void Directory::ClearDirtyMetahandles() {
kernel_->transaction_mutex.AssertAcquired();
kernel_->dirty_metahandles->clear();
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h
index 3ab7e3f..bf517fe 100644
--- a/chrome/browser/sync/syncable/syncable.h
+++ b/chrome/browser/sync/syncable/syncable.h
@@ -26,6 +26,7 @@
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/time.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler.h"
#include "chrome/browser/sync/protocol/sync.pb.h"
#include "chrome/browser/sync/syncable/blob.h"
#include "chrome/browser/sync/syncable/dir_open_result.h"
@@ -814,7 +815,8 @@ class Directory {
MetahandleSet metahandles_to_purge;
};
- Directory();
+ explicit Directory(
+ browser_sync::UnrecoverableErrorHandler* unrecoverable_error_handler);
virtual ~Directory();
// Does not take ownership of |delegate|, which must not be NULL.
@@ -868,6 +870,8 @@ class Directory {
// Unique to each account / client pair.
std::string cache_guid() const;
+ browser_sync::UnrecoverableErrorHandler* unrecoverable_error_handler();
+
protected: // for friends, mainly used by Entry constructors
virtual EntryKernel* GetEntryByHandle(int64 handle);
virtual EntryKernel* GetEntryByHandle(int64 metahandle,
@@ -1187,6 +1191,8 @@ class Directory {
Kernel* kernel_;
DirectoryBackingStore* store_;
+
+ browser_sync::UnrecoverableErrorHandler* unrecoverable_error_handler_;
};
class ScopedKernelLock {
diff --git a/chrome/browser/sync/syncable/syncable_mock.cc b/chrome/browser/sync/syncable/syncable_mock.cc
index b21decf..5149cfd 100644
--- a/chrome/browser/sync/syncable/syncable_mock.cc
+++ b/chrome/browser/sync/syncable/syncable_mock.cc
@@ -7,7 +7,7 @@
#include "base/location.h"
#include "chrome/browser/sync/test/null_transaction_observer.h"
-MockDirectory::MockDirectory() {
+MockDirectory::MockDirectory() :Directory(&mock_handler_) {
InitKernelForTest("myk", &delegate_, syncable::NullTransactionObserver());
}
diff --git a/chrome/browser/sync/syncable/syncable_mock.h b/chrome/browser/sync/syncable/syncable_mock.h
index 656b3d5..ec325b3 100644
--- a/chrome/browser/sync/syncable/syncable_mock.h
+++ b/chrome/browser/sync/syncable/syncable_mock.h
@@ -8,6 +8,7 @@
#include <string>
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/test/null_directory_change_delegate.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -30,6 +31,7 @@ class MockDirectory : public Directory {
private:
syncable::NullDirectoryChangeDelegate delegate_;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler_;
};
class MockSyncableWriteTransaction : public syncable::WriteTransaction {
diff --git a/chrome/browser/sync/syncable/syncable_unittest.cc b/chrome/browser/sync/syncable/syncable_unittest.cc
index 453d819..6ba25ff 100644
--- a/chrome/browser/sync/syncable/syncable_unittest.cc
+++ b/chrome/browser/sync/syncable/syncable_unittest.cc
@@ -19,6 +19,7 @@
#include "base/threading/platform_thread.h"
#include "base/values.h"
#include "chrome/browser/sync/engine/syncproto.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h"
#include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
#include "chrome/browser/sync/syncable/directory_backing_store.h"
#include "chrome/browser/sync/syncable/directory_change_delegate.h"
@@ -98,7 +99,8 @@ class SyncableGeneralTest : public testing::Test {
};
TEST_F(SyncableGeneralTest, General) {
- Directory dir;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ Directory dir(&mock_handler);
dir.Open(db_path_, "SimpleTest", &delegate_, NullTransactionObserver());
int64 root_metahandle;
@@ -197,7 +199,8 @@ TEST_F(SyncableGeneralTest, General) {
}
TEST_F(SyncableGeneralTest, ChildrenOps) {
- Directory dir;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ Directory dir(&mock_handler);
dir.Open(db_path_, "SimpleTest", &delegate_, NullTransactionObserver());
int64 root_metahandle;
@@ -277,7 +280,8 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) {
// Test creating a new meta entry.
{
- Directory dir;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ Directory dir(&mock_handler);
dir.Open(db_path_, "IndexTest", &delegate_, NullTransactionObserver());
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
@@ -293,7 +297,8 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) {
// The DB was closed. Now reopen it. This will cause index regeneration.
{
- Directory dir;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ Directory dir(&mock_handler);
dir.Open(db_path_, "IndexTest", &delegate_, NullTransactionObserver());
ReadTransaction trans(FROM_HERE, &dir);
@@ -313,7 +318,8 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) {
// Test creating a deleted, unsynced, server meta entry.
{
- Directory dir;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ Directory dir(&mock_handler);
dir.Open(db_path_, "IndexTest", &delegate_, NullTransactionObserver());
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
@@ -331,7 +337,8 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) {
// The DB was closed. Now reopen it. This will cause index regeneration.
// Should still be present and valid in the client tag index.
{
- Directory dir;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ Directory dir(&mock_handler);
dir.Open(db_path_, "IndexTest", &delegate_, NullTransactionObserver());
ReadTransaction trans(FROM_HERE, &dir);
@@ -345,7 +352,8 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) {
}
TEST_F(SyncableGeneralTest, ToValue) {
- Directory dir;
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ Directory dir(&mock_handler);
dir.Open(db_path_, "SimpleTest", &delegate_, NullTransactionObserver());
const Id id = TestIdFactory::FromNumber(99);
@@ -381,6 +389,7 @@ TEST_F(SyncableGeneralTest, ToValue) {
// A Directory whose backing store always fails SaveChanges by returning false.
class TestUnsaveableDirectory : public Directory {
public:
+ TestUnsaveableDirectory() : Directory(&mock_handler_) {}
class UnsaveableBackingStore : public DirectoryBackingStore {
public:
UnsaveableBackingStore(const std::string& dir_name,
@@ -395,6 +404,8 @@ class TestUnsaveableDirectory : public Directory {
const FilePath& backing_filepath) {
return new UnsaveableBackingStore(dir_name, backing_filepath);
}
+ private:
+ browser_sync::MockUnrecoverableErrorHandler mock_handler_;
};
// Test suite for syncable::Directory.
@@ -408,11 +419,12 @@ class SyncableDirectoryTest : public testing::Test {
// SetUp() is called before each test case is run.
// The sqlite3 DB is deleted before each test is run.
virtual void SetUp() {
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
file_path_ = temp_dir_.path().Append(
FILE_PATH_LITERAL("Test.sqlite3"));
file_util::Delete(file_path_, true);
- dir_.reset(new Directory());
+ dir_.reset(new Directory(&mock_handler));
ASSERT_TRUE(dir_.get());
ASSERT_EQ(OPENED, dir_->Open(file_path_, kName,
&delegate_, NullTransactionObserver()));
@@ -427,7 +439,8 @@ class SyncableDirectoryTest : public testing::Test {
}
void ReloadDir() {
- dir_.reset(new Directory());
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ dir_.reset(new Directory(&mock_handler));
ASSERT_TRUE(dir_.get());
ASSERT_EQ(OPENED, dir_->Open(file_path_, kName,
&delegate_, NullTransactionObserver()));
@@ -1199,7 +1212,8 @@ TEST_F(SyncableDirectoryTest, TestSimpleFieldsPreservedDuringSaveChanges) {
}
dir_->SaveChanges();
- dir_.reset(new Directory());
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ dir_.reset(new Directory(&mock_handler));
ASSERT_TRUE(dir_.get());
ASSERT_EQ(OPENED, dir_->Open(file_path_, kName,
&delegate_, NullTransactionObserver()));
@@ -1504,7 +1518,9 @@ class SyncableDirectoryManager : public testing::Test {
TEST_F(SyncableDirectoryManager, TestFileRelease) {
DirectoryManager dm(FilePath(temp_dir_.path()));
- ASSERT_TRUE(dm.Open("ScopeTest", &delegate_, NullTransactionObserver()));
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ ASSERT_TRUE(dm.Open("ScopeTest", &delegate_, &mock_handler,
+ NullTransactionObserver()));
{
ScopedDirLookup(&dm, "ScopeTest");
}
@@ -1522,8 +1538,9 @@ class ThreadOpenTestDelegate : public base::PlatformThread::Delegate {
private:
// PlatformThread::Delegate methods:
virtual void ThreadMain() {
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
CHECK(directory_manager_->Open(
- "Open", &delegate_, NullTransactionObserver()));
+ "Open", &delegate_, &mock_handler, NullTransactionObserver()));
}
DISALLOW_COPY_AND_ASSIGN(ThreadOpenTestDelegate);
@@ -1570,7 +1587,7 @@ class ThreadBugDelegate : public base::PlatformThread::Delegate {
MessageLoop message_loop;
const std::string dirname = "ThreadBug1";
base::AutoLock scoped_lock(step_->mutex);
-
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
while (step_->number < 3) {
while (step_->number % 2 != role_) {
step_->condvar.Wait();
@@ -1578,13 +1595,13 @@ class ThreadBugDelegate : public base::PlatformThread::Delegate {
switch (step_->number) {
case 0:
directory_manager_->Open(
- dirname, &delegate_, NullTransactionObserver());
+ dirname, &delegate_, &mock_handler, NullTransactionObserver());
break;
case 1:
{
directory_manager_->Close(dirname);
directory_manager_->Open(
- dirname, &delegate_, NullTransactionObserver());
+ dirname, &delegate_, &mock_handler, NullTransactionObserver());
ScopedDirLookup dir(directory_manager_, dirname);
CHECK(dir.good());
WriteTransaction trans(FROM_HERE, UNITTEST, dir);
@@ -1655,12 +1672,13 @@ class DirectoryKernelStalenessBugDelegate : public ThreadBugDelegate {
switch (step_->number) {
case 0:
{
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
// Clean up remnants of earlier test runs.
file_util::Delete(directory_manager_->GetSyncDataDatabasePath(),
true);
// Test.
directory_manager_->Open(
- dirname, &delegate_, NullTransactionObserver());
+ dirname, &delegate_, &mock_handler, NullTransactionObserver());
ScopedDirLookup dir(directory_manager_, dirname);
CHECK(dir.good());
WriteTransaction trans(FROM_HERE, UNITTEST, dir);
@@ -1679,8 +1697,9 @@ class DirectoryKernelStalenessBugDelegate : public ThreadBugDelegate {
break;
case 1:
{
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
directory_manager_->Open(
- dirname, &delegate_, NullTransactionObserver());
+ dirname, &delegate_, &mock_handler, NullTransactionObserver());
ScopedDirLookup dir(directory_manager_, dirname);
CHECK(dir.good());
}
@@ -1786,7 +1805,8 @@ TEST(SyncableDirectory, StressTransactions) {
std::string dirname = "stress";
file_util::Delete(dirman.GetSyncDataDatabasePath(), true);
NullDirectoryChangeDelegate delegate;
- dirman.Open(dirname, &delegate, NullTransactionObserver());
+ browser_sync::MockUnrecoverableErrorHandler mock_handler;
+ dirman.Open(dirname, &delegate, &mock_handler, NullTransactionObserver());
const int kThreadCount = 7;
base::PlatformThreadHandle threads[kThreadCount];
diff --git a/chrome/browser/sync/test/engine/test_directory_setter_upper.cc b/chrome/browser/sync/test/engine/test_directory_setter_upper.cc
index 7cdb2a4..352506c 100644
--- a/chrome/browser/sync/test/engine/test_directory_setter_upper.cc
+++ b/chrome/browser/sync/test/engine/test_directory_setter_upper.cc
@@ -40,7 +40,8 @@ void TestDirectorySetterUpper::reset_directory_manager(DirectoryManager* d) {
void TestDirectorySetterUpper::SetUp() {
Init();
- ASSERT_TRUE(manager()->Open(name(), &delegate_, NullTransactionObserver()));
+ ASSERT_TRUE(manager()->Open(name(), &delegate_, &handler_mock_,
+ NullTransactionObserver()));
}
void TestDirectorySetterUpper::TearDown() {
@@ -83,7 +84,8 @@ void ManuallyOpenedTestDirectorySetterUpper::SetUp() {
void ManuallyOpenedTestDirectorySetterUpper::Open() {
ASSERT_TRUE(
- manager()->Open(name(), &delegate_, NullTransactionObserver()));
+ manager()->Open(name(), &delegate_, &handler_mock_,
+ NullTransactionObserver()));
was_opened_ = true;
}
@@ -113,7 +115,9 @@ void TriggeredOpenTestDirectorySetterUpper::TearDown() {
}
MockDirectorySetterUpper::MockDirectory::MockDirectory(
- const std::string& name) {
+ const std::string& name,
+ browser_sync::UnrecoverableErrorHandler* handler_mock)
+ : Directory(handler_mock) {
InitKernelForTest(name, &delegate_, NullTransactionObserver());
}
@@ -126,7 +130,7 @@ MockDirectorySetterUpper::Manager::Manager(
}
MockDirectorySetterUpper::MockDirectorySetterUpper()
- : directory_(new MockDirectory(name())) {
+ : directory_(new MockDirectory(name(), &handler_mock_)) {
}
MockDirectorySetterUpper::~MockDirectorySetterUpper() {}
diff --git a/chrome/browser/sync/test/engine/test_directory_setter_upper.h b/chrome/browser/sync/test/engine/test_directory_setter_upper.h
index f595cf2..111d21d 100644
--- a/chrome/browser/sync/test/engine/test_directory_setter_upper.h
+++ b/chrome/browser/sync/test/engine/test_directory_setter_upper.h
@@ -37,6 +37,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/scoped_temp_dir.h"
+#include "chrome/browser/sync/internal_api/includes/unrecoverable_error_handler_mock.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/test/null_directory_change_delegate.h"
@@ -73,6 +74,7 @@ class TestDirectorySetterUpper {
void reset_directory_manager(syncable::DirectoryManager* d);
syncable::NullDirectoryChangeDelegate delegate_;
+ MockUnrecoverableErrorHandler handler_mock_;
private:
void RunInvariantCheck(const syncable::ScopedDirLookup& dir);
@@ -121,7 +123,8 @@ class MockDirectorySetterUpper : public TestDirectorySetterUpper {
class MockDirectory : public syncable::Directory {
public:
- explicit MockDirectory(const std::string& name);
+ MockDirectory(const std::string& name,
+ browser_sync::UnrecoverableErrorHandler* handler_mock);
virtual ~MockDirectory();
MOCK_METHOD1(PurgeEntriesWithTypeIn, void(syncable::ModelTypeSet));