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

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

Issue 211523002: Add AttachmentMetadata to Sync's EntryKernel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot about using META_PROTO_TIMES_VALS in the test. Created 6 years, 8 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/entry.cc ('k') | sync/syncable/entry_kernel.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 2012 The Chromium Authors. All rights reserved. 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 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_ENTRY_KERNEL_H_ 5 #ifndef SYNC_SYNCABLE_ENTRY_KERNEL_H_
6 #define SYNC_SYNCABLE_ENTRY_KERNEL_H_ 6 #define SYNC_SYNCABLE_ENTRY_KERNEL_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "sync/base/sync_export.h" 12 #include "sync/base/sync_export.h"
13 #include "sync/internal_api/public/base/model_type.h" 13 #include "sync/internal_api/public/base/model_type.h"
14 #include "sync/internal_api/public/base/unique_position.h" 14 #include "sync/internal_api/public/base/unique_position.h"
15 #include "sync/internal_api/public/util/immutable.h" 15 #include "sync/internal_api/public/util/immutable.h"
16 #include "sync/protocol/attachments.pb.h"
16 #include "sync/protocol/sync.pb.h" 17 #include "sync/protocol/sync.pb.h"
17 #include "sync/syncable/metahandle_set.h" 18 #include "sync/syncable/metahandle_set.h"
18 #include "sync/syncable/syncable_id.h" 19 #include "sync/syncable/syncable_id.h"
19 #include "sync/util/time.h" 20 #include "sync/util/time.h"
20 21
21 namespace syncer { 22 namespace syncer {
22 23
23 class Cryptographer; 24 class Cryptographer;
24 25
25 namespace syncable { 26 namespace syncable {
26 27
27 // Things you need to update if you change any of the fields below: 28 // Things you need to update if you change any of the fields below:
28 // - EntryKernel struct in this file 29 // - EntryKernel struct in this file
29 // - syncable_columns.h 30 // - syncable_columns.h
30 // - syncable_enum_conversions{.h,.cc,_unittest.cc} 31 // - syncable_enum_conversions{.h,.cc,_unittest.cc}
31 // - EntryKernel::EntryKernel(), EntryKernel::ToValue() in entry_kernel.cc 32 // - EntryKernel::EntryKernel(), EntryKernel::ToValue() in entry_kernel.cc
32 // - operator<< in Entry.cc 33 // - operator<< in Entry.cc
33 // - BindFields() and UnpackEntry() in directory_backing_store.cc 34 // - BindFields() and UnpackEntry() in directory_backing_store.cc
35 // - kCurrentDBVersion, DirectoryBackingStore::InitializeTables in
36 // directory_backing_store.cc
34 // - TestSimpleFieldsPreservedDuringSaveChanges in syncable_unittest.cc 37 // - TestSimpleFieldsPreservedDuringSaveChanges in syncable_unittest.cc
35 38
36 static const int64 kInvalidMetaHandle = 0; 39 static const int64 kInvalidMetaHandle = 0;
37 40
38 enum { 41 enum {
39 BEGIN_FIELDS = 0, 42 BEGIN_FIELDS = 0,
40 INT64_FIELDS_BEGIN = BEGIN_FIELDS 43 INT64_FIELDS_BEGIN = BEGIN_FIELDS
41 }; 44 };
42 45
43 enum MetahandleField { 46 enum MetahandleField {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 152
150 enum UniquePositionField { 153 enum UniquePositionField {
151 SERVER_UNIQUE_POSITION = UNIQUE_POSITION_FIELDS_BEGIN, 154 SERVER_UNIQUE_POSITION = UNIQUE_POSITION_FIELDS_BEGIN,
152 UNIQUE_POSITION, 155 UNIQUE_POSITION,
153 UNIQUE_POSITION_FIELDS_END 156 UNIQUE_POSITION_FIELDS_END
154 }; 157 };
155 158
156 enum { 159 enum {
157 UNIQUE_POSITION_FIELDS_COUNT = 160 UNIQUE_POSITION_FIELDS_COUNT =
158 UNIQUE_POSITION_FIELDS_END - UNIQUE_POSITION_FIELDS_BEGIN, 161 UNIQUE_POSITION_FIELDS_END - UNIQUE_POSITION_FIELDS_BEGIN,
159 FIELD_COUNT = UNIQUE_POSITION_FIELDS_END - BEGIN_FIELDS, 162 ATTACHMENT_METADATA_FIELDS_BEGIN = UNIQUE_POSITION_FIELDS_END
163 };
164
165 enum AttachmentMetadataField {
166 ATTACHMENT_METADATA = ATTACHMENT_METADATA_FIELDS_BEGIN,
167 ATTACHMENT_METADATA_FIELDS_END
168 };
169
170 enum {
171 ATTACHMENT_METADATA_FIELDS_COUNT =
172 ATTACHMENT_METADATA_FIELDS_END - ATTACHMENT_METADATA_FIELDS_BEGIN,
173 FIELD_COUNT = ATTACHMENT_METADATA_FIELDS_END - BEGIN_FIELDS,
160 // Past this point we have temporaries, stored in memory only. 174 // Past this point we have temporaries, stored in memory only.
161 BEGIN_TEMPS = UNIQUE_POSITION_FIELDS_END, 175 BEGIN_TEMPS = ATTACHMENT_METADATA_FIELDS_END,
162 BIT_TEMPS_BEGIN = BEGIN_TEMPS, 176 BIT_TEMPS_BEGIN = BEGIN_TEMPS,
163 }; 177 };
164 178
165 enum BitTemp { 179 enum BitTemp {
166 // Not to be confused with IS_UNSYNCED, this bit is used to detect local 180 // Not to be confused with IS_UNSYNCED, this bit is used to detect local
167 // changes to items that happen during the server Commit operation. 181 // changes to items that happen during the server Commit operation.
168 SYNCING = BIT_TEMPS_BEGIN, 182 SYNCING = BIT_TEMPS_BEGIN,
169 BIT_TEMPS_END, 183 BIT_TEMPS_END,
170 }; 184 };
171 185
172 enum { 186 enum {
173 BIT_TEMPS_COUNT = BIT_TEMPS_END - BIT_TEMPS_BEGIN 187 BIT_TEMPS_COUNT = BIT_TEMPS_END - BIT_TEMPS_BEGIN
174 }; 188 };
175 189
176 190
177 191
178 struct SYNC_EXPORT_PRIVATE EntryKernel { 192 struct SYNC_EXPORT_PRIVATE EntryKernel {
179 private: 193 private:
180 std::string string_fields[STRING_FIELDS_COUNT]; 194 std::string string_fields[STRING_FIELDS_COUNT];
181 sync_pb::EntitySpecifics specifics_fields[PROTO_FIELDS_COUNT]; 195 sync_pb::EntitySpecifics specifics_fields[PROTO_FIELDS_COUNT];
182 int64 int64_fields[INT64_FIELDS_COUNT]; 196 int64 int64_fields[INT64_FIELDS_COUNT];
183 base::Time time_fields[TIME_FIELDS_COUNT]; 197 base::Time time_fields[TIME_FIELDS_COUNT];
184 Id id_fields[ID_FIELDS_COUNT]; 198 Id id_fields[ID_FIELDS_COUNT];
185 UniquePosition unique_position_fields[UNIQUE_POSITION_FIELDS_COUNT]; 199 UniquePosition unique_position_fields[UNIQUE_POSITION_FIELDS_COUNT];
200 sync_pb::AttachmentMetadata
201 attachment_metadata_fields[ATTACHMENT_METADATA_FIELDS_COUNT];
186 std::bitset<BIT_FIELDS_COUNT> bit_fields; 202 std::bitset<BIT_FIELDS_COUNT> bit_fields;
187 std::bitset<BIT_TEMPS_COUNT> bit_temps; 203 std::bitset<BIT_TEMPS_COUNT> bit_temps;
188 204
189 public: 205 public:
190 EntryKernel(); 206 EntryKernel();
191 ~EntryKernel(); 207 ~EntryKernel();
192 208
193 // Set the dirty bit, and optionally add this entry's metahandle to 209 // Set the dirty bit, and optionally add this entry's metahandle to
194 // a provided index on dirty bits in |dirty_index|. Parameter may be null, 210 // a provided index on dirty bits in |dirty_index|. Parameter may be null,
195 // and will result only in setting the dirty bit of this entry. 211 // and will result only in setting the dirty bit of this entry.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 262 }
247 inline void put(StringField field, const std::string& value) { 263 inline void put(StringField field, const std::string& value) {
248 string_fields[field - STRING_FIELDS_BEGIN] = value; 264 string_fields[field - STRING_FIELDS_BEGIN] = value;
249 } 265 }
250 inline void put(ProtoField field, const sync_pb::EntitySpecifics& value) { 266 inline void put(ProtoField field, const sync_pb::EntitySpecifics& value) {
251 specifics_fields[field - PROTO_FIELDS_BEGIN].CopyFrom(value); 267 specifics_fields[field - PROTO_FIELDS_BEGIN].CopyFrom(value);
252 } 268 }
253 inline void put(UniquePositionField field, const UniquePosition& value) { 269 inline void put(UniquePositionField field, const UniquePosition& value) {
254 unique_position_fields[field - UNIQUE_POSITION_FIELDS_BEGIN] = value; 270 unique_position_fields[field - UNIQUE_POSITION_FIELDS_BEGIN] = value;
255 } 271 }
272 inline void put(AttachmentMetadataField field,
273 const sync_pb::AttachmentMetadata& value) {
274 attachment_metadata_fields[field - ATTACHMENT_METADATA_FIELDS_BEGIN] =
275 value;
276 }
256 inline void put(BitTemp field, bool value) { 277 inline void put(BitTemp field, bool value) {
257 bit_temps[field - BIT_TEMPS_BEGIN] = value; 278 bit_temps[field - BIT_TEMPS_BEGIN] = value;
258 } 279 }
259 280
260 // Const ref getters. 281 // Const ref getters.
261 inline int64 ref(MetahandleField field) const { 282 inline int64 ref(MetahandleField field) const {
262 return int64_fields[field - INT64_FIELDS_BEGIN]; 283 return int64_fields[field - INT64_FIELDS_BEGIN];
263 } 284 }
264 inline int64 ref(Int64Field field) const { 285 inline int64 ref(Int64Field field) const {
265 return int64_fields[field - INT64_FIELDS_BEGIN]; 286 return int64_fields[field - INT64_FIELDS_BEGIN];
(...skipping 18 matching lines...) Expand all
284 } 305 }
285 inline const std::string& ref(StringField field) const { 306 inline const std::string& ref(StringField field) const {
286 return string_fields[field - STRING_FIELDS_BEGIN]; 307 return string_fields[field - STRING_FIELDS_BEGIN];
287 } 308 }
288 inline const sync_pb::EntitySpecifics& ref(ProtoField field) const { 309 inline const sync_pb::EntitySpecifics& ref(ProtoField field) const {
289 return specifics_fields[field - PROTO_FIELDS_BEGIN]; 310 return specifics_fields[field - PROTO_FIELDS_BEGIN];
290 } 311 }
291 inline const UniquePosition& ref(UniquePositionField field) const { 312 inline const UniquePosition& ref(UniquePositionField field) const {
292 return unique_position_fields[field - UNIQUE_POSITION_FIELDS_BEGIN]; 313 return unique_position_fields[field - UNIQUE_POSITION_FIELDS_BEGIN];
293 } 314 }
315 inline const sync_pb::AttachmentMetadata& ref(
316 AttachmentMetadataField field) const {
317 return attachment_metadata_fields[field - ATTACHMENT_METADATA_FIELDS_BEGIN];
318 }
294 inline bool ref(BitTemp field) const { 319 inline bool ref(BitTemp field) const {
295 return bit_temps[field - BIT_TEMPS_BEGIN]; 320 return bit_temps[field - BIT_TEMPS_BEGIN];
296 } 321 }
297 322
298 // Non-const, mutable ref getters for object types only. 323 // Non-const, mutable ref getters for object types only.
299 inline std::string& mutable_ref(StringField field) { 324 inline std::string& mutable_ref(StringField field) {
300 return string_fields[field - STRING_FIELDS_BEGIN]; 325 return string_fields[field - STRING_FIELDS_BEGIN];
301 } 326 }
302 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) { 327 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) {
303 return specifics_fields[field - PROTO_FIELDS_BEGIN]; 328 return specifics_fields[field - PROTO_FIELDS_BEGIN];
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 const EntryKernelMutation& mutation); 374 const EntryKernelMutation& mutation);
350 375
351 // Caller owns the return value. 376 // Caller owns the return value.
352 base::ListValue* EntryKernelMutationMapToValue( 377 base::ListValue* EntryKernelMutationMapToValue(
353 const EntryKernelMutationMap& mutations); 378 const EntryKernelMutationMap& mutations);
354 379
355 } // namespace syncable 380 } // namespace syncable
356 } // namespace syncer 381 } // namespace syncer
357 382
358 #endif // SYNC_SYNCABLE_ENTRY_KERNEL_H_ 383 #endif // SYNC_SYNCABLE_ENTRY_KERNEL_H_
OLDNEW
« no previous file with comments | « sync/syncable/entry.cc ('k') | sync/syncable/entry_kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698