| 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_H_ | 5 #ifndef SYNC_SYNCABLE_DIRECTORY_H_ |
| 6 #define SYNC_SYNCABLE_DIRECTORY_H_ | 6 #define SYNC_SYNCABLE_DIRECTORY_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "sync/base/sync_export.h" | 14 #include "sync/base/sync_export.h" |
| 15 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 15 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
| 16 #include "sync/internal_api/public/util/weak_handle.h" | 16 #include "sync/internal_api/public/util/weak_handle.h" |
| 17 #include "sync/syncable/delete_journal.h" | 17 #include "sync/syncable/delete_journal.h" |
| 18 #include "sync/syncable/dir_open_result.h" | 18 #include "sync/syncable/dir_open_result.h" |
| 19 #include "sync/syncable/entry_kernel.h" | 19 #include "sync/syncable/entry_kernel.h" |
| 20 #include "sync/syncable/metahandle_set.h" | 20 #include "sync/syncable/metahandle_set.h" |
| 21 #include "sync/syncable/scoped_kernel_lock.h" | 21 #include "sync/syncable/scoped_kernel_lock.h" |
| 22 | 22 |
| 23 namespace syncer { | 23 namespace syncer { |
| 24 | 24 |
| 25 class Cryptographer; | 25 class Cryptographer; |
| 26 class TestUserShare; |
| 26 class UnrecoverableErrorHandler; | 27 class UnrecoverableErrorHandler; |
| 27 | 28 |
| 28 namespace syncable { | 29 namespace syncable { |
| 29 | 30 |
| 30 class BaseTransaction; | 31 class BaseTransaction; |
| 31 class DirectoryChangeDelegate; | 32 class DirectoryChangeDelegate; |
| 32 class DirectoryBackingStore; | 33 class DirectoryBackingStore; |
| 33 class NigoriHandler; | 34 class NigoriHandler; |
| 34 class ScopedKernelLock; | 35 class ScopedKernelLock; |
| 35 class TransactionObserver; | 36 class TransactionObserver; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 class SYNC_EXPORT Directory { | 124 class SYNC_EXPORT Directory { |
| 124 friend class BaseTransaction; | 125 friend class BaseTransaction; |
| 125 friend class Entry; | 126 friend class Entry; |
| 126 friend class MutableEntry; | 127 friend class MutableEntry; |
| 127 friend class ReadTransaction; | 128 friend class ReadTransaction; |
| 128 friend class ReadTransactionWithoutDB; | 129 friend class ReadTransactionWithoutDB; |
| 129 friend class ScopedKernelLock; | 130 friend class ScopedKernelLock; |
| 130 friend class ScopedKernelUnlock; | 131 friend class ScopedKernelUnlock; |
| 131 friend class WriteTransaction; | 132 friend class WriteTransaction; |
| 132 friend class SyncableDirectoryTest; | 133 friend class SyncableDirectoryTest; |
| 134 friend class syncer::TestUserShare; |
| 133 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, ManageDeleteJournals); | 135 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, ManageDeleteJournals); |
| 134 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, | 136 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, |
| 135 TakeSnapshotGetsAllDirtyHandlesTest); | 137 TakeSnapshotGetsAllDirtyHandlesTest); |
| 136 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, | 138 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, |
| 137 TakeSnapshotGetsOnlyDirtyHandlesTest); | 139 TakeSnapshotGetsOnlyDirtyHandlesTest); |
| 138 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, | 140 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, |
| 139 TakeSnapshotGetsMetahandlesToPurge); | 141 TakeSnapshotGetsMetahandlesToPurge); |
| 140 | 142 |
| 141 public: | 143 public: |
| 142 static const FilePath::CharType kSyncDatabaseFilename[]; | 144 static const FilePath::CharType kSyncDatabaseFilename[]; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 report_unrecoverable_error_function_(); | 302 report_unrecoverable_error_function_(); |
| 301 } | 303 } |
| 302 } | 304 } |
| 303 | 305 |
| 304 // Called to set the unrecoverable error on the directory and to propagate | 306 // Called to set the unrecoverable error on the directory and to propagate |
| 305 // the error to upper layers. | 307 // the error to upper layers. |
| 306 void OnUnrecoverableError(const BaseTransaction* trans, | 308 void OnUnrecoverableError(const BaseTransaction* trans, |
| 307 const tracked_objects::Location& location, | 309 const tracked_objects::Location& location, |
| 308 const std::string & message); | 310 const std::string & message); |
| 309 | 311 |
| 312 DeleteJournal* delete_journal(); |
| 313 |
| 310 protected: // for friends, mainly used by Entry constructors | 314 protected: // for friends, mainly used by Entry constructors |
| 311 virtual EntryKernel* GetEntryByHandle(int64 handle); | 315 virtual EntryKernel* GetEntryByHandle(int64 handle); |
| 312 virtual EntryKernel* GetEntryByHandle(int64 metahandle, | 316 virtual EntryKernel* GetEntryByHandle(int64 metahandle, |
| 313 ScopedKernelLock* lock); | 317 ScopedKernelLock* lock); |
| 314 virtual EntryKernel* GetEntryById(const Id& id); | 318 virtual EntryKernel* GetEntryById(const Id& id); |
| 315 EntryKernel* GetEntryByServerTag(const std::string& tag); | 319 EntryKernel* GetEntryByServerTag(const std::string& tag); |
| 316 virtual EntryKernel* GetEntryByClientTag(const std::string& tag); | 320 virtual EntryKernel* GetEntryByClientTag(const std::string& tag); |
| 317 EntryKernel* GetRootEntry(); | 321 EntryKernel* GetRootEntry(); |
| 318 bool ReindexId(WriteTransaction* trans, EntryKernel* const entry, | 322 bool ReindexId(WriteTransaction* trans, EntryKernel* const entry, |
| 319 const Id& new_id); | 323 const Id& new_id); |
| 320 bool ReindexParentId(WriteTransaction* trans, EntryKernel* const entry, | 324 bool ReindexParentId(WriteTransaction* trans, EntryKernel* const entry, |
| 321 const Id& new_parent_id); | 325 const Id& new_parent_id); |
| 322 void ClearDirtyMetahandles(); | 326 void ClearDirtyMetahandles(); |
| 323 | 327 |
| 324 // These don't do semantic checking. | 328 // These don't do semantic checking. |
| 325 // The semantic checking is implemented higher up. | 329 // The semantic checking is implemented higher up. |
| 326 bool UnlinkEntryFromOrder(EntryKernel* entry, | 330 bool UnlinkEntryFromOrder(EntryKernel* entry, |
| 327 WriteTransaction* trans, | 331 WriteTransaction* trans, |
| 328 ScopedKernelLock* lock, | 332 ScopedKernelLock* lock, |
| 329 UnlinkReason unlink_reason); | 333 UnlinkReason unlink_reason); |
| 330 | 334 |
| 331 DirOpenResult OpenImpl( | 335 DirOpenResult OpenImpl( |
| 332 const std::string& name, | 336 const std::string& name, |
| 333 DirectoryChangeDelegate* delegate, | 337 DirectoryChangeDelegate* delegate, |
| 334 const WeakHandle<TransactionObserver>& transaction_observer); | 338 const WeakHandle<TransactionObserver>& transaction_observer); |
| 335 | 339 |
| 336 DeleteJournal* delete_journal(); | |
| 337 | |
| 338 private: | 340 private: |
| 339 // These private versions expect the kernel lock to already be held | 341 // These private versions expect the kernel lock to already be held |
| 340 // before calling. | 342 // before calling. |
| 341 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); | 343 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); |
| 342 | 344 |
| 343 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set); | 345 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set); |
| 344 | 346 |
| 345 public: | 347 public: |
| 346 typedef std::vector<int64> ChildHandles; | 348 typedef std::vector<int64> ChildHandles; |
| 347 | 349 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 | 635 |
| 634 // Maintain deleted entries not in |kernel_| until it's verified that they | 636 // Maintain deleted entries not in |kernel_| until it's verified that they |
| 635 // are deleted in native models as well. | 637 // are deleted in native models as well. |
| 636 scoped_ptr<DeleteJournal> delete_journal_; | 638 scoped_ptr<DeleteJournal> delete_journal_; |
| 637 }; | 639 }; |
| 638 | 640 |
| 639 } // namespace syncable | 641 } // namespace syncable |
| 640 } // namespace syncer | 642 } // namespace syncer |
| 641 | 643 |
| 642 #endif // SYNC_SYNCABLE_DIRECTORY_H_ | 644 #endif // SYNC_SYNCABLE_DIRECTORY_H_ |
| OLD | NEW |