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

Side by Side Diff: components/sync/core/read_node.h

Issue 2407163004: [Sync] Move some directory-related things from core/ to syncable/. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « components/sync/core/delete_journal.cc ('k') | components/sync/core/read_node.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SYNC_CORE_READ_NODE_H_
6 #define COMPONENTS_SYNC_CORE_READ_NODE_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <string>
12
13 #include "base/compiler_specific.h"
14 #include "base/macros.h"
15 #include "components/sync/base/model_type.h"
16 #include "components/sync/core/base_node.h"
17
18 namespace syncer {
19
20 // ReadNode wraps a syncable::Entry to provide the functionality of a
21 // read-only BaseNode.
22 class ReadNode : public BaseNode {
23 public:
24 // Create an unpopulated ReadNode on the given transaction. Call some flavor
25 // of Init to populate the ReadNode with a database entry.
26 explicit ReadNode(const BaseTransaction* transaction);
27 ~ReadNode() override;
28
29 // A client must use one (and only one) of the following Init variants to
30 // populate the node.
31
32 // BaseNode implementation.
33 InitByLookupResult InitByIdLookup(int64_t id) override;
34 InitByLookupResult InitByClientTagLookup(ModelType model_type,
35 const std::string& tag) override;
36
37 // There is always a root node, so this can't fail. The root node is
38 // never mutable, so root lookup is only possible on a ReadNode.
39 void InitByRootLookup();
40
41 // Returns the type root node, if it exists. This is usually created by the
42 // server during first sync. Eventually, we plan to remove support for it
43 // from the protocol and have the client create the node instead.
44 InitByLookupResult InitTypeRoot(ModelType type);
45
46 // Returns a server-created and unique-server-tagged item.
47 //
48 // This functionality is only useful for bookmarks because only bookmarks
49 // have server-tagged items. All other server-tagged items are type root
50 // nodes, which should be looked up with InitTypeRoot().
51 InitByLookupResult InitByTagLookupForBookmarks(const std::string& tag);
52
53 // Returns transaction version of the last transaction where this node has
54 // been modified.
55 int64_t GetTransactionVersion() const;
56
57 // Implementation of BaseNode's abstract virtual accessors.
58 const syncable::Entry* GetEntry() const override;
59 const BaseTransaction* GetTransaction() const override;
60
61 protected:
62 ReadNode();
63
64 private:
65 void* operator new(size_t size); // Node is meant for stack use only.
66
67 // The underlying syncable object which this class wraps.
68 syncable::Entry* entry_;
69
70 // The sync API transaction that is the parent of this node.
71 const BaseTransaction* transaction_;
72
73 DISALLOW_COPY_AND_ASSIGN(ReadNode);
74 };
75
76 } // namespace syncer
77
78 #endif // COMPONENTS_SYNC_CORE_READ_NODE_H_
OLDNEW
« no previous file with comments | « components/sync/core/delete_journal.cc ('k') | components/sync/core/read_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698