summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/syncable
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 00:47:19 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 00:47:19 +0000
commit18af9a22ada195c0ffc524fd4ab12b54e61e7663 (patch)
treeb0806976a7bf941fb9162a65988ecb3cc4aab2c3 /chrome/browser/sync/syncable
parent93c1c66878c5f8fc76a4bd095ecbf537c2ed01e8 (diff)
downloadchromium_src-18af9a22ada195c0ffc524fd4ab12b54e61e7663.zip
chromium_src-18af9a22ada195c0ffc524fd4ab12b54e61e7663.tar.gz
chromium_src-18af9a22ada195c0ffc524fd4ab12b54e61e7663.tar.bz2
sync: Fix backend configuration to support sync db refresh.
Removes the has_new bit in favor of checking if initial_sync_ended for requested types, and recreates the sync db on corruption (as we used to). These together mean we refresh the sync db on corruption. Also added some defensive dchecks. To test this, I ripped out the test-only #ifdefs in SyncBackendHost so the tests use the real Initialize code path, and added a toolbox of stuff to control when we set initial sync ended bits during testing. BUG=50965 TEST=DirectoryBackingStoreTest, ProfileSyncService* tests. Review URL: http://codereview.chromium.org/3099001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/syncable')
-rw-r--r--chrome/browser/sync/syncable/directory_backing_store.cc30
-rw-r--r--chrome/browser/sync/syncable/directory_backing_store_unittest.cc3
2 files changed, 28 insertions, 5 deletions
diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc
index 8dc939cd..7f82a73 100644
--- a/chrome/browser/sync/syncable/directory_backing_store.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store.cc
@@ -14,6 +14,7 @@
#include "base/file_util.h"
#include "base/hash_tables.h"
+#include "base/histogram.h"
#include "base/logging.h"
#include "base/stl_util-inl.h"
#include "base/string_number_conversions.h"
@@ -283,11 +284,34 @@ bool DirectoryBackingStore::BeginLoad() {
DCHECK(load_dbhandle_ == NULL);
bool ret = OpenAndConfigureHandleHelper(&load_dbhandle_);
if (ret)
- return ret;
+ return true;
// Something's gone wrong. Nuke the database and try again.
LOG(ERROR) << "Sync database " << backing_filepath_.value()
- << " corrupt.";
- return false;
+ << " corrupt. Deleting and recreating.";
+ file_util::Delete(backing_filepath_, false);
+ bool failed_again = !OpenAndConfigureHandleHelper(&load_dbhandle_);
+
+ // Using failed_again here lets us distinguish from cases where corruption
+ // occurred even when re-opening a fresh directory (they'll go in a separate
+ // double weight histogram bucket). Failing twice in a row means we disable
+ // sync, so it's useful to see this number separately.
+ int bucket = failed_again ? 2 : 1;
+#if defined(OS_WIN)
+ UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedWin", bucket);
+#elif defined(OS_MACOSX)
+ UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedMac", bucket);
+#else
+ UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedNotWinMac", bucket);
+
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedLinux", bucket);
+#elif defined(OS_CHROMEOS)
+ UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedCros", bucket);
+#else
+ UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedOther", bucket);
+#endif // OS_LINUX && !OS_CHROMEOS
+#endif // OS_WIN
+ return !failed_again;
}
void DirectoryBackingStore::EndLoad() {
diff --git a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
index 7ec3d49..c158f9a 100644
--- a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
@@ -1019,8 +1019,7 @@ TEST_F(DirectoryBackingStoreTest, ModelTypeIds) {
}
}
-// TODO(tim): Disabled due to bug 48502.
-TEST_F(DirectoryBackingStoreTest, DISABLED_Corruption) {
+TEST_F(DirectoryBackingStoreTest, Corruption) {
{
scoped_ptr<DirectoryBackingStore> dbs(
new DirectoryBackingStore(GetUsername(), GetDatabasePath()));