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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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 | « sync/syncable/metahandle_set.h ('k') | sync/syncable/model_neutral_mutable_entry.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 2013 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 SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_
6 #define SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <string>
12
13 #include "base/macros.h"
14 #include "sync/base/sync_export.h"
15 #include "sync/internal_api/public/base/model_type.h"
16 #include "sync/syncable/entry.h"
17
18 namespace syncer {
19 class WriteNode;
20
21 namespace syncable {
22
23 class BaseWriteTransaction;
24
25 enum CreateNewUpdateItem {
26 CREATE_NEW_UPDATE_ITEM
27 };
28
29 enum CreateNewTypeRoot { CREATE_NEW_TYPE_ROOT };
30
31 // This Entry includes all the operations one can safely perform on the sync
32 // thread. In particular, it does not expose setters to make changes that need
33 // to be communicated to the model (and the model's thread). It is not possible
34 // to change an entry's SPECIFICS or UNIQUE_POSITION fields with this kind of
35 // entry.
36 class SYNC_EXPORT ModelNeutralMutableEntry : public Entry {
37 public:
38 ModelNeutralMutableEntry(BaseWriteTransaction* trans,
39 CreateNewUpdateItem,
40 const Id& id);
41 ModelNeutralMutableEntry(BaseWriteTransaction* trans,
42 CreateNewTypeRoot,
43 ModelType type);
44 ModelNeutralMutableEntry(BaseWriteTransaction* trans, GetByHandle, int64_t);
45 ModelNeutralMutableEntry(BaseWriteTransaction* trans, GetById, const Id&);
46 ModelNeutralMutableEntry(
47 BaseWriteTransaction* trans,
48 GetByClientTag,
49 const std::string& tag);
50 ModelNeutralMutableEntry(
51 BaseWriteTransaction* trans,
52 GetTypeRoot,
53 ModelType type);
54
55 inline BaseWriteTransaction* base_write_transaction() const {
56 return base_write_transaction_;
57 }
58
59 // Non-model-changing setters. These setters will change properties internal
60 // to the node. These fields are important for bookkeeping in the sync
61 // internals, but it is not necessary to communicate changes in these fields
62 // to the local models.
63 //
64 // Some of them trigger the re-indexing of the entry. They return true on
65 // success and false on failure, which occurs when putting the value would
66 // have caused a duplicate in the index. The setters that never fail return
67 // void.
68 void PutBaseVersion(int64_t value);
69 void PutServerVersion(int64_t value);
70 void PutServerMtime(base::Time value);
71 void PutServerCtime(base::Time value);
72 bool PutId(const Id& value);
73 void PutServerParentId(const Id& value);
74 bool PutIsUnsynced(bool value);
75 bool PutIsUnappliedUpdate(bool value);
76 void PutServerIsDir(bool value);
77 void PutServerIsDel(bool value);
78 void PutServerNonUniqueName(const std::string& value);
79 bool PutUniqueServerTag(const std::string& value);
80 bool PutUniqueClientTag(const std::string& value);
81 void PutUniqueBookmarkTag(const std::string& tag);
82 void PutServerSpecifics(const sync_pb::EntitySpecifics& value);
83 void PutBaseServerSpecifics(const sync_pb::EntitySpecifics& value);
84 void PutServerUniquePosition(const UniquePosition& value);
85 void PutServerAttachmentMetadata(const sync_pb::AttachmentMetadata& value);
86 void PutSyncing(bool value);
87 void PutDirtySync(bool value);
88
89 // Do a simple property-only update of the PARENT_ID field. Use with caution.
90 //
91 // The normal Put(IS_PARENT) call will move the item to the front of the
92 // sibling order to maintain the linked list invariants when the parent
93 // changes. That's usually what you want to do, but it's inappropriate
94 // when the caller is trying to change the parent ID of a the whole set
95 // of children (e.g. because the ID changed during a commit). For those
96 // cases, there's this function. It will corrupt the sibling ordering
97 // if you're not careful.
98 void PutParentIdPropertyOnly(const Id& parent_id);
99
100 // This is similar to what one would expect from Put(TRANSACTION_VERSION),
101 // except that it doesn't bother to invoke 'SaveOriginals'. Calling that
102 // function is at best unnecessary, since the transaction will have already
103 // used its list of mutations by the time this function is called.
104 void UpdateTransactionVersion(int64_t version);
105
106 protected:
107 explicit ModelNeutralMutableEntry(BaseWriteTransaction* trans);
108
109 void MarkDirty();
110
111 private:
112 friend class syncer::WriteNode;
113 friend class Directory;
114
115 // Don't allow creation on heap, except by sync API wrappers.
116 void* operator new(size_t size) { return (::operator new)(size); }
117
118 // Kind of redundant. We should reduce the number of pointers
119 // floating around if at all possible. Could we store this in Directory?
120 // Scope: Set on construction, never changed after that.
121 BaseWriteTransaction* const base_write_transaction_;
122
123 DISALLOW_COPY_AND_ASSIGN(ModelNeutralMutableEntry);
124 };
125
126 } // namespace syncable
127 } // namespace syncer
128
129 #endif // SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_
OLDNEW
« no previous file with comments | « sync/syncable/metahandle_set.h ('k') | sync/syncable/model_neutral_mutable_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698