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

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

Issue 1545553003: Switch to standard integer types in sync/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <stdint.h>
9
8 #include <algorithm> 10 #include <algorithm>
9 #include <map> 11 #include <map>
10 #include <set> 12 #include <set>
11 #include <string> 13 #include <string>
12 14
13 #include "base/time/time.h" 15 #include "base/time/time.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "sync/base/sync_export.h" 17 #include "sync/base/sync_export.h"
16 #include "sync/internal_api/public/base/model_type.h" 18 #include "sync/internal_api/public/base/model_type.h"
17 #include "sync/internal_api/public/base/unique_position.h" 19 #include "sync/internal_api/public/base/unique_position.h"
(...skipping 15 matching lines...) Expand all
33 // - EntryKernel struct in this file 35 // - EntryKernel struct in this file
34 // - syncable_columns.h 36 // - syncable_columns.h
35 // - syncable_enum_conversions{.h,.cc,_unittest.cc} 37 // - syncable_enum_conversions{.h,.cc,_unittest.cc}
36 // - EntryKernel::EntryKernel(), EntryKernel::ToValue() in entry_kernel.cc 38 // - EntryKernel::EntryKernel(), EntryKernel::ToValue() in entry_kernel.cc
37 // - operator<< in Entry.cc 39 // - operator<< in Entry.cc
38 // - BindFields() and UnpackEntry() in directory_backing_store.cc 40 // - BindFields() and UnpackEntry() in directory_backing_store.cc
39 // - kCurrentDBVersion, DirectoryBackingStore::InitializeTables in 41 // - kCurrentDBVersion, DirectoryBackingStore::InitializeTables in
40 // directory_backing_store.cc 42 // directory_backing_store.cc
41 // - TestSimpleFieldsPreservedDuringSaveChanges in syncable_unittest.cc 43 // - TestSimpleFieldsPreservedDuringSaveChanges in syncable_unittest.cc
42 44
43 static const int64 kInvalidMetaHandle = 0; 45 static const int64_t kInvalidMetaHandle = 0;
44 46
45 enum { 47 enum {
46 BEGIN_FIELDS = 0, 48 BEGIN_FIELDS = 0,
47 INT64_FIELDS_BEGIN = BEGIN_FIELDS 49 INT64_FIELDS_BEGIN = BEGIN_FIELDS
48 }; 50 };
49 51
50 enum MetahandleField { 52 enum MetahandleField {
51 // Primary key into the table. Keep this as a handle to the meta entry 53 // Primary key into the table. Keep this as a handle to the meta entry
52 // across transactions. 54 // across transactions.
53 META_HANDLE = INT64_FIELDS_BEGIN 55 META_HANDLE = INT64_FIELDS_BEGIN
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 }; 199 };
198 200
199 struct SYNC_EXPORT EntryKernel { 201 struct SYNC_EXPORT EntryKernel {
200 private: 202 private:
201 typedef syncer::ProtoValuePtr<sync_pb::EntitySpecifics> EntitySpecificsPtr; 203 typedef syncer::ProtoValuePtr<sync_pb::EntitySpecifics> EntitySpecificsPtr;
202 typedef syncer::ProtoValuePtr<sync_pb::AttachmentMetadata> 204 typedef syncer::ProtoValuePtr<sync_pb::AttachmentMetadata>
203 AttachmentMetadataPtr; 205 AttachmentMetadataPtr;
204 206
205 std::string string_fields[STRING_FIELDS_COUNT]; 207 std::string string_fields[STRING_FIELDS_COUNT];
206 EntitySpecificsPtr specifics_fields[PROTO_FIELDS_COUNT]; 208 EntitySpecificsPtr specifics_fields[PROTO_FIELDS_COUNT];
207 int64 int64_fields[INT64_FIELDS_COUNT]; 209 int64_t int64_fields[INT64_FIELDS_COUNT];
208 base::Time time_fields[TIME_FIELDS_COUNT]; 210 base::Time time_fields[TIME_FIELDS_COUNT];
209 Id id_fields[ID_FIELDS_COUNT]; 211 Id id_fields[ID_FIELDS_COUNT];
210 UniquePosition unique_position_fields[UNIQUE_POSITION_FIELDS_COUNT]; 212 UniquePosition unique_position_fields[UNIQUE_POSITION_FIELDS_COUNT];
211 AttachmentMetadataPtr 213 AttachmentMetadataPtr
212 attachment_metadata_fields[ATTACHMENT_METADATA_FIELDS_COUNT]; 214 attachment_metadata_fields[ATTACHMENT_METADATA_FIELDS_COUNT];
213 std::bitset<BIT_FIELDS_COUNT> bit_fields; 215 std::bitset<BIT_FIELDS_COUNT> bit_fields;
214 std::bitset<BIT_TEMPS_COUNT> bit_temps; 216 std::bitset<BIT_TEMPS_COUNT> bit_temps;
215 217
216 friend std::ostream& operator<<(std::ostream& s, const EntryKernel& e); 218 friend std::ostream& operator<<(std::ostream& s, const EntryKernel& e);
217 219
(...skipping 21 matching lines...) Expand all
239 dirty_index->erase(ref(META_HANDLE)); 241 dirty_index->erase(ref(META_HANDLE));
240 } 242 }
241 dirty_ = false; 243 dirty_ = false;
242 } 244 }
243 245
244 inline bool is_dirty() const { 246 inline bool is_dirty() const {
245 return dirty_; 247 return dirty_;
246 } 248 }
247 249
248 // Setters. 250 // Setters.
249 inline void put(MetahandleField field, int64 value) { 251 inline void put(MetahandleField field, int64_t value) {
250 int64_fields[field - INT64_FIELDS_BEGIN] = value; 252 int64_fields[field - INT64_FIELDS_BEGIN] = value;
251 } 253 }
252 inline void put(Int64Field field, int64 value) { 254 inline void put(Int64Field field, int64_t value) {
253 int64_fields[field - INT64_FIELDS_BEGIN] = value; 255 int64_fields[field - INT64_FIELDS_BEGIN] = value;
254 } 256 }
255 inline void put(TimeField field, const base::Time& value) { 257 inline void put(TimeField field, const base::Time& value) {
256 // Round-trip to proto time format and back so that we have 258 // Round-trip to proto time format and back so that we have
257 // consistent time resolutions (ms). 259 // consistent time resolutions (ms).
258 time_fields[field - TIME_FIELDS_BEGIN] = 260 time_fields[field - TIME_FIELDS_BEGIN] =
259 ProtoTimeToTime(TimeToProtoTime(value)); 261 ProtoTimeToTime(TimeToProtoTime(value));
260 } 262 }
261 inline void put(IdField field, const Id& value) { 263 inline void put(IdField field, const Id& value) {
262 id_fields[field - ID_FIELDS_BEGIN] = value; 264 id_fields[field - ID_FIELDS_BEGIN] = value;
263 } 265 }
264 inline void put(BaseVersion field, int64 value) { 266 inline void put(BaseVersion field, int64_t value) {
265 int64_fields[field - INT64_FIELDS_BEGIN] = value; 267 int64_fields[field - INT64_FIELDS_BEGIN] = value;
266 } 268 }
267 inline void put(IndexedBitField field, bool value) { 269 inline void put(IndexedBitField field, bool value) {
268 bit_fields[field - BIT_FIELDS_BEGIN] = value; 270 bit_fields[field - BIT_FIELDS_BEGIN] = value;
269 } 271 }
270 inline void put(IsDelField field, bool value) { 272 inline void put(IsDelField field, bool value) {
271 bit_fields[field - BIT_FIELDS_BEGIN] = value; 273 bit_fields[field - BIT_FIELDS_BEGIN] = value;
272 } 274 }
273 inline void put(BitField field, bool value) { 275 inline void put(BitField field, bool value) {
274 bit_fields[field - BIT_FIELDS_BEGIN] = value; 276 bit_fields[field - BIT_FIELDS_BEGIN] = value;
(...skipping 10 matching lines...) Expand all
285 inline void put(AttachmentMetadataField field, 287 inline void put(AttachmentMetadataField field,
286 const sync_pb::AttachmentMetadata& value) { 288 const sync_pb::AttachmentMetadata& value) {
287 attachment_metadata_fields[field - ATTACHMENT_METADATA_FIELDS_BEGIN] 289 attachment_metadata_fields[field - ATTACHMENT_METADATA_FIELDS_BEGIN]
288 .set_value(value); 290 .set_value(value);
289 } 291 }
290 inline void put(BitTemp field, bool value) { 292 inline void put(BitTemp field, bool value) {
291 bit_temps[field - BIT_TEMPS_BEGIN] = value; 293 bit_temps[field - BIT_TEMPS_BEGIN] = value;
292 } 294 }
293 295
294 // Const ref getters. 296 // Const ref getters.
295 inline int64 ref(MetahandleField field) const { 297 inline int64_t ref(MetahandleField field) const {
296 return int64_fields[field - INT64_FIELDS_BEGIN]; 298 return int64_fields[field - INT64_FIELDS_BEGIN];
297 } 299 }
298 inline int64 ref(Int64Field field) const { 300 inline int64_t ref(Int64Field field) const {
299 return int64_fields[field - INT64_FIELDS_BEGIN]; 301 return int64_fields[field - INT64_FIELDS_BEGIN];
300 } 302 }
301 inline const base::Time& ref(TimeField field) const { 303 inline const base::Time& ref(TimeField field) const {
302 return time_fields[field - TIME_FIELDS_BEGIN]; 304 return time_fields[field - TIME_FIELDS_BEGIN];
303 } 305 }
304 inline const Id& ref(IdField field) const { 306 inline const Id& ref(IdField field) const {
305 return id_fields[field - ID_FIELDS_BEGIN]; 307 return id_fields[field - ID_FIELDS_BEGIN];
306 } 308 }
307 inline int64 ref(BaseVersion field) const { 309 inline int64_t ref(BaseVersion field) const {
308 return int64_fields[field - INT64_FIELDS_BEGIN]; 310 return int64_fields[field - INT64_FIELDS_BEGIN];
309 } 311 }
310 inline bool ref(IndexedBitField field) const { 312 inline bool ref(IndexedBitField field) const {
311 return bit_fields[field - BIT_FIELDS_BEGIN]; 313 return bit_fields[field - BIT_FIELDS_BEGIN];
312 } 314 }
313 inline bool ref(IsDelField field) const { 315 inline bool ref(IsDelField field) const {
314 return bit_fields[field - BIT_FIELDS_BEGIN]; 316 return bit_fields[field - BIT_FIELDS_BEGIN];
315 } 317 }
316 inline bool ref(BitField field) const { 318 inline bool ref(BitField field) const {
317 return bit_fields[field - BIT_FIELDS_BEGIN]; 319 return bit_fields[field - BIT_FIELDS_BEGIN];
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 397 }
396 }; 398 };
397 399
398 typedef std::set<const EntryKernel*, EntryKernelLessByMetaHandle> 400 typedef std::set<const EntryKernel*, EntryKernelLessByMetaHandle>
399 EntryKernelSet; 401 EntryKernelSet;
400 402
401 struct EntryKernelMutation { 403 struct EntryKernelMutation {
402 EntryKernel original, mutated; 404 EntryKernel original, mutated;
403 }; 405 };
404 406
405 typedef std::map<int64, EntryKernelMutation> EntryKernelMutationMap; 407 typedef std::map<int64_t, EntryKernelMutation> EntryKernelMutationMap;
406 408
407 typedef Immutable<EntryKernelMutationMap> ImmutableEntryKernelMutationMap; 409 typedef Immutable<EntryKernelMutationMap> ImmutableEntryKernelMutationMap;
408 410
409 // Caller owns the return value. 411 // Caller owns the return value.
410 base::DictionaryValue* EntryKernelMutationToValue( 412 base::DictionaryValue* EntryKernelMutationToValue(
411 const EntryKernelMutation& mutation); 413 const EntryKernelMutation& mutation);
412 414
413 // Caller owns the return value. 415 // Caller owns the return value.
414 base::ListValue* EntryKernelMutationMapToValue( 416 base::ListValue* EntryKernelMutationMapToValue(
415 const EntryKernelMutationMap& mutations); 417 const EntryKernelMutationMap& mutations);
416 418
417 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel); 419 std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel);
418 420
419 } // namespace syncable 421 } // namespace syncable
420 } // namespace syncer 422 } // namespace syncer
421 423
422 #endif // SYNC_SYNCABLE_ENTRY_KERNEL_H_ 424 #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