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

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

Issue 10844005: [Sync] Refactor GetEncryptedTypes usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + add dcheck Created 8 years, 3 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/internal_api/write_node.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/internal_api/public/util/report_unrecoverable_error_function.h" 14 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
15 #include "sync/internal_api/public/util/weak_handle.h" 15 #include "sync/internal_api/public/util/weak_handle.h"
16 #include "sync/syncable/dir_open_result.h" 16 #include "sync/syncable/dir_open_result.h"
17 #include "sync/syncable/entry_kernel.h" 17 #include "sync/syncable/entry_kernel.h"
18 #include "sync/syncable/metahandle_set.h" 18 #include "sync/syncable/metahandle_set.h"
19 #include "sync/syncable/scoped_kernel_lock.h" 19 #include "sync/syncable/scoped_kernel_lock.h"
20 #include "sync/util/cryptographer.h"
21 20
22 namespace syncer { 21 namespace syncer {
23 22
24 class Encryptor; 23 class Cryptographer;
25 class UnrecoverableErrorHandler; 24 class UnrecoverableErrorHandler;
26 25
27 namespace syncable { 26 namespace syncable {
28 27
28 class BaseTransaction;
29 class DirectoryChangeDelegate; 29 class DirectoryChangeDelegate;
30 class DirectoryBackingStore;
31 class NigoriHandler;
32 class ScopedKernelLock;
30 class TransactionObserver; 33 class TransactionObserver;
31 class BaseTransaction;
32 class WriteTransaction; 34 class WriteTransaction;
33 class ScopedKernelLock;
34 class DirectoryBackingStore;
35 35
36 // How syncable indices & Indexers work. 36 // How syncable indices & Indexers work.
37 // 37 //
38 // The syncable Directory maintains several indices on the Entries it tracks. 38 // The syncable Directory maintains several indices on the Entries it tracks.
39 // The indices follow a common pattern: 39 // The indices follow a common pattern:
40 // (a) The index allows efficient lookup of an Entry* with particular 40 // (a) The index allows efficient lookup of an Entry* with particular
41 // field values. This is done by use of a std::set<> and a custom 41 // field values. This is done by use of a std::set<> and a custom
42 // comparator. 42 // comparator.
43 // (b) There may be conditions for inclusion in the index -- for example, 43 // (b) There may be conditions for inclusion in the index -- for example,
44 // deleted items might not be indexed. 44 // deleted items might not be indexed.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 KernelShareInfoStatus kernel_info_status; 200 KernelShareInfoStatus kernel_info_status;
201 PersistedKernelInfo kernel_info; 201 PersistedKernelInfo kernel_info;
202 EntryKernelSet dirty_metas; 202 EntryKernelSet dirty_metas;
203 MetahandleSet metahandles_to_purge; 203 MetahandleSet metahandles_to_purge;
204 }; 204 };
205 205
206 // Does not take ownership of |encryptor|. 206 // Does not take ownership of |encryptor|.
207 // |report_unrecoverable_error_function| may be NULL. 207 // |report_unrecoverable_error_function| may be NULL.
208 // Takes ownership of |store|. 208 // Takes ownership of |store|.
209 Directory( 209 Directory(
210 Encryptor* encryptor, 210 DirectoryBackingStore* store,
211 UnrecoverableErrorHandler* unrecoverable_error_handler, 211 UnrecoverableErrorHandler* unrecoverable_error_handler,
212 ReportUnrecoverableErrorFunction 212 ReportUnrecoverableErrorFunction
213 report_unrecoverable_error_function, 213 report_unrecoverable_error_function,
214 DirectoryBackingStore* store); 214 NigoriHandler* nigori_handler,
215 Cryptographer* cryptographer);
215 virtual ~Directory(); 216 virtual ~Directory();
216 217
217 // Does not take ownership of |delegate|, which must not be NULL. 218 // Does not take ownership of |delegate|, which must not be NULL.
218 // Starts sending events to |delegate| if the returned result is 219 // Starts sending events to |delegate| if the returned result is
219 // OPENED. Note that events to |delegate| may be sent from *any* 220 // OPENED. Note that events to |delegate| may be sent from *any*
220 // thread. |transaction_observer| must be initialized. 221 // thread. |transaction_observer| must be initialized.
221 DirOpenResult Open(const std::string& name, 222 DirOpenResult Open(const std::string& name,
222 DirectoryChangeDelegate* delegate, 223 DirectoryChangeDelegate* delegate,
223 const WeakHandle<TransactionObserver>& 224 const WeakHandle<TransactionObserver>&
224 transaction_observer); 225 transaction_observer);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // later. 259 // later.
259 std::string store_birthday() const; 260 std::string store_birthday() const;
260 void set_store_birthday(const std::string& store_birthday); 261 void set_store_birthday(const std::string& store_birthday);
261 262
262 std::string GetNotificationState() const; 263 std::string GetNotificationState() const;
263 void SetNotificationState(const std::string& notification_state); 264 void SetNotificationState(const std::string& notification_state);
264 265
265 // Unique to each account / client pair. 266 // Unique to each account / client pair.
266 std::string cache_guid() const; 267 std::string cache_guid() const;
267 268
268 // Returns a pointer to our cryptographer. Does not transfer ownership. The 269 // Returns a pointer to our Nigori node handler.
269 // cryptographer is not thread safe; it should not be accessed after the 270 NigoriHandler* GetNigoriHandler();
270 // transaction has been released. 271
272 // Returns a pointer to our cryptographer. Does not transfer ownership.
273 // Not thread safe, so should only be accessed while holding a transaction.
271 Cryptographer* GetCryptographer(const BaseTransaction* trans); 274 Cryptographer* GetCryptographer(const BaseTransaction* trans);
272 275
273 // Returns true if the directory had encountered an unrecoverable error. 276 // Returns true if the directory had encountered an unrecoverable error.
274 // Note: Any function in |Directory| that can be called without holding a 277 // Note: Any function in |Directory| that can be called without holding a
275 // transaction need to check if the Directory already has an unrecoverable 278 // transaction need to check if the Directory already has an unrecoverable
276 // error on it. 279 // error on it.
277 bool unrecoverable_error_set(const BaseTransaction* trans) const; 280 bool unrecoverable_error_set(const BaseTransaction* trans) const;
278 281
279 // Called to immediately report an unrecoverable error (but don't 282 // Called to immediately report an unrecoverable error (but don't
280 // propagate it up). 283 // propagate it up).
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 void AppendChildHandles( 588 void AppendChildHandles(
586 const ScopedKernelLock& lock, 589 const ScopedKernelLock& lock,
587 const Id& parent_id, Directory::ChildHandles* result); 590 const Id& parent_id, Directory::ChildHandles* result);
588 591
589 // Return a pointer to what is probably (but not certainly) the 592 // Return a pointer to what is probably (but not certainly) the
590 // first child of |parent_id|, or NULL if |parent_id| definitely has 593 // first child of |parent_id|, or NULL if |parent_id| definitely has
591 // no children. 594 // no children.
592 EntryKernel* GetPossibleFirstChild( 595 EntryKernel* GetPossibleFirstChild(
593 const ScopedKernelLock& lock, const Id& parent_id); 596 const ScopedKernelLock& lock, const Id& parent_id);
594 597
595 Cryptographer cryptographer_;
596
597 Kernel* kernel_; 598 Kernel* kernel_;
598 599
599 scoped_ptr<DirectoryBackingStore> store_; 600 scoped_ptr<DirectoryBackingStore> store_;
600 601
601 UnrecoverableErrorHandler* const unrecoverable_error_handler_; 602 UnrecoverableErrorHandler* const unrecoverable_error_handler_;
602 const ReportUnrecoverableErrorFunction report_unrecoverable_error_function_; 603 const ReportUnrecoverableErrorFunction report_unrecoverable_error_function_;
603 bool unrecoverable_error_set_; 604 bool unrecoverable_error_set_;
604 605
606 // Not owned.
607 NigoriHandler* const nigori_handler_;
608 Cryptographer* const cryptographer_;
609
605 InvariantCheckLevel invariant_check_level_; 610 InvariantCheckLevel invariant_check_level_;
606 }; 611 };
607 612
608 } // namespace syncable 613 } // namespace syncable
609 } // namespace syncer 614 } // namespace syncer
610 615
611 #endif // SYNC_SYNCABLE_DIRECTORY_H_ 616 #endif // SYNC_SYNCABLE_DIRECTORY_H_
OLDNEW
« no previous file with comments | « sync/internal_api/write_node.cc ('k') | sync/syncable/directory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698