| 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 |kernel_load_info|. | 56 // and loads appropriate persisted kernel info into |kernel_load_info|. |
| 53 // The function determines which entries can be safely dropped and inserts | 57 // The function determines which entries can be safely dropped and inserts |
| 54 // their keys into |metahandles_to_purge|. It is up to the caller to | 58 // their keys into |metahandles_to_purge|. It is up to the caller to |
| 55 // perform the actual cleanup. | 59 // perform the actual cleanup. |
| 56 // | 60 // |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 142 |
| 139 // Checks that the references between sync nodes is consistent. | 143 // Checks that the references between sync nodes is consistent. |
| 140 static bool VerifyReferenceIntegrity( | 144 static bool VerifyReferenceIntegrity( |
| 141 const Directory::MetahandlesMap* handles_map); | 145 const Directory::MetahandlesMap* handles_map); |
| 142 | 146 |
| 143 // Migration utilities. | 147 // Migration utilities. |
| 144 bool RefreshColumns(); | 148 bool RefreshColumns(); |
| 145 bool SetVersion(int version); | 149 bool SetVersion(int version); |
| 146 int GetVersion(); | 150 int GetVersion(); |
| 147 | 151 |
| 152 bool GetDatabasePageSize(int* page_size); |
| 153 bool IsSyncBackingDatabase32KEnabled(); |
| 154 bool IncreasePageSizeTo32K(); |
| 155 bool Vacuum(); |
| 156 int databasePageSize_; |
| 157 |
| 148 bool MigrateToSpecifics(const char* old_columns, | 158 bool MigrateToSpecifics(const char* old_columns, |
| 149 const char* specifics_column, | 159 const char* specifics_column, |
| 150 void(*handler_function) ( | 160 void(*handler_function) ( |
| 151 sql::Statement* old_value_query, | 161 sql::Statement* old_value_query, |
| 152 int old_value_column, | 162 int old_value_column, |
| 153 sync_pb::EntitySpecifics* mutable_new_value)); | 163 sync_pb::EntitySpecifics* mutable_new_value)); |
| 154 | 164 |
| 155 // Individual version migrations. | 165 // Individual version migrations. |
| 156 bool MigrateVersion67To68(); | 166 bool MigrateVersion67To68(); |
| 157 bool MigrateVersion68To69(); | 167 bool MigrateVersion68To69(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void PrepareSaveEntryStatement(EntryTable table, | 200 void PrepareSaveEntryStatement(EntryTable table, |
| 191 sql::Statement* save_statement); | 201 sql::Statement* save_statement); |
| 192 | 202 |
| 193 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); | 203 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); |
| 194 }; | 204 }; |
| 195 | 205 |
| 196 } // namespace syncable | 206 } // namespace syncable |
| 197 } // namespace syncer | 207 } // namespace syncer |
| 198 | 208 |
| 199 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ | 209 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
| OLD | NEW |