| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "sync/internal_api/public/base/model_type.h" | 10 #include "sync/internal_api/public/base/model_type.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 inline void put(MetahandleField field, int64 value) { | 209 inline void put(MetahandleField field, int64 value) { |
| 210 int64_fields[field - INT64_FIELDS_BEGIN] = value; | 210 int64_fields[field - INT64_FIELDS_BEGIN] = value; |
| 211 } | 211 } |
| 212 inline void put(Int64Field field, int64 value) { | 212 inline void put(Int64Field field, int64 value) { |
| 213 int64_fields[field - INT64_FIELDS_BEGIN] = value; | 213 int64_fields[field - INT64_FIELDS_BEGIN] = value; |
| 214 } | 214 } |
| 215 inline void put(TimeField field, const base::Time& value) { | 215 inline void put(TimeField field, const base::Time& value) { |
| 216 // Round-trip to proto time format and back so that we have | 216 // Round-trip to proto time format and back so that we have |
| 217 // consistent time resolutions (ms). | 217 // consistent time resolutions (ms). |
| 218 time_fields[field - TIME_FIELDS_BEGIN] = | 218 time_fields[field - TIME_FIELDS_BEGIN] = |
| 219 syncer::ProtoTimeToTime( | 219 ProtoTimeToTime(TimeToProtoTime(value)); |
| 220 syncer::TimeToProtoTime(value)); | |
| 221 } | 220 } |
| 222 inline void put(IdField field, const Id& value) { | 221 inline void put(IdField field, const Id& value) { |
| 223 id_fields[field - ID_FIELDS_BEGIN] = value; | 222 id_fields[field - ID_FIELDS_BEGIN] = value; |
| 224 } | 223 } |
| 225 inline void put(BaseVersion field, int64 value) { | 224 inline void put(BaseVersion field, int64 value) { |
| 226 int64_fields[field - INT64_FIELDS_BEGIN] = value; | 225 int64_fields[field - INT64_FIELDS_BEGIN] = value; |
| 227 } | 226 } |
| 228 inline void put(IndexedBitField field, bool value) { | 227 inline void put(IndexedBitField field, bool value) { |
| 229 bit_fields[field - BIT_FIELDS_BEGIN] = value; | 228 bit_fields[field - BIT_FIELDS_BEGIN] = value; |
| 230 } | 229 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 inline std::string& mutable_ref(StringField field) { | 282 inline std::string& mutable_ref(StringField field) { |
| 284 return string_fields[field - STRING_FIELDS_BEGIN]; | 283 return string_fields[field - STRING_FIELDS_BEGIN]; |
| 285 } | 284 } |
| 286 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) { | 285 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) { |
| 287 return specifics_fields[field - PROTO_FIELDS_BEGIN]; | 286 return specifics_fields[field - PROTO_FIELDS_BEGIN]; |
| 288 } | 287 } |
| 289 inline Id& mutable_ref(IdField field) { | 288 inline Id& mutable_ref(IdField field) { |
| 290 return id_fields[field - ID_FIELDS_BEGIN]; | 289 return id_fields[field - ID_FIELDS_BEGIN]; |
| 291 } | 290 } |
| 292 | 291 |
| 293 syncer::ModelType GetServerModelType() const; | 292 ModelType GetServerModelType() const; |
| 294 | 293 |
| 295 // Dumps all kernel info into a DictionaryValue and returns it. | 294 // Dumps all kernel info into a DictionaryValue and returns it. |
| 296 // Transfers ownership of the DictionaryValue to the caller. | 295 // Transfers ownership of the DictionaryValue to the caller. |
| 297 base::DictionaryValue* ToValue() const; | 296 base::DictionaryValue* ToValue() const; |
| 298 | 297 |
| 299 private: | 298 private: |
| 300 // Tracks whether this entry needs to be saved to the database. | 299 // Tracks whether this entry needs to be saved to the database. |
| 301 bool dirty_; | 300 bool dirty_; |
| 302 }; | 301 }; |
| 303 | 302 |
| 304 struct EntryKernelMutation { | 303 struct EntryKernelMutation { |
| 305 EntryKernel original, mutated; | 304 EntryKernel original, mutated; |
| 306 }; | 305 }; |
| 307 | 306 |
| 308 typedef std::map<int64, EntryKernelMutation> EntryKernelMutationMap; | 307 typedef std::map<int64, EntryKernelMutation> EntryKernelMutationMap; |
| 309 | 308 |
| 310 typedef syncer::Immutable<EntryKernelMutationMap> | 309 typedef Immutable<EntryKernelMutationMap> ImmutableEntryKernelMutationMap; |
| 311 ImmutableEntryKernelMutationMap; | |
| 312 | 310 |
| 313 // Caller owns the return value. | 311 // Caller owns the return value. |
| 314 base::DictionaryValue* EntryKernelMutationToValue( | 312 base::DictionaryValue* EntryKernelMutationToValue( |
| 315 const EntryKernelMutation& mutation); | 313 const EntryKernelMutation& mutation); |
| 316 | 314 |
| 317 // Caller owns the return value. | 315 // Caller owns the return value. |
| 318 base::ListValue* EntryKernelMutationMapToValue( | 316 base::ListValue* EntryKernelMutationMapToValue( |
| 319 const EntryKernelMutationMap& mutations); | 317 const EntryKernelMutationMap& mutations); |
| 320 | 318 |
| 321 } // namespace syncable | 319 } // namespace syncable |
| 322 } // namespace syncer | 320 } // namespace syncer |
| 323 | 321 |
| 324 #endif // SYNC_SYNCABLE_ENTRY_KERNEL_H_ | 322 #endif // SYNC_SYNCABLE_ENTRY_KERNEL_H_ |
| OLD | NEW |