summaryrefslogtreecommitdiffstats
path: root/sync/syncable/on_disk_directory_backing_store.h
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 00:10:16 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 00:10:16 +0000
commitfc82716815f7df148d48382632ea96681a2f9b1f (patch)
tree556708a0c1ad6a6b47e9b1e581d5913859a7c7da /sync/syncable/on_disk_directory_backing_store.h
parent44aed838ef34e9f3cebf84a52e0ed6bbc45b9171 (diff)
downloadchromium_src-fc82716815f7df148d48382632ea96681a2f9b1f.zip
chromium_src-fc82716815f7df148d48382632ea96681a2f9b1f.tar.gz
chromium_src-fc82716815f7df148d48382632ea96681a2f9b1f.tar.bz2
sync: Attempt to recover from directory corruption
Sync when sqlite fails to maintain databsae integrity, most likely due to unexpected shutdowns or flaky storage devices. They can also be corrupted by logic errors in the sync code, though we hope that's a rare occurence. This patch attempts to improve a user's experience in this scenario by transparently deleting the old directory and re-downloading all their data. This will be much better than the old behaviours, which included silently signing a user out of sync, triggering an unrecoverable error, or crashing. To help catch sync logic bugs, debug builds are set to crash when they detect directory corruption. Also included in this patch is a new test. The DirectoryBackingStore.MinorCorruption test exercises the code invoked when the directory is successfully re-created. BUG=109668, 129825 Review URL: https://chromiumcodereview.appspot.com/10821121 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150465 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/syncable/on_disk_directory_backing_store.h')
-rw-r--r--sync/syncable/on_disk_directory_backing_store.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/sync/syncable/on_disk_directory_backing_store.h b/sync/syncable/on_disk_directory_backing_store.h
index f722ef9..0bf720b 100644
--- a/sync/syncable/on_disk_directory_backing_store.h
+++ b/sync/syncable/on_disk_directory_backing_store.h
@@ -17,11 +17,25 @@ class OnDiskDirectoryBackingStore : public DirectoryBackingStore {
public:
OnDiskDirectoryBackingStore(const std::string& dir_name,
const FilePath& backing_filepath);
+ virtual ~OnDiskDirectoryBackingStore();
virtual DirOpenResult Load(
MetahandlesIndex* entry_bucket,
Directory::KernelLoadInfo* kernel_load_info) OVERRIDE;
+ // A helper function that will make one attempt to load the directory.
+ // Unlike Load(), it does not attempt to recover from failure.
+ DirOpenResult TryLoad(
+ MetahandlesIndex* entry_bucket,
+ Directory::KernelLoadInfo* kernel_load_info);
+
+ protected:
+ // Subclasses may override this to avoid a possible DCHECK.
+ virtual void ReportFirstTryOpenFailure();
+
private:
+ FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MinorCorruption);
+
+ bool allow_failure_for_test_;
FilePath backing_filepath_;
};