OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_H_ | 5 #ifndef SYNC_SYNCABLE_DIRECTORY_H_ |
6 #define SYNC_SYNCABLE_DIRECTORY_H_ | 6 #define SYNC_SYNCABLE_DIRECTORY_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <deque> | 11 #include <deque> |
9 #include <set> | 12 #include <set> |
10 #include <string> | 13 #include <string> |
11 #include <vector> | 14 #include <vector> |
12 | 15 |
13 #include "base/basictypes.h" | |
14 #include "base/callback.h" | 16 #include "base/callback.h" |
15 #include "base/containers/hash_tables.h" | 17 #include "base/containers/hash_tables.h" |
16 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
17 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
| 20 #include "base/macros.h" |
18 #include "base/values.h" | 21 #include "base/values.h" |
19 #include "sync/api/attachments/attachment_id.h" | 22 #include "sync/api/attachments/attachment_id.h" |
20 #include "sync/base/sync_export.h" | 23 #include "sync/base/sync_export.h" |
21 #include "sync/internal_api/public/util/weak_handle.h" | 24 #include "sync/internal_api/public/util/weak_handle.h" |
22 #include "sync/syncable/dir_open_result.h" | 25 #include "sync/syncable/dir_open_result.h" |
23 #include "sync/syncable/entry.h" | 26 #include "sync/syncable/entry.h" |
24 #include "sync/syncable/entry_kernel.h" | 27 #include "sync/syncable/entry_kernel.h" |
25 #include "sync/syncable/metahandle_set.h" | 28 #include "sync/syncable/metahandle_set.h" |
26 #include "sync/syncable/parent_child_index.h" | 29 #include "sync/syncable/parent_child_index.h" |
27 #include "sync/syncable/syncable_delete_journal.h" | 30 #include "sync/syncable/syncable_delete_journal.h" |
(...skipping 22 matching lines...) Expand all Loading... |
50 FULL_DB_VERIFICATION = 2 // Check every entry. This can be expensive. | 53 FULL_DB_VERIFICATION = 2 // Check every entry. This can be expensive. |
51 }; | 54 }; |
52 | 55 |
53 // Directory stores and manages EntryKernels. | 56 // Directory stores and manages EntryKernels. |
54 // | 57 // |
55 // This class is tightly coupled to several other classes via Directory::Kernel. | 58 // This class is tightly coupled to several other classes via Directory::Kernel. |
56 // Although Directory's kernel_ is exposed via public accessor it should be | 59 // Although Directory's kernel_ is exposed via public accessor it should be |
57 // treated as pseudo-private. | 60 // treated as pseudo-private. |
58 class SYNC_EXPORT Directory { | 61 class SYNC_EXPORT Directory { |
59 public: | 62 public: |
60 typedef std::vector<int64> Metahandles; | 63 typedef std::vector<int64_t> Metahandles; |
61 | 64 |
62 // TODO(skym): Convert this hash_map usage to unordered_map, crbug/567280. | 65 // TODO(skym): Convert this hash_map usage to unordered_map, crbug/567280. |
63 // Be careful when using these hash_map containers. According to the spec, | 66 // Be careful when using these hash_map containers. According to the spec, |
64 // inserting into them may invalidate all iterators. | 67 // inserting into them may invalidate all iterators. |
65 // | 68 // |
66 // It gets worse, though. The Anroid STL library has a bug that means it may | 69 // It gets worse, though. The Anroid STL library has a bug that means it may |
67 // invalidate all iterators when you erase from the map, too. That means that | 70 // invalidate all iterators when you erase from the map, too. That means that |
68 // you can't iterate while erasing. STLDeleteElements(), std::remove_if(), | 71 // you can't iterate while erasing. STLDeleteElements(), std::remove_if(), |
69 // and other similar functions are off-limits too, until this bug is fixed. | 72 // and other similar functions are off-limits too, until this bug is fixed. |
70 // | 73 // |
71 // See http://sourceforge.net/p/stlport/bugs/239/. | 74 // See http://sourceforge.net/p/stlport/bugs/239/. |
72 typedef base::hash_map<int64, EntryKernel*> MetahandlesMap; | 75 typedef base::hash_map<int64_t, EntryKernel*> MetahandlesMap; |
73 typedef base::hash_map<std::string, EntryKernel*> IdsMap; | 76 typedef base::hash_map<std::string, EntryKernel*> IdsMap; |
74 typedef base::hash_map<std::string, EntryKernel*> TagsMap; | 77 typedef base::hash_map<std::string, EntryKernel*> TagsMap; |
75 typedef std::string AttachmentIdUniqueId; | 78 typedef std::string AttachmentIdUniqueId; |
76 typedef base::hash_map<AttachmentIdUniqueId, MetahandleSet> | 79 typedef base::hash_map<AttachmentIdUniqueId, MetahandleSet> |
77 IndexByAttachmentId; | 80 IndexByAttachmentId; |
78 | 81 |
79 static const base::FilePath::CharType kSyncDatabaseFilename[]; | 82 static const base::FilePath::CharType kSyncDatabaseFilename[]; |
80 | 83 |
81 // The dirty/clean state of kernel fields backed by the share_info table. | 84 // The dirty/clean state of kernel fields backed by the share_info table. |
82 // This is public so it can be used in SaveChangesSnapshot for persistence. | 85 // This is public so it can be used in SaveChangesSnapshot for persistence. |
(...skipping 18 matching lines...) Expand all Loading... |
101 bool HasEmptyDownloadProgress(ModelType model_type); | 104 bool HasEmptyDownloadProgress(ModelType model_type); |
102 | 105 |
103 // Last sync timestamp fetched from the server. | 106 // Last sync timestamp fetched from the server. |
104 sync_pb::DataTypeProgressMarker download_progress[MODEL_TYPE_COUNT]; | 107 sync_pb::DataTypeProgressMarker download_progress[MODEL_TYPE_COUNT]; |
105 // Sync-side transaction version per data type. Monotonically incremented | 108 // Sync-side transaction version per data type. Monotonically incremented |
106 // when updating native model. A copy is also saved in native model. | 109 // when updating native model. A copy is also saved in native model. |
107 // Later out-of-sync models can be detected and fixed by comparing | 110 // Later out-of-sync models can be detected and fixed by comparing |
108 // transaction versions of sync model and native model. | 111 // transaction versions of sync model and native model. |
109 // TODO(hatiaol): implement detection and fixing of out-of-sync models. | 112 // TODO(hatiaol): implement detection and fixing of out-of-sync models. |
110 // Bug 154858. | 113 // Bug 154858. |
111 int64 transaction_version[MODEL_TYPE_COUNT]; | 114 int64_t transaction_version[MODEL_TYPE_COUNT]; |
112 // The store birthday we were given by the server. Contents are opaque to | 115 // The store birthday we were given by the server. Contents are opaque to |
113 // the client. | 116 // the client. |
114 std::string store_birthday; | 117 std::string store_birthday; |
115 // The serialized bag of chips we were given by the server. Contents are | 118 // The serialized bag of chips we were given by the server. Contents are |
116 // opaque to the client. This is the serialization of a message of type | 119 // opaque to the client. This is the serialization of a message of type |
117 // ChipBag defined in sync.proto. It can contains NULL characters. | 120 // ChipBag defined in sync.proto. It can contains NULL characters. |
118 std::string bag_of_chips; | 121 std::string bag_of_chips; |
119 // The per-datatype context. | 122 // The per-datatype context. |
120 sync_pb::DataTypeContext datatype_context[MODEL_TYPE_COUNT]; | 123 sync_pb::DataTypeContext datatype_context[MODEL_TYPE_COUNT]; |
121 }; | 124 }; |
122 | 125 |
123 // What the Directory needs on initialization to create itself and its Kernel. | 126 // What the Directory needs on initialization to create itself and its Kernel. |
124 // Filled by DirectoryBackingStore::Load. | 127 // Filled by DirectoryBackingStore::Load. |
125 struct KernelLoadInfo { | 128 struct KernelLoadInfo { |
126 PersistedKernelInfo kernel_info; | 129 PersistedKernelInfo kernel_info; |
127 std::string cache_guid; // Created on first initialization, never changes. | 130 std::string cache_guid; // Created on first initialization, never changes. |
128 int64 max_metahandle; // Computed (using sql MAX aggregate) on init. | 131 int64_t max_metahandle; // Computed (using sql MAX aggregate) on init. |
129 KernelLoadInfo() : max_metahandle(0) { | 132 KernelLoadInfo() : max_metahandle(0) { |
130 } | 133 } |
131 }; | 134 }; |
132 | 135 |
133 // When the Directory is told to SaveChanges, a SaveChangesSnapshot is | 136 // When the Directory is told to SaveChanges, a SaveChangesSnapshot is |
134 // constructed and forms a consistent snapshot of what needs to be sent to | 137 // constructed and forms a consistent snapshot of what needs to be sent to |
135 // the backing store. | 138 // the backing store. |
136 struct SYNC_EXPORT SaveChangesSnapshot { | 139 struct SYNC_EXPORT SaveChangesSnapshot { |
137 SaveChangesSnapshot(); | 140 SaveChangesSnapshot(); |
138 ~SaveChangesSnapshot(); | 141 ~SaveChangesSnapshot(); |
(...skipping 15 matching lines...) Expand all Loading... |
154 Kernel(const std::string& name, const KernelLoadInfo& info, | 157 Kernel(const std::string& name, const KernelLoadInfo& info, |
155 DirectoryChangeDelegate* delegate, | 158 DirectoryChangeDelegate* delegate, |
156 const WeakHandle<TransactionObserver>& transaction_observer); | 159 const WeakHandle<TransactionObserver>& transaction_observer); |
157 | 160 |
158 ~Kernel(); | 161 ~Kernel(); |
159 | 162 |
160 // Implements ReadTransaction / WriteTransaction using a simple lock. | 163 // Implements ReadTransaction / WriteTransaction using a simple lock. |
161 base::Lock transaction_mutex; | 164 base::Lock transaction_mutex; |
162 | 165 |
163 // Protected by transaction_mutex. Used by WriteTransactions. | 166 // Protected by transaction_mutex. Used by WriteTransactions. |
164 int64 next_write_transaction_id; | 167 int64_t next_write_transaction_id; |
165 | 168 |
166 // The name of this directory. | 169 // The name of this directory. |
167 std::string const name; | 170 std::string const name; |
168 | 171 |
169 // Protects all members below. | 172 // Protects all members below. |
170 // The mutex effectively protects all the indices, but not the | 173 // The mutex effectively protects all the indices, but not the |
171 // entries themselves. So once a pointer to an entry is pulled | 174 // entries themselves. So once a pointer to an entry is pulled |
172 // from the index, the mutex can be unlocked and entry read or written. | 175 // from the index, the mutex can be unlocked and entry read or written. |
173 // | 176 // |
174 // Never hold the mutex and do anything with the database or any | 177 // Never hold the mutex and do anything with the database or any |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 234 |
232 // A unique identifier for this account's cache db, used to generate | 235 // A unique identifier for this account's cache db, used to generate |
233 // unique server IDs. No need to lock, only written at init time. | 236 // unique server IDs. No need to lock, only written at init time. |
234 const std::string cache_guid; | 237 const std::string cache_guid; |
235 | 238 |
236 // It doesn't make sense for two threads to run SaveChanges at the same | 239 // It doesn't make sense for two threads to run SaveChanges at the same |
237 // time; this mutex protects that activity. | 240 // time; this mutex protects that activity. |
238 base::Lock save_changes_mutex; | 241 base::Lock save_changes_mutex; |
239 | 242 |
240 // The next metahandle is protected by kernel mutex. | 243 // The next metahandle is protected by kernel mutex. |
241 int64 next_metahandle; | 244 int64_t next_metahandle; |
242 | 245 |
243 // The delegate for directory change events. Must not be NULL. | 246 // The delegate for directory change events. Must not be NULL. |
244 DirectoryChangeDelegate* const delegate; | 247 DirectoryChangeDelegate* const delegate; |
245 | 248 |
246 // The transaction observer. | 249 // The transaction observer. |
247 const WeakHandle<TransactionObserver> transaction_observer; | 250 const WeakHandle<TransactionObserver> transaction_observer; |
248 }; | 251 }; |
249 | 252 |
250 // Does not take ownership of |encryptor|. | 253 // Does not take ownership of |encryptor|. |
251 // |report_unrecoverable_error_function| may be NULL. | 254 // |report_unrecoverable_error_function| may be NULL. |
252 // Takes ownership of |store|. | 255 // Takes ownership of |store|. |
253 Directory( | 256 Directory( |
254 DirectoryBackingStore* store, | 257 DirectoryBackingStore* store, |
255 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, | 258 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
256 const base::Closure& report_unrecoverable_error_function, | 259 const base::Closure& report_unrecoverable_error_function, |
257 NigoriHandler* nigori_handler, | 260 NigoriHandler* nigori_handler, |
258 Cryptographer* cryptographer); | 261 Cryptographer* cryptographer); |
259 virtual ~Directory(); | 262 virtual ~Directory(); |
260 | 263 |
261 // Does not take ownership of |delegate|, which must not be NULL. | 264 // Does not take ownership of |delegate|, which must not be NULL. |
262 // Starts sending events to |delegate| if the returned result is | 265 // Starts sending events to |delegate| if the returned result is |
263 // OPENED. Note that events to |delegate| may be sent from *any* | 266 // OPENED. Note that events to |delegate| may be sent from *any* |
264 // thread. |transaction_observer| must be initialized. | 267 // thread. |transaction_observer| must be initialized. |
265 DirOpenResult Open(const std::string& name, | 268 DirOpenResult Open(const std::string& name, |
266 DirectoryChangeDelegate* delegate, | 269 DirectoryChangeDelegate* delegate, |
267 const WeakHandle<TransactionObserver>& | 270 const WeakHandle<TransactionObserver>& |
268 transaction_observer); | 271 transaction_observer); |
269 | 272 |
270 int64 NextMetahandle(); | 273 int64_t NextMetahandle(); |
271 // Generates next client ID based on a randomly generated GUID. | 274 // Generates next client ID based on a randomly generated GUID. |
272 syncable::Id NextId(); | 275 syncable::Id NextId(); |
273 | 276 |
274 bool good() const { return NULL != kernel_; } | 277 bool good() const { return NULL != kernel_; } |
275 | 278 |
276 // The download progress is an opaque token provided by the sync server | 279 // The download progress is an opaque token provided by the sync server |
277 // to indicate the continuation state of the next GetUpdates operation. | 280 // to indicate the continuation state of the next GetUpdates operation. |
278 void GetDownloadProgress( | 281 void GetDownloadProgress( |
279 ModelType type, | 282 ModelType type, |
280 sync_pb::DataTypeProgressMarker* value_out) const; | 283 sync_pb::DataTypeProgressMarker* value_out) const; |
281 void GetDownloadProgressAsString( | 284 void GetDownloadProgressAsString( |
282 ModelType type, | 285 ModelType type, |
283 std::string* value_out) const; | 286 std::string* value_out) const; |
284 void SetDownloadProgress( | 287 void SetDownloadProgress( |
285 ModelType type, | 288 ModelType type, |
286 const sync_pb::DataTypeProgressMarker& value); | 289 const sync_pb::DataTypeProgressMarker& value); |
287 bool HasEmptyDownloadProgress(ModelType type) const; | 290 bool HasEmptyDownloadProgress(ModelType type) const; |
288 | 291 |
289 // Gets the total number of entries in the directory. | 292 // Gets the total number of entries in the directory. |
290 size_t GetEntriesCount() const; | 293 size_t GetEntriesCount() const; |
291 | 294 |
292 // Gets/Increments transaction version of a model type. Must be called when | 295 // Gets/Increments transaction version of a model type. Must be called when |
293 // holding kernel mutex. | 296 // holding kernel mutex. |
294 int64 GetTransactionVersion(ModelType type) const; | 297 int64_t GetTransactionVersion(ModelType type) const; |
295 void IncrementTransactionVersion(ModelType type); | 298 void IncrementTransactionVersion(ModelType type); |
296 | 299 |
297 // Getter/setters for the per datatype context. | 300 // Getter/setters for the per datatype context. |
298 void GetDataTypeContext(BaseTransaction* trans, | 301 void GetDataTypeContext(BaseTransaction* trans, |
299 ModelType type, | 302 ModelType type, |
300 sync_pb::DataTypeContext* context) const; | 303 sync_pb::DataTypeContext* context) const; |
301 void SetDataTypeContext(BaseWriteTransaction* trans, | 304 void SetDataTypeContext(BaseWriteTransaction* trans, |
302 ModelType type, | 305 ModelType type, |
303 const sync_pb::DataTypeContext& context); | 306 const sync_pb::DataTypeContext& context); |
304 | 307 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // state and indices (by deep copy) under a ReadTransaction, passing this | 395 // state and indices (by deep copy) under a ReadTransaction, passing this |
393 // snapshot to the backing store under no transaction, and finally cleaning | 396 // snapshot to the backing store under no transaction, and finally cleaning |
394 // up by either purging entries no longer needed (this part done under a | 397 // up by either purging entries no longer needed (this part done under a |
395 // WriteTransaction) or rolling back the dirty bits. It also uses | 398 // WriteTransaction) or rolling back the dirty bits. It also uses |
396 // internal locking to enforce SaveChanges operations are mutually exclusive. | 399 // internal locking to enforce SaveChanges operations are mutually exclusive. |
397 // | 400 // |
398 // WARNING: THIS METHOD PERFORMS SYNCHRONOUS I/O VIA SQLITE. | 401 // WARNING: THIS METHOD PERFORMS SYNCHRONOUS I/O VIA SQLITE. |
399 bool SaveChanges(); | 402 bool SaveChanges(); |
400 | 403 |
401 // Returns the number of entities with the unsynced bit set. | 404 // Returns the number of entities with the unsynced bit set. |
402 int64 unsynced_entity_count() const; | 405 int64_t unsynced_entity_count() const; |
403 | 406 |
404 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and | 407 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and |
405 // before any new entries have been created. The intention is that the | 408 // before any new entries have been created. The intention is that the |
406 // syncer should call it from its PerformSyncQueries member. | 409 // syncer should call it from its PerformSyncQueries member. |
407 void GetUnsyncedMetaHandles(BaseTransaction* trans, | 410 void GetUnsyncedMetaHandles(BaseTransaction* trans, |
408 Metahandles* result); | 411 Metahandles* result); |
409 | 412 |
410 // Returns whether or not this |type| has unapplied updates. | 413 // Returns whether or not this |type| has unapplied updates. |
411 bool TypeHasUnappliedUpdates(ModelType type); | 414 bool TypeHasUnappliedUpdates(ModelType type); |
412 | 415 |
413 // Get all the metahandles for unapplied updates for a given set of | 416 // Get all the metahandles for unapplied updates for a given set of |
414 // server types. | 417 // server types. |
415 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, | 418 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, |
416 FullModelTypeSet server_types, | 419 FullModelTypeSet server_types, |
417 std::vector<int64>* result); | 420 std::vector<int64_t>* result); |
418 | 421 |
419 // Get all the metahandles of entries of |type|. | 422 // Get all the metahandles of entries of |type|. |
420 void GetMetaHandlesOfType(BaseTransaction* trans, | 423 void GetMetaHandlesOfType(BaseTransaction* trans, |
421 ModelType type, | 424 ModelType type, |
422 Metahandles* result); | 425 Metahandles* result); |
423 | 426 |
424 // Get metahandle counts for various criteria to show on the | 427 // Get metahandle counts for various criteria to show on the |
425 // about:sync page. The information is computed on the fly | 428 // about:sync page. The information is computed on the fly |
426 // each time. If this results in a significant performance hit, | 429 // each time. If this results in a significant performance hit, |
427 // additional data structures can be added to cache results. | 430 // additional data structures can be added to cache results. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 // uploaded to the sync server. | 501 // uploaded to the sync server. |
499 void GetAttachmentIdsToUpload(BaseTransaction* trans, | 502 void GetAttachmentIdsToUpload(BaseTransaction* trans, |
500 ModelType type, | 503 ModelType type, |
501 AttachmentIdList* ids); | 504 AttachmentIdList* ids); |
502 | 505 |
503 // For new entry creation only. | 506 // For new entry creation only. |
504 bool InsertEntry(BaseWriteTransaction* trans, EntryKernel* entry); | 507 bool InsertEntry(BaseWriteTransaction* trans, EntryKernel* entry); |
505 | 508 |
506 // Update the attachment index for |metahandle| removing it from the index | 509 // Update the attachment index for |metahandle| removing it from the index |
507 // under |old_metadata| entries and add it under |new_metadata| entries. | 510 // under |old_metadata| entries and add it under |new_metadata| entries. |
508 void UpdateAttachmentIndex(const int64 metahandle, | 511 void UpdateAttachmentIndex(const int64_t metahandle, |
509 const sync_pb::AttachmentMetadata& old_metadata, | 512 const sync_pb::AttachmentMetadata& old_metadata, |
510 const sync_pb::AttachmentMetadata& new_metadata); | 513 const sync_pb::AttachmentMetadata& new_metadata); |
511 | 514 |
512 virtual EntryKernel* GetEntryById(const Id& id); | 515 virtual EntryKernel* GetEntryById(const Id& id); |
513 virtual EntryKernel* GetEntryByClientTag(const std::string& tag); | 516 virtual EntryKernel* GetEntryByClientTag(const std::string& tag); |
514 EntryKernel* GetEntryByServerTag(const std::string& tag); | 517 EntryKernel* GetEntryByServerTag(const std::string& tag); |
515 | 518 |
516 virtual EntryKernel* GetEntryByHandle(int64 handle); | 519 virtual EntryKernel* GetEntryByHandle(int64_t handle); |
517 | 520 |
518 bool ReindexId(BaseWriteTransaction* trans, EntryKernel* const entry, | 521 bool ReindexId(BaseWriteTransaction* trans, EntryKernel* const entry, |
519 const Id& new_id); | 522 const Id& new_id); |
520 | 523 |
521 bool ReindexParentId(BaseWriteTransaction* trans, EntryKernel* const entry, | 524 bool ReindexParentId(BaseWriteTransaction* trans, EntryKernel* const entry, |
522 const Id& new_parent_id); | 525 const Id& new_parent_id); |
523 | 526 |
524 // Accessors for the underlying Kernel. Although these are public methods, the | 527 // Accessors for the underlying Kernel. Although these are public methods, the |
525 // number of classes that call these should be limited. | 528 // number of classes that call these should be limited. |
526 Kernel* kernel(); | 529 Kernel* kernel(); |
(...skipping 10 matching lines...) Expand all Loading... |
537 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, | 540 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, |
538 TakeSnapshotGetsMetahandlesToPurge); | 541 TakeSnapshotGetsMetahandlesToPurge); |
539 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, CatastrophicError); | 542 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, CatastrophicError); |
540 | 543 |
541 // You'll notice that some of the methods below are private overloads of the | 544 // You'll notice that some of the methods below are private overloads of the |
542 // public ones declared above. The general pattern is that the public overload | 545 // public ones declared above. The general pattern is that the public overload |
543 // constructs a ScopedKernelLock before calling the corresponding private | 546 // constructs a ScopedKernelLock before calling the corresponding private |
544 // overload with the held ScopedKernelLock. | 547 // overload with the held ScopedKernelLock. |
545 | 548 |
546 virtual EntryKernel* GetEntryByHandle(const ScopedKernelLock& lock, | 549 virtual EntryKernel* GetEntryByHandle(const ScopedKernelLock& lock, |
547 int64 metahandle); | 550 int64_t metahandle); |
548 | 551 |
549 virtual EntryKernel* GetEntryById(const ScopedKernelLock& lock, const Id& id); | 552 virtual EntryKernel* GetEntryById(const ScopedKernelLock& lock, const Id& id); |
550 | 553 |
551 bool InsertEntry(const ScopedKernelLock& lock, | 554 bool InsertEntry(const ScopedKernelLock& lock, |
552 BaseWriteTransaction* trans, | 555 BaseWriteTransaction* trans, |
553 EntryKernel* entry); | 556 EntryKernel* entry); |
554 | 557 |
555 // Remove each of |metahandle|'s attachment ids from index_by_attachment_id. | 558 // Remove each of |metahandle|'s attachment ids from index_by_attachment_id. |
556 void RemoveFromAttachmentIndex( | 559 void RemoveFromAttachmentIndex( |
557 const ScopedKernelLock& lock, | 560 const ScopedKernelLock& lock, |
558 const int64 metahandle, | 561 const int64_t metahandle, |
559 const sync_pb::AttachmentMetadata& attachment_metadata); | 562 const sync_pb::AttachmentMetadata& attachment_metadata); |
560 | 563 |
561 // Add each of |metahandle|'s attachment ids to the index_by_attachment_id. | 564 // Add each of |metahandle|'s attachment ids to the index_by_attachment_id. |
562 void AddToAttachmentIndex( | 565 void AddToAttachmentIndex( |
563 const ScopedKernelLock& lock, | 566 const ScopedKernelLock& lock, |
564 const int64 metahandle, | 567 const int64_t metahandle, |
565 const sync_pb::AttachmentMetadata& attachment_metadata); | 568 const sync_pb::AttachmentMetadata& attachment_metadata); |
566 | 569 |
567 void ClearDirtyMetahandles(const ScopedKernelLock& lock); | 570 void ClearDirtyMetahandles(const ScopedKernelLock& lock); |
568 | 571 |
569 DirOpenResult OpenImpl( | 572 DirOpenResult OpenImpl( |
570 const std::string& name, | 573 const std::string& name, |
571 DirectoryChangeDelegate* delegate, | 574 DirectoryChangeDelegate* delegate, |
572 const WeakHandle<TransactionObserver>& transaction_observer); | 575 const WeakHandle<TransactionObserver>& transaction_observer); |
573 | 576 |
574 // A helper that implements the logic of checking tree invariants. | 577 // A helper that implements the logic of checking tree invariants. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 void DeleteEntry(const ScopedKernelLock& lock, | 620 void DeleteEntry(const ScopedKernelLock& lock, |
618 bool save_to_journal, | 621 bool save_to_journal, |
619 EntryKernel* entry, | 622 EntryKernel* entry, |
620 EntryKernelSet* entries_to_journal); | 623 EntryKernelSet* entries_to_journal); |
621 | 624 |
622 // A private version of the public GetMetaHandlesOfType for when you already | 625 // A private version of the public GetMetaHandlesOfType for when you already |
623 // have a ScopedKernelLock. | 626 // have a ScopedKernelLock. |
624 void GetMetaHandlesOfType(const ScopedKernelLock& lock, | 627 void GetMetaHandlesOfType(const ScopedKernelLock& lock, |
625 BaseTransaction* trans, | 628 BaseTransaction* trans, |
626 ModelType type, | 629 ModelType type, |
627 std::vector<int64>* result); | 630 std::vector<int64_t>* result); |
628 | 631 |
629 // Invoked by DirectoryBackingStore when a catastrophic database error is | 632 // Invoked by DirectoryBackingStore when a catastrophic database error is |
630 // detected. | 633 // detected. |
631 void OnCatastrophicError(); | 634 void OnCatastrophicError(); |
632 | 635 |
633 // Stops sending events to the delegate and the transaction | 636 // Stops sending events to the delegate and the transaction |
634 // observer. | 637 // observer. |
635 void Close(); | 638 void Close(); |
636 | 639 |
637 // Returns true if the directory had encountered an unrecoverable error. | 640 // Returns true if the directory had encountered an unrecoverable error. |
(...skipping 22 matching lines...) Expand all Loading... |
660 | 663 |
661 base::WeakPtrFactory<Directory> weak_ptr_factory_; | 664 base::WeakPtrFactory<Directory> weak_ptr_factory_; |
662 | 665 |
663 DISALLOW_COPY_AND_ASSIGN(Directory); | 666 DISALLOW_COPY_AND_ASSIGN(Directory); |
664 }; | 667 }; |
665 | 668 |
666 } // namespace syncable | 669 } // namespace syncable |
667 } // namespace syncer | 670 } // namespace syncer |
668 | 671 |
669 #endif // SYNC_SYNCABLE_DIRECTORY_H_ | 672 #endif // SYNC_SYNCABLE_DIRECTORY_H_ |
OLD | NEW |