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

Unified Diff: sync/protocol/proto_value_conversions.cc

Issue 332923002: [sync] Add backup time in synced device info so that server can flag device (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: sync/protocol/proto_value_conversions.cc
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 5ea434c39b28eadabce45de6a6e09c74cebf177e..1c95e8137e139bc5b2e5f1f041b5d3fc3a45726a 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -10,8 +10,10 @@
#include "base/base64.h"
#include "base/basictypes.h"
+#include "base/i18n/time_formatting.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
+#include "base/time/time.h"
#include "base/values.h"
#include "sync/internal_api/public/base/unique_position.h"
#include "sync/protocol/app_list_specifics.pb.h"
@@ -82,6 +84,11 @@ base::ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) {
return list;
}
+base::StringValue* MakeTimestampValue(int64 tm) {
+ return new base::StringValue(
+ base::TimeFormatShortDateAndTime(base::Time::FromInternalValue(tm)));
+}
+
} // namespace
// Helper macros to reduce the amount of boilerplate.
@@ -102,6 +109,7 @@ base::ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) {
#define SET_INT64(field) SET(field, MakeInt64Value)
#define SET_INT64_REP(field) SET_REP(field, MakeInt64Value)
#define SET_STR(field) SET(field, new base::StringValue)
+#define SET_TIME_STR(field) SET(field, MakeTimestampValue)
#define SET_STR_REP(field) \
value->Set(#field, \
MakeRepeatedValue<const std::string&, \
@@ -488,6 +496,7 @@ base::DictionaryValue* DeviceInfoSpecificsToValue(
SET_ENUM(device_type, GetDeviceTypeString);
SET_STR(sync_user_agent);
SET_STR(chrome_version);
+ SET_TIME_STR(backup_timestamp);
return value;
}

Powered by Google App Engine
This is Rietveld 408576698