OLD | NEW |
1 // Copyright (c) 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" |
11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
12 #include "sql/connection.h" | 12 #include "sql/connection.h" |
13 #include "sql/statement.h" | 13 #include "sql/statement.h" |
| 14 #include "sync/base/sync_export.h" |
14 #include "sync/internal_api/public/base/model_type.h" | 15 #include "sync/internal_api/public/base/model_type.h" |
15 #include "sync/syncable/dir_open_result.h" | 16 #include "sync/syncable/dir_open_result.h" |
16 #include "sync/syncable/directory.h" | 17 #include "sync/syncable/directory.h" |
17 #include "sync/syncable/metahandle_set.h" | 18 #include "sync/syncable/metahandle_set.h" |
18 | 19 |
19 namespace sync_pb { | 20 namespace sync_pb { |
20 class EntitySpecifics; | 21 class EntitySpecifics; |
21 } | 22 } |
22 | 23 |
23 namespace syncer { | 24 namespace syncer { |
24 namespace syncable { | 25 namespace syncable { |
25 | 26 |
| 27 SYNC_EXPORT_PRIVATE extern const int32 kCurrentDBVersion; |
| 28 |
26 struct ColumnSpec; | 29 struct ColumnSpec; |
27 typedef Directory::MetahandlesIndex MetahandlesIndex; | 30 typedef Directory::MetahandlesIndex MetahandlesIndex; |
28 | 31 |
29 // Interface that provides persistence for a syncable::Directory object. You can | 32 // Interface that provides persistence for a syncable::Directory object. You can |
30 // load all the persisted data to prime a syncable::Directory on startup by | 33 // load all the persisted data to prime a syncable::Directory on startup by |
31 // invoking Load. The only other thing you (or more correctly, a Directory) can | 34 // invoking Load. The only other thing you (or more correctly, a Directory) can |
32 // do here is save any changes that have occurred since calling Load, which can | 35 // do here is save any changes that have occurred since calling Load, which can |
33 // be done periodically as often as desired. | 36 // be done periodically as often as desired. |
34 // | 37 // |
35 // The DirectoryBackingStore will own an sqlite lock on its database for most of | 38 // The DirectoryBackingStore will own an sqlite lock on its database for most of |
36 // its lifetime. You must not have two DirectoryBackingStore objects accessing | 39 // its lifetime. You must not have two DirectoryBackingStore objects accessing |
37 // the database simultaneously. Because the lock exists at the database level, | 40 // the database simultaneously. Because the lock exists at the database level, |
38 // not even two separate browser instances would be able to acquire it | 41 // not even two separate browser instances would be able to acquire it |
39 // simultaneously. | 42 // simultaneously. |
40 // | 43 // |
41 // This class is abstract so that we can extend it in interesting ways for use | 44 // This class is abstract so that we can extend it in interesting ways for use |
42 // in tests. The concrete class used in non-test scenarios is | 45 // in tests. The concrete class used in non-test scenarios is |
43 // OnDiskDirectoryBackingStore. | 46 // OnDiskDirectoryBackingStore. |
44 class DirectoryBackingStore : public base::NonThreadSafe { | 47 class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe { |
45 public: | 48 public: |
46 explicit DirectoryBackingStore(const std::string& dir_name); | 49 explicit DirectoryBackingStore(const std::string& dir_name); |
47 virtual ~DirectoryBackingStore(); | 50 virtual ~DirectoryBackingStore(); |
48 | 51 |
49 // Loads and drops all currently persisted meta entries into |entry_bucket| | 52 // Loads and drops all currently persisted meta entries into |entry_bucket| |
50 // and loads appropriate persisted kernel info into |info_bucket|. | 53 // and loads appropriate persisted kernel info into |info_bucket|. |
51 // | 54 // |
52 // This function can perform some cleanup tasks behind the scenes. It will | 55 // This function can perform some cleanup tasks behind the scenes. It will |
53 // clean up unused entries from the database and migrate to the latest | 56 // clean up unused entries from the database and migrate to the latest |
54 // database version. The caller can safely ignore these details. | 57 // database version. The caller can safely ignore these details. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // discarded. | 174 // discarded. |
172 bool needs_column_refresh_; | 175 bool needs_column_refresh_; |
173 | 176 |
174 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); | 177 DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); |
175 }; | 178 }; |
176 | 179 |
177 } // namespace syncable | 180 } // namespace syncable |
178 } // namespace syncer | 181 } // namespace syncer |
179 | 182 |
180 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ | 183 #endif // SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ |
OLD | NEW |