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

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

Powered by Google App Engine
This is Rietveld 408576698