Index: chrome/browser/sync/syncable/syncable.h |
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h |
index e0fbe1d060cef2b1768b474214c277def288b5ef..e309ecbd1c53c9933cbac1e86cfbfbe501a0b371 100644 |
--- a/chrome/browser/sync/syncable/syncable.h |
+++ b/chrome/browser/sync/syncable/syncable.h |
@@ -33,6 +33,7 @@ |
#include "chrome/browser/sync/syncable/model_type.h" |
#include "chrome/browser/sync/util/dbgq.h" |
#include "chrome/browser/sync/util/immutable.h" |
+#include "chrome/browser/sync/util/time.h" |
struct PurgeInfo; |
@@ -58,8 +59,14 @@ class DirectoryBackingStore; |
static const int64 kInvalidMetaHandle = 0; |
-// Update syncable_enum_conversions{.h,.cc,_unittest.cc} if you change |
-// any fields in this file. |
+// Things you need to update if you change any of the fields below: |
+// - EntryKernel struct in syncable.h (this file) |
+// - syncable_columns.h |
+// - syncable_enum_conversions{.h,.cc,_unittest.cc} |
+// - ZeroFields(), EntryKernel::ToValue(), operator<< for Entry in |
+// syncable.cc |
+// - BindFields() and UnpackEntry() in directory_backing_store.cc |
+// - TestSimpleFieldsPreservedDuringSaveChanges in syncable_unittest.cc |
Nicolas Zea
2011/09/21 18:09:12
ouch.
akalin
2011/09/21 19:37:35
No kidding.
|
enum { |
BEGIN_FIELDS = 0, |
@@ -80,10 +87,6 @@ enum BaseVersion { |
enum Int64Field { |
SERVER_VERSION = BASE_VERSION + 1, |
- MTIME, |
- SERVER_MTIME, |
- CTIME, |
- SERVER_CTIME, |
// A numeric position value that indicates the relative ordering of |
// this object among its siblings. |
@@ -96,8 +99,21 @@ enum Int64Field { |
}; |
enum { |
- INT64_FIELDS_COUNT = INT64_FIELDS_END, |
- ID_FIELDS_BEGIN = INT64_FIELDS_END, |
+ INT64_FIELDS_COUNT = INT64_FIELDS_END - INT64_FIELDS_BEGIN, |
+ TIME_FIELDS_BEGIN = INT64_FIELDS_END, |
+}; |
+ |
+enum TimeField { |
+ MTIME = TIME_FIELDS_BEGIN, |
+ SERVER_MTIME, |
+ CTIME, |
+ SERVER_CTIME, |
+ TIME_FIELDS_END, |
+}; |
+ |
+enum { |
+ TIME_FIELDS_COUNT = TIME_FIELDS_END - TIME_FIELDS_BEGIN, |
+ ID_FIELDS_BEGIN = TIME_FIELDS_END, |
}; |
enum IdField { |
@@ -236,6 +252,7 @@ struct EntryKernel { |
std::string string_fields[STRING_FIELDS_COUNT]; |
sync_pb::EntitySpecifics specifics_fields[PROTO_FIELDS_COUNT]; |
int64 int64_fields[INT64_FIELDS_COUNT]; |
+ base::Time time_fields[TIME_FIELDS_COUNT]; |
Id id_fields[ID_FIELDS_COUNT]; |
std::bitset<BIT_FIELDS_COUNT> bit_fields; |
std::bitset<BIT_TEMPS_COUNT> bit_temps; |
@@ -277,6 +294,13 @@ struct EntryKernel { |
inline void put(Int64Field field, int64 value) { |
int64_fields[field - INT64_FIELDS_BEGIN] = value; |
} |
+ inline void put(TimeField field, const base::Time& value) { |
+ // Round-trip to proto time format and back so that we have |
+ // consistent time resolutions. |
Nicolas Zea
2011/09/21 18:09:12
consistent time resolutions (in milliseconds)
akalin
2011/09/21 19:37:35
Done.
|
+ time_fields[field - TIME_FIELDS_BEGIN] = |
+ browser_sync::ProtoTimeToTime( |
+ browser_sync::TimeToProtoTime(value)); |
+ } |
inline void put(IdField field, const Id& value) { |
id_fields[field - ID_FIELDS_BEGIN] = value; |
} |
@@ -309,6 +333,9 @@ struct EntryKernel { |
inline int64 ref(Int64Field field) const { |
return int64_fields[field - INT64_FIELDS_BEGIN]; |
} |
+ inline const base::Time& ref(TimeField field) const { |
+ return time_fields[field - TIME_FIELDS_BEGIN]; |
+ } |
inline const Id& ref(IdField field) const { |
return id_fields[field - ID_FIELDS_BEGIN]; |
} |
@@ -388,6 +415,10 @@ class Entry { |
DCHECK(kernel_); |
return kernel_->ref(field); |
} |
+ inline const base::Time& Get(TimeField field) const { |
+ DCHECK(kernel_); |
+ return kernel_->ref(field); |
+ } |
inline int64 Get(BaseVersion field) const { |
DCHECK(kernel_); |
return kernel_->ref(field); |
@@ -489,6 +520,7 @@ class MutableEntry : public Entry { |
// that putting the value would have caused a duplicate in the index. |
// TODO(chron): Remove some of these unecessary return values. |
bool Put(Int64Field field, const int64& value); |
+ bool Put(TimeField field, const base::Time& value); |
bool Put(IdField field, const Id& value); |
// Do a simple property-only update if the PARENT_ID field. Use with caution. |
@@ -1183,8 +1215,6 @@ class WriteTransaction : public BaseTransaction { |
bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); |
-int64 Now(); |
- |
// This function sets only the flags needed to get this entry to sync. |
void MarkForSyncing(syncable::MutableEntry* e); |