Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: sync/syncable/directory.h

Issue 11441026: [Sync] Add support for loading, updating and querying delete journals in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/syncable/delete_journal.cc ('k') | sync/syncable/directory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dir_open_result.h" 18 #include "sync/syncable/dir_open_result.h"
18 #include "sync/syncable/entry_kernel.h" 19 #include "sync/syncable/entry_kernel.h"
19 #include "sync/syncable/metahandle_set.h" 20 #include "sync/syncable/metahandle_set.h"
20 #include "sync/syncable/scoped_kernel_lock.h" 21 #include "sync/syncable/scoped_kernel_lock.h"
21 22
22 namespace syncer { 23 namespace syncer {
23 24
24 class Cryptographer; 25 class Cryptographer;
25 class UnrecoverableErrorHandler; 26 class UnrecoverableErrorHandler;
26 27
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 typedef std::set<EntryKernel*, typename Indexer::Comparator> Set; 107 typedef std::set<EntryKernel*, typename Indexer::Comparator> Set;
107 }; 108 };
108 109
109 // Reason for unlinking. 110 // Reason for unlinking.
110 enum UnlinkReason { 111 enum UnlinkReason {
111 NODE_MANIPULATION, // To be used by any operation manipulating the linked 112 NODE_MANIPULATION, // To be used by any operation manipulating the linked
112 // list. 113 // list.
113 DATA_TYPE_PURGE // To be used when purging a dataype. 114 DATA_TYPE_PURGE // To be used when purging a dataype.
114 }; 115 };
115 116
116 class EntryKernelLessByMetaHandle {
117 public:
118 inline bool operator()(const EntryKernel& a,
119 const EntryKernel& b) const {
120 return a.ref(META_HANDLE) < b.ref(META_HANDLE);
121 }
122 };
123
124 typedef std::set<EntryKernel, EntryKernelLessByMetaHandle> EntryKernelSet;
125
126 enum InvariantCheckLevel { 117 enum InvariantCheckLevel {
127 OFF = 0, // No checking. 118 OFF = 0, // No checking.
128 VERIFY_CHANGES = 1, // Checks only mutated entries. Does not check hierarchy. 119 VERIFY_CHANGES = 1, // Checks only mutated entries. Does not check hierarchy.
129 FULL_DB_VERIFICATION = 2 // Check every entry. This can be expensive. 120 FULL_DB_VERIFICATION = 2 // Check every entry. This can be expensive.
130 }; 121 };
131 122
132 class SYNC_EXPORT Directory { 123 class SYNC_EXPORT Directory {
133 friend class BaseTransaction; 124 friend class BaseTransaction;
134 friend class Entry; 125 friend class Entry;
135 friend class MutableEntry; 126 friend class MutableEntry;
136 friend class ReadTransaction; 127 friend class ReadTransaction;
137 friend class ReadTransactionWithoutDB; 128 friend class ReadTransactionWithoutDB;
138 friend class ScopedKernelLock; 129 friend class ScopedKernelLock;
139 friend class ScopedKernelUnlock; 130 friend class ScopedKernelUnlock;
140 friend class WriteTransaction; 131 friend class WriteTransaction;
141 friend class SyncableDirectoryTest; 132 friend class SyncableDirectoryTest;
133 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, ManageDeleteJournals);
142 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, 134 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest,
143 TakeSnapshotGetsAllDirtyHandlesTest); 135 TakeSnapshotGetsAllDirtyHandlesTest);
144 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, 136 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest,
145 TakeSnapshotGetsOnlyDirtyHandlesTest); 137 TakeSnapshotGetsOnlyDirtyHandlesTest);
146 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest, 138 FRIEND_TEST_ALL_PREFIXES(SyncableDirectoryTest,
147 TakeSnapshotGetsMetahandlesToPurge); 139 TakeSnapshotGetsMetahandlesToPurge);
148 140
149 public: 141 public:
150 static const FilePath::CharType kSyncDatabaseFilename[]; 142 static const FilePath::CharType kSyncDatabaseFilename[];
151 143
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // constructed and forms a consistent snapshot of what needs to be sent to 196 // constructed and forms a consistent snapshot of what needs to be sent to
205 // the backing store. 197 // the backing store.
206 struct SYNC_EXPORT_PRIVATE SaveChangesSnapshot { 198 struct SYNC_EXPORT_PRIVATE SaveChangesSnapshot {
207 SaveChangesSnapshot(); 199 SaveChangesSnapshot();
208 ~SaveChangesSnapshot(); 200 ~SaveChangesSnapshot();
209 201
210 KernelShareInfoStatus kernel_info_status; 202 KernelShareInfoStatus kernel_info_status;
211 PersistedKernelInfo kernel_info; 203 PersistedKernelInfo kernel_info;
212 EntryKernelSet dirty_metas; 204 EntryKernelSet dirty_metas;
213 MetahandleSet metahandles_to_purge; 205 MetahandleSet metahandles_to_purge;
206 EntryKernelSet delete_journals;
207 MetahandleSet delete_journals_to_purge;
214 }; 208 };
215 209
216 // Does not take ownership of |encryptor|. 210 // Does not take ownership of |encryptor|.
217 // |report_unrecoverable_error_function| may be NULL. 211 // |report_unrecoverable_error_function| may be NULL.
218 // Takes ownership of |store|. 212 // Takes ownership of |store|.
219 Directory( 213 Directory(
220 DirectoryBackingStore* store, 214 DirectoryBackingStore* store,
221 UnrecoverableErrorHandler* unrecoverable_error_handler, 215 UnrecoverableErrorHandler* unrecoverable_error_handler,
222 ReportUnrecoverableErrorFunction 216 ReportUnrecoverableErrorFunction
223 report_unrecoverable_error_function, 217 report_unrecoverable_error_function,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 bool UnlinkEntryFromOrder(EntryKernel* entry, 326 bool UnlinkEntryFromOrder(EntryKernel* entry,
333 WriteTransaction* trans, 327 WriteTransaction* trans,
334 ScopedKernelLock* lock, 328 ScopedKernelLock* lock,
335 UnlinkReason unlink_reason); 329 UnlinkReason unlink_reason);
336 330
337 DirOpenResult OpenImpl( 331 DirOpenResult OpenImpl(
338 const std::string& name, 332 const std::string& name,
339 DirectoryChangeDelegate* delegate, 333 DirectoryChangeDelegate* delegate,
340 const WeakHandle<TransactionObserver>& transaction_observer); 334 const WeakHandle<TransactionObserver>& transaction_observer);
341 335
336 DeleteJournal* delete_journal();
337
342 private: 338 private:
343 // These private versions expect the kernel lock to already be held 339 // These private versions expect the kernel lock to already be held
344 // before calling. 340 // before calling.
345 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); 341 EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock);
346 342
347 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set); 343 template <class T> void TestAndSet(T* kernel_data, const T* data_to_set);
348 344
349 public: 345 public:
350 typedef std::vector<int64> ChildHandles; 346 typedef std::vector<int64> ChildHandles;
351 347
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 623
628 UnrecoverableErrorHandler* const unrecoverable_error_handler_; 624 UnrecoverableErrorHandler* const unrecoverable_error_handler_;
629 const ReportUnrecoverableErrorFunction report_unrecoverable_error_function_; 625 const ReportUnrecoverableErrorFunction report_unrecoverable_error_function_;
630 bool unrecoverable_error_set_; 626 bool unrecoverable_error_set_;
631 627
632 // Not owned. 628 // Not owned.
633 NigoriHandler* const nigori_handler_; 629 NigoriHandler* const nigori_handler_;
634 Cryptographer* const cryptographer_; 630 Cryptographer* const cryptographer_;
635 631
636 InvariantCheckLevel invariant_check_level_; 632 InvariantCheckLevel invariant_check_level_;
633
634 // Maintain deleted entries not in |kernel_| until it's verified that they
635 // are deleted in native models as well.
636 scoped_ptr<DeleteJournal> delete_journal_;
637 }; 637 };
638 638
639 } // namespace syncable 639 } // namespace syncable
640 } // namespace syncer 640 } // namespace syncer
641 641
642 #endif // SYNC_SYNCABLE_DIRECTORY_H_ 642 #endif // SYNC_SYNCABLE_DIRECTORY_H_
OLDNEW
« no previous file with comments | « sync/syncable/delete_journal.cc ('k') | sync/syncable/directory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698