OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_MODEL_NEUTRAL_MUTABLE_ENTRY_H_ | 5 #ifndef SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_ |
6 #define SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_ | 6 #define SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 | 12 |
| 13 #include "base/macros.h" |
10 #include "sync/base/sync_export.h" | 14 #include "sync/base/sync_export.h" |
11 #include "sync/internal_api/public/base/model_type.h" | 15 #include "sync/internal_api/public/base/model_type.h" |
12 #include "sync/syncable/entry.h" | 16 #include "sync/syncable/entry.h" |
13 | 17 |
14 namespace syncer { | 18 namespace syncer { |
15 class WriteNode; | 19 class WriteNode; |
16 | 20 |
17 namespace syncable { | 21 namespace syncable { |
18 | 22 |
19 class BaseWriteTransaction; | 23 class BaseWriteTransaction; |
(...skipping 10 matching lines...) Expand all Loading... |
30 // to change an entry's SPECIFICS or UNIQUE_POSITION fields with this kind of | 34 // to change an entry's SPECIFICS or UNIQUE_POSITION fields with this kind of |
31 // entry. | 35 // entry. |
32 class SYNC_EXPORT ModelNeutralMutableEntry : public Entry { | 36 class SYNC_EXPORT ModelNeutralMutableEntry : public Entry { |
33 public: | 37 public: |
34 ModelNeutralMutableEntry(BaseWriteTransaction* trans, | 38 ModelNeutralMutableEntry(BaseWriteTransaction* trans, |
35 CreateNewUpdateItem, | 39 CreateNewUpdateItem, |
36 const Id& id); | 40 const Id& id); |
37 ModelNeutralMutableEntry(BaseWriteTransaction* trans, | 41 ModelNeutralMutableEntry(BaseWriteTransaction* trans, |
38 CreateNewTypeRoot, | 42 CreateNewTypeRoot, |
39 ModelType type); | 43 ModelType type); |
40 ModelNeutralMutableEntry(BaseWriteTransaction* trans, GetByHandle, int64); | 44 ModelNeutralMutableEntry(BaseWriteTransaction* trans, GetByHandle, int64_t); |
41 ModelNeutralMutableEntry(BaseWriteTransaction* trans, GetById, const Id&); | 45 ModelNeutralMutableEntry(BaseWriteTransaction* trans, GetById, const Id&); |
42 ModelNeutralMutableEntry( | 46 ModelNeutralMutableEntry( |
43 BaseWriteTransaction* trans, | 47 BaseWriteTransaction* trans, |
44 GetByClientTag, | 48 GetByClientTag, |
45 const std::string& tag); | 49 const std::string& tag); |
46 ModelNeutralMutableEntry( | 50 ModelNeutralMutableEntry( |
47 BaseWriteTransaction* trans, | 51 BaseWriteTransaction* trans, |
48 GetTypeRoot, | 52 GetTypeRoot, |
49 ModelType type); | 53 ModelType type); |
50 | 54 |
51 inline BaseWriteTransaction* base_write_transaction() const { | 55 inline BaseWriteTransaction* base_write_transaction() const { |
52 return base_write_transaction_; | 56 return base_write_transaction_; |
53 } | 57 } |
54 | 58 |
55 // Non-model-changing setters. These setters will change properties internal | 59 // Non-model-changing setters. These setters will change properties internal |
56 // to the node. These fields are important for bookkeeping in the sync | 60 // to the node. These fields are important for bookkeeping in the sync |
57 // internals, but it is not necessary to communicate changes in these fields | 61 // internals, but it is not necessary to communicate changes in these fields |
58 // to the local models. | 62 // to the local models. |
59 // | 63 // |
60 // Some of them trigger the re-indexing of the entry. They return true on | 64 // Some of them trigger the re-indexing of the entry. They return true on |
61 // success and false on failure, which occurs when putting the value would | 65 // success and false on failure, which occurs when putting the value would |
62 // have caused a duplicate in the index. The setters that never fail return | 66 // have caused a duplicate in the index. The setters that never fail return |
63 // void. | 67 // void. |
64 void PutBaseVersion(int64 value); | 68 void PutBaseVersion(int64_t value); |
65 void PutServerVersion(int64 value); | 69 void PutServerVersion(int64_t value); |
66 void PutServerMtime(base::Time value); | 70 void PutServerMtime(base::Time value); |
67 void PutServerCtime(base::Time value); | 71 void PutServerCtime(base::Time value); |
68 bool PutId(const Id& value); | 72 bool PutId(const Id& value); |
69 void PutServerParentId(const Id& value); | 73 void PutServerParentId(const Id& value); |
70 bool PutIsUnsynced(bool value); | 74 bool PutIsUnsynced(bool value); |
71 bool PutIsUnappliedUpdate(bool value); | 75 bool PutIsUnappliedUpdate(bool value); |
72 void PutServerIsDir(bool value); | 76 void PutServerIsDir(bool value); |
73 void PutServerIsDel(bool value); | 77 void PutServerIsDel(bool value); |
74 void PutServerNonUniqueName(const std::string& value); | 78 void PutServerNonUniqueName(const std::string& value); |
75 bool PutUniqueServerTag(const std::string& value); | 79 bool PutUniqueServerTag(const std::string& value); |
(...skipping 14 matching lines...) Expand all Loading... |
90 // when the caller is trying to change the parent ID of a the whole set | 94 // when the caller is trying to change the parent ID of a the whole set |
91 // of children (e.g. because the ID changed during a commit). For those | 95 // of children (e.g. because the ID changed during a commit). For those |
92 // cases, there's this function. It will corrupt the sibling ordering | 96 // cases, there's this function. It will corrupt the sibling ordering |
93 // if you're not careful. | 97 // if you're not careful. |
94 void PutParentIdPropertyOnly(const Id& parent_id); | 98 void PutParentIdPropertyOnly(const Id& parent_id); |
95 | 99 |
96 // This is similar to what one would expect from Put(TRANSACTION_VERSION), | 100 // This is similar to what one would expect from Put(TRANSACTION_VERSION), |
97 // except that it doesn't bother to invoke 'SaveOriginals'. Calling that | 101 // except that it doesn't bother to invoke 'SaveOriginals'. Calling that |
98 // function is at best unnecessary, since the transaction will have already | 102 // function is at best unnecessary, since the transaction will have already |
99 // used its list of mutations by the time this function is called. | 103 // used its list of mutations by the time this function is called. |
100 void UpdateTransactionVersion(int64 version); | 104 void UpdateTransactionVersion(int64_t version); |
101 | 105 |
102 protected: | 106 protected: |
103 explicit ModelNeutralMutableEntry(BaseWriteTransaction* trans); | 107 explicit ModelNeutralMutableEntry(BaseWriteTransaction* trans); |
104 | 108 |
105 void MarkDirty(); | 109 void MarkDirty(); |
106 | 110 |
107 private: | 111 private: |
108 friend class syncer::WriteNode; | 112 friend class syncer::WriteNode; |
109 friend class Directory; | 113 friend class Directory; |
110 | 114 |
111 // Don't allow creation on heap, except by sync API wrappers. | 115 // Don't allow creation on heap, except by sync API wrappers. |
112 void* operator new(size_t size) { return (::operator new)(size); } | 116 void* operator new(size_t size) { return (::operator new)(size); } |
113 | 117 |
114 // Kind of redundant. We should reduce the number of pointers | 118 // Kind of redundant. We should reduce the number of pointers |
115 // floating around if at all possible. Could we store this in Directory? | 119 // floating around if at all possible. Could we store this in Directory? |
116 // Scope: Set on construction, never changed after that. | 120 // Scope: Set on construction, never changed after that. |
117 BaseWriteTransaction* const base_write_transaction_; | 121 BaseWriteTransaction* const base_write_transaction_; |
118 | 122 |
119 DISALLOW_COPY_AND_ASSIGN(ModelNeutralMutableEntry); | 123 DISALLOW_COPY_AND_ASSIGN(ModelNeutralMutableEntry); |
120 }; | 124 }; |
121 | 125 |
122 } // namespace syncable | 126 } // namespace syncable |
123 } // namespace syncer | 127 } // namespace syncer |
124 | 128 |
125 #endif // SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_ | 129 #endif // SYNC_SYNCABLE_MODEL_NEUTRAL_MUTABLE_ENTRY_H_ |
OLD | NEW |