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