diff options
author | maniscalco <maniscalco@chromium.org> | 2015-04-30 12:38:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-30 19:39:38 +0000 |
commit | 8382e4e5dce071e21f1297df234a17bdf7a5ed32 (patch) | |
tree | 14718629ea94944dbfc83400902711c8d4eab93f /sync/util | |
parent | 610f47342c8d725e239513ac17727a176d161495 (diff) | |
download | chromium_src-8382e4e5dce071e21f1297df234a17bdf7a5ed32.zip chromium_src-8382e4e5dce071e21f1297df234a17bdf7a5ed32.tar.gz chromium_src-8382e4e5dce071e21f1297df234a17bdf7a5ed32.tar.bz2 |
[Sync] Erase sync DB when corrupted
Directory now registers to be notified of catastrophic sync DB errors.
Upon notification, Directory triggers an unrecoverable sync error which
causes ProfileSyncService to delete the sync DB.
Add integration test that verifies the sync DB is deleted when DB
corruption is detected.
Remove unused member variable allow_failure_for_test_ from
DirectoryBackingStore.
Add MockUnrecoverableErrorHandler to assist in writing tests for
Directory.
BUG=470993
Committed: https://crrev.com/90a7f8d3e3b3a2aac43e71a93eac2731f084945c
Cr-Commit-Position: refs/heads/master@{#327120}
Review URL: https://codereview.chromium.org/1082893003
Cr-Commit-Position: refs/heads/master@{#327766}
Diffstat (limited to 'sync/util')
-rw-r--r-- | sync/util/mock_unrecoverable_error_handler.cc | 26 | ||||
-rw-r--r-- | sync/util/mock_unrecoverable_error_handler.h | 35 |
2 files changed, 61 insertions, 0 deletions
diff --git a/sync/util/mock_unrecoverable_error_handler.cc b/sync/util/mock_unrecoverable_error_handler.cc new file mode 100644 index 0000000..bfed1f1 --- /dev/null +++ b/sync/util/mock_unrecoverable_error_handler.cc @@ -0,0 +1,26 @@ +// Copyright 2015 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 "sync/util/mock_unrecoverable_error_handler.h" + +namespace syncer { + +MockUnrecoverableErrorHandler::MockUnrecoverableErrorHandler() + : invocation_count_(0) { +} + +MockUnrecoverableErrorHandler::~MockUnrecoverableErrorHandler() { +} + +void MockUnrecoverableErrorHandler::OnUnrecoverableError( + const tracked_objects::Location& from_here, + const std::string& message) { + ++invocation_count_; +} + +int MockUnrecoverableErrorHandler::invocation_count() const { + return invocation_count_; +} + +} // namespace syncer diff --git a/sync/util/mock_unrecoverable_error_handler.h b/sync/util/mock_unrecoverable_error_handler.h new file mode 100644 index 0000000..aacde89 --- /dev/null +++ b/sync/util/mock_unrecoverable_error_handler.h @@ -0,0 +1,35 @@ +// Copyright 2015 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 SYNC_UTIL_MOCK_UNRECOVERABLE_ERROR_HANDLER_H_ +#define SYNC_UTIL_MOCK_UNRECOVERABLE_ERROR_HANDLER_H_ + +#include <string> + +#include "base/macros.h" +#include "sync/internal_api/public/util/unrecoverable_error_handler.h" + +namespace syncer { + +// Mock implementation of UnrecoverableErrorHandler that counts how many times +// it has been invoked. +class MockUnrecoverableErrorHandler : public UnrecoverableErrorHandler { + public: + MockUnrecoverableErrorHandler(); + ~MockUnrecoverableErrorHandler() override; + void OnUnrecoverableError(const tracked_objects::Location& from_here, + const std::string& message) override; + + // Returns the number of times this handler has been invoked. + int invocation_count() const; + + private: + int invocation_count_; + + DISALLOW_COPY_AND_ASSIGN(MockUnrecoverableErrorHandler); +}; + +} // namespace syncer + +#endif // SYNC_UTIL_MOCK_UNRECOVERABLE_ERROR_HANDLER_H_ |