Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_DIRECTORY_BACKING_STORE_H_ | 5 #ifndef SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
| 6 #define SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ | 6 #define SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 // The DirectoryBackingStore will own an sqlite lock on its database for most of | 37 // The DirectoryBackingStore will own an sqlite lock on its database for most of |
| 38 // its lifetime. You must not have two DirectoryBackingStore objects accessing | 38 // its lifetime. You must not have two DirectoryBackingStore objects accessing |
| 39 // the database simultaneously. Because the lock exists at the database level, | 39 // the database simultaneously. Because the lock exists at the database level, |
| 40 // not even two separate browser instances would be able to acquire it | 40 // not even two separate browser instances would be able to acquire it |
| 41 // simultaneously. | 41 // simultaneously. |
| 42 // | 42 // |
| 43 // This class is abstract so that we can extend it in interesting ways for use | 43 // This class is abstract so that we can extend it in interesting ways for use |
| 44 // in tests. The concrete class used in non-test scenarios is | 44 // in tests. The concrete class used in non-test scenarios is |
| 45 // OnDiskDirectoryBackingStore. | 45 // OnDiskDirectoryBackingStore. |
| 46 class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe { | 46 class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe { |
| 47 friend class DirectoryBackingStoreTest; | |
| 48 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, | |
| 49 IncreaseDatabasePageSizeFrom4KTo32K); | |
| 50 | |
| 47 public: | 51 public: |
| 48 explicit DirectoryBackingStore(const std::string& dir_name); | 52 explicit DirectoryBackingStore(const std::string& dir_name); |
| 49 virtual ~DirectoryBackingStore(); | 53 virtual ~DirectoryBackingStore(); |
| 50 | 54 |
| 51 // Loads and drops all currently persisted meta entries into |handles_map| | 55 // Loads and drops all currently persisted meta entries into |handles_map| |
| 52 // and loads appropriate persisted kernel info into |info_bucket|. | 56 // and loads appropriate persisted kernel info into |info_bucket|. |
| 53 // | 57 // |
| 54 // This function can perform some cleanup tasks behind the scenes. It will | 58 // This function can perform some cleanup tasks behind the scenes. It will |
| 55 // clean up unused entries from the database and migrate to the latest | 59 // clean up unused entries from the database and migrate to the latest |
| 56 // database version. The caller can safely ignore these details. | 60 // database version. The caller can safely ignore these details. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 141 |
| 138 // Checks that the references between sync nodes is consistent. | 142 // Checks that the references between sync nodes is consistent. |
| 139 static bool VerifyReferenceIntegrity( | 143 static bool VerifyReferenceIntegrity( |
| 140 const Directory::MetahandlesMap* handles_map); | 144 const Directory::MetahandlesMap* handles_map); |
| 141 | 145 |
| 142 // Migration utilities. | 146 // Migration utilities. |
| 143 bool RefreshColumns(); | 147 bool RefreshColumns(); |
| 144 bool SetVersion(int version); | 148 bool SetVersion(int version); |
| 145 int GetVersion(); | 149 int GetVersion(); |
| 146 | 150 |
| 151 bool GetDatabasePageSize(int* page_size); | |
| 152 bool IsSyncBackingDatabase32KEnabled(); | |
| 153 bool IncreasePageSizeTo32K(); | |
| 154 bool Vacuum(); | |
| 155 int databasePageSize; | |
|
stanisc
2015/03/18 15:10:45
Member field should have an underscore at the end.
Gang Wu
2015/05/21 18:38:17
Done.
| |
| 156 | |
| 147 bool MigrateToSpecifics(const char* old_columns, | 157 bool MigrateToSpecifics(const char* old_columns, |
| 148 const char* specifics_column, | 158 const char* specifics_column, |
| 149 void(*handler_function) ( | 159 void(*handler_function) ( |
| 150 sql::Statement* old_value_query, | 160 sql::Statement* old_value_query, |
| 151 int old_value_column, | 161 int old_value_column, |
| 152 sync_pb::EntitySpecifics* mutable_new_value)); | 162 sync_pb::EntitySpecifics* mutable_new_value)); |
| 153 | 163 |
| 154 // Individual version migrations. | 164 // Individual version migrations. |
| 155 bool MigrateVersion67To68(); | 165 bool MigrateVersion67To68(); |
| 156 bool MigrateVersion68To69(); | 166 bool MigrateVersion68To69(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 void PrepareSaveEntryStatement(EntryTable table, | 199 void PrepareSaveEntryStatement(EntryTable table, |
| 190 sql::Statement* save_statement); | 200 sql::Statement* save_statement); |
| 191 | 201 |
| 192 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); | 202 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); |
| 193 }; | 203 }; |
| 194 | 204 |
| 195 } // namespace syncable | 205 } // namespace syncable |
| 196 } // namespace syncer | 206 } // namespace syncer |
| 197 | 207 |
| 198 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ | 208 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
| OLD | NEW |