OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SYNC_SYNCABLE_ON_DISK_DIRECTORY_BACKING_STORE_H_ | 5 #ifndef SYNC_SYNCABLE_ON_DISK_DIRECTORY_BACKING_STORE_H_ |
6 #define SYNC_SYNCABLE_ON_DISK_DIRECTORY_BACKING_STORE_H_ | 6 #define SYNC_SYNCABLE_ON_DISK_DIRECTORY_BACKING_STORE_H_ |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "sync/syncable/directory_backing_store.h" | 9 #include "sync/syncable/directory_backing_store.h" |
10 | 10 |
11 namespace syncer { | 11 namespace syncer { |
12 namespace syncable { | 12 namespace syncable { |
13 | 13 |
14 // This is the concrete class that provides a useful implementation of | 14 // This is the concrete class that provides a useful implementation of |
15 // DirectoryBackingStore. | 15 // DirectoryBackingStore. |
16 class OnDiskDirectoryBackingStore : public DirectoryBackingStore { | 16 class OnDiskDirectoryBackingStore : public DirectoryBackingStore { |
17 public: | 17 public: |
18 OnDiskDirectoryBackingStore(const std::string& dir_name, | 18 OnDiskDirectoryBackingStore(const std::string& dir_name, |
19 const FilePath& backing_filepath); | 19 const FilePath& backing_filepath); |
| 20 virtual ~OnDiskDirectoryBackingStore(); |
20 virtual DirOpenResult Load( | 21 virtual DirOpenResult Load( |
21 MetahandlesIndex* entry_bucket, | 22 MetahandlesIndex* entry_bucket, |
22 Directory::KernelLoadInfo* kernel_load_info) OVERRIDE; | 23 Directory::KernelLoadInfo* kernel_load_info) OVERRIDE; |
23 | 24 |
| 25 // A helper function that will make one attempt to load the directory. |
| 26 // Unlike Load(), it does not attempt to recover from failure. |
| 27 DirOpenResult TryLoad( |
| 28 MetahandlesIndex* entry_bucket, |
| 29 Directory::KernelLoadInfo* kernel_load_info); |
| 30 |
| 31 protected: |
| 32 // Subclasses may override this to avoid a possible DCHECK. |
| 33 virtual void ReportFirstTryOpenFailure(); |
| 34 |
24 private: | 35 private: |
| 36 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MinorCorruption); |
| 37 |
| 38 bool allow_failure_for_test_; |
25 FilePath backing_filepath_; | 39 FilePath backing_filepath_; |
26 }; | 40 }; |
27 | 41 |
28 } // namespace syncable | 42 } // namespace syncable |
29 } // namespace syncer | 43 } // namespace syncer |
30 | 44 |
31 #endif // SYNC_SYNCABLE_ON_DISK_DIRECTORY_BACKING_STORE_H_ | 45 #endif // SYNC_SYNCABLE_ON_DISK_DIRECTORY_BACKING_STORE_H_ |
OLD | NEW |