| 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 COMPONENTS_SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ | 5 #ifndef COMPONENTS_SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
| 6 #define COMPONENTS_SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ | 6 #define COMPONENTS_SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/sequence_checker.h" |
| 16 #include "components/sync/base/model_type.h" | 16 #include "components/sync/base/model_type.h" |
| 17 #include "components/sync/syncable/dir_open_result.h" | 17 #include "components/sync/syncable/dir_open_result.h" |
| 18 #include "components/sync/syncable/directory.h" | 18 #include "components/sync/syncable/directory.h" |
| 19 #include "components/sync/syncable/metahandle_set.h" | 19 #include "components/sync/syncable/metahandle_set.h" |
| 20 #include "sql/connection.h" | 20 #include "sql/connection.h" |
| 21 #include "sql/statement.h" | 21 #include "sql/statement.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 namespace trace_event { | 24 namespace trace_event { |
| 25 class ProcessMemoryDump; | 25 class ProcessMemoryDump; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 44 // | 44 // |
| 45 // The DirectoryBackingStore will own an sqlite lock on its database for most of | 45 // The DirectoryBackingStore will own an sqlite lock on its database for most of |
| 46 // its lifetime. You must not have two DirectoryBackingStore objects accessing | 46 // its lifetime. You must not have two DirectoryBackingStore objects accessing |
| 47 // the database simultaneously. Because the lock exists at the database level, | 47 // the database simultaneously. Because the lock exists at the database level, |
| 48 // not even two separate browser instances would be able to acquire it | 48 // not even two separate browser instances would be able to acquire it |
| 49 // simultaneously. | 49 // simultaneously. |
| 50 // | 50 // |
| 51 // This class is abstract so that we can extend it in interesting ways for use | 51 // This class is abstract so that we can extend it in interesting ways for use |
| 52 // in tests. The concrete class used in non-test scenarios is | 52 // in tests. The concrete class used in non-test scenarios is |
| 53 // OnDiskDirectoryBackingStore. | 53 // OnDiskDirectoryBackingStore. |
| 54 class DirectoryBackingStore : public base::NonThreadSafe { | 54 class DirectoryBackingStore { |
| 55 public: | 55 public: |
| 56 explicit DirectoryBackingStore(const std::string& dir_name); | 56 explicit DirectoryBackingStore(const std::string& dir_name); |
| 57 virtual ~DirectoryBackingStore(); | 57 virtual ~DirectoryBackingStore(); |
| 58 | 58 |
| 59 // Loads and drops all currently persisted meta entries into |handles_map| | 59 // Loads and drops all currently persisted meta entries into |handles_map| |
| 60 // and loads appropriate persisted kernel info into |kernel_load_info|. | 60 // and loads appropriate persisted kernel info into |kernel_load_info|. |
| 61 // The function determines which entries can be safely dropped and inserts | 61 // The function determines which entries can be safely dropped and inserts |
| 62 // their keys into |metahandles_to_purge|. It is up to the caller to | 62 // their keys into |metahandles_to_purge|. It is up to the caller to |
| 63 // perform the actual cleanup. | 63 // perform the actual cleanup. |
| 64 // | 64 // |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 bool MigrateVersion88To89(); | 188 bool MigrateVersion88To89(); |
| 189 bool MigrateVersion89To90(); | 189 bool MigrateVersion89To90(); |
| 190 bool MigrateVersion90To91(); | 190 bool MigrateVersion90To91(); |
| 191 | 191 |
| 192 // Accessor for needs_column_refresh_. Used in tests. | 192 // Accessor for needs_column_refresh_. Used in tests. |
| 193 bool needs_column_refresh() const; | 193 bool needs_column_refresh() const; |
| 194 | 194 |
| 195 // Destroys the existing Connection and creates a new one. | 195 // Destroys the existing Connection and creates a new one. |
| 196 void ResetAndCreateConnection(); | 196 void ResetAndCreateConnection(); |
| 197 | 197 |
| 198 SEQUENCE_CHECKER(sequence_checker_); |
| 199 |
| 198 private: | 200 private: |
| 199 friend class DirectoryBackingStoreTest; | 201 friend class DirectoryBackingStoreTest; |
| 200 friend class TestDirectoryBackingStore; | 202 friend class TestDirectoryBackingStore; |
| 201 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, | 203 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, |
| 202 IncreaseDatabasePageSizeFrom4KTo32K); | 204 IncreaseDatabasePageSizeFrom4KTo32K); |
| 203 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, | 205 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, |
| 204 CatastrophicErrorHandler_KeptAcrossReset); | 206 CatastrophicErrorHandler_KeptAcrossReset); |
| 205 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, | 207 FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, |
| 206 CatastrophicErrorHandler_InvocationDuringLoad); | 208 CatastrophicErrorHandler_InvocationDuringLoad); |
| 207 FRIEND_TEST_ALL_PREFIXES( | 209 FRIEND_TEST_ALL_PREFIXES( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // sql::Connection is destroyed/recreated. | 271 // sql::Connection is destroyed/recreated. |
| 270 base::Closure catastrophic_error_handler_; | 272 base::Closure catastrophic_error_handler_; |
| 271 | 273 |
| 272 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); | 274 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); |
| 273 }; | 275 }; |
| 274 | 276 |
| 275 } // namespace syncable | 277 } // namespace syncable |
| 276 } // namespace syncer | 278 } // namespace syncer |
| 277 | 279 |
| 278 #endif // COMPONENTS_SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ | 280 #endif // COMPONENTS_SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
| OLD | NEW |