| 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 <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 VERIFY_CHANGES = 1, // Checks only mutated entries. Does not check hierarchy. | 48 VERIFY_CHANGES = 1, // Checks only mutated entries. Does not check hierarchy. |
| 49 FULL_DB_VERIFICATION = 2 // Check every entry. This can be expensive. | 49 FULL_DB_VERIFICATION = 2 // Check every entry. This can be expensive. |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // Directory stores and manages EntryKernels. | 52 // Directory stores and manages EntryKernels. |
| 53 // | 53 // |
| 54 // This class is tightly coupled to several other classes via Directory::Kernel. | 54 // This class is tightly coupled to several other classes via Directory::Kernel. |
| 55 // Although Directory's kernel_ is exposed via public accessor it should be | 55 // Although Directory's kernel_ is exposed via public accessor it should be |
| 56 // treated as pseudo-private. | 56 // treated as pseudo-private. |
| 57 class SYNC_EXPORT Directory { | 57 class SYNC_EXPORT Directory { |
| 58 friend class SyncableDirectoryTest; | |
| 59 friend class syncer::TestUserShare; | |
| 60 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, ManageDeleteJournals); | |
| 61 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, | |
| 62 TakeSnapshotGetsAllDirtyHandlesTest); | |
| 63 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, | |
| 64 TakeSnapshotGetsOnlyDirtyHandlesTest); | |
| 65 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, | |
| 66 TakeSnapshotGetsMetahandlesToPurge); | |
| 67 | |
| 68 public: | 58 public: |
| 69 typedef std::vector<int64> Metahandles; | 59 typedef std::vector<int64> Metahandles; |
| 70 | 60 |
| 71 // Be careful when using these hash_map containers. According to the spec, | 61 // Be careful when using these hash_map containers. According to the spec, |
| 72 // inserting into them may invalidate all iterators. | 62 // inserting into them may invalidate all iterators. |
| 73 // | 63 // |
| 74 // It gets worse, though. The Anroid STL library has a bug that means it may | 64 // It gets worse, though. The Anroid STL library has a bug that means it may |
| 75 // invalidate all iterators when you erase from the map, too. That means that | 65 // invalidate all iterators when you erase from the map, too. That means that |
| 76 // you can't iterate while erasing. STLDeleteElements(), std::remove_if(), | 66 // you can't iterate while erasing. STLDeleteElements(), std::remove_if(), |
| 77 // and other similar functions are off-limits too, until this bug is fixed. | 67 // and other similar functions are off-limits too, until this bug is fixed. |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 523 |
| 534 bool ReindexParentId(BaseWriteTransaction* trans, EntryKernel* const entry, | 524 bool ReindexParentId(BaseWriteTransaction* trans, EntryKernel* const entry, |
| 535 const Id& new_parent_id); | 525 const Id& new_parent_id); |
| 536 | 526 |
| 537 // Accessors for the underlying Kernel. Although these are public methods, the | 527 // Accessors for the underlying Kernel. Although these are public methods, the |
| 538 // number of classes that call these should be limited. | 528 // number of classes that call these should be limited. |
| 539 Kernel* kernel(); | 529 Kernel* kernel(); |
| 540 const Kernel* kernel() const; | 530 const Kernel* kernel() const; |
| 541 | 531 |
| 542 private: | 532 private: |
| 533 friend class SyncableDirectoryTest; |
| 534 friend class syncer::TestUserShare; |
| 535 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, ManageDeleteJournals); |
| 536 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, |
| 537 TakeSnapshotGetsAllDirtyHandlesTest); |
| 538 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, |
| 539 TakeSnapshotGetsOnlyDirtyHandlesTest); |
| 540 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, |
| 541 TakeSnapshotGetsMetahandlesToPurge); |
| 542 |
| 543 // You'll notice that some of the methods below are private overloads of the | 543 // You'll notice that some of the methods below are private overloads of the |
| 544 // public ones declared above. The general pattern is that the public overload | 544 // public ones declared above. The general pattern is that the public overload |
| 545 // constructs a ScopedKernelLock before calling the corresponding private | 545 // constructs a ScopedKernelLock before calling the corresponding private |
| 546 // overload with the held ScopedKernelLock. | 546 // overload with the held ScopedKernelLock. |
| 547 | 547 |
| 548 virtual EntryKernel* GetEntryByHandle(const ScopedKernelLock& lock, | 548 virtual EntryKernel* GetEntryByHandle(const ScopedKernelLock& lock, |
| 549 int64 metahandle); | 549 int64 metahandle); |
| 550 | 550 |
| 551 virtual EntryKernel* GetEntryById(const ScopedKernelLock& lock, const Id& id); | 551 virtual EntryKernel* GetEntryById(const ScopedKernelLock& lock, const Id& id); |
| 552 | 552 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 // are deleted in native models as well. | 650 // are deleted in native models as well. |
| 651 scoped_ptr<DeleteJournal> delete_journal_; | 651 scoped_ptr<DeleteJournal> delete_journal_; |
| 652 | 652 |
| 653 DISALLOW_COPY_AND_ASSIGN(Directory); | 653 DISALLOW_COPY_AND_ASSIGN(Directory); |
| 654 }; | 654 }; |
| 655 | 655 |
| 656 } // namespace syncable | 656 } // namespace syncable |
| 657 } // namespace syncer | 657 } // namespace syncer |
| 658 | 658 |
| 659 #endif // SYNC_SYNCABLE_DIRECTORY_H_ | 659 #endif // SYNC_SYNCABLE_DIRECTORY_H_ |
| OLD | NEW |