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

Unified Diff: chrome/browser/sync/glue/synced_device_tracker.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: check db on DB thread Created 6 years, 5 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: chrome/browser/sync/glue/synced_device_tracker.cc
diff --git a/chrome/browser/sync/glue/synced_device_tracker.cc b/chrome/browser/sync/glue/synced_device_tracker.cc
index bf7fa9274fc78f9303bb4dd184b690e32702f28f..e77463e3d7df6f0ef7cf986f938852531e5df118 100644
--- a/chrome/browser/sync/glue/synced_device_tracker.cc
+++ b/chrome/browser/sync/glue/synced_device_tracker.cc
@@ -13,6 +13,7 @@
#include "sync/internal_api/public/user_share.h"
#include "sync/internal_api/public/write_node.h"
#include "sync/internal_api/public/write_transaction.h"
+#include "sync/util/time.h"
namespace browser_sync {
@@ -157,25 +158,28 @@ void SyncedDeviceTracker::InitLocalDeviceInfoContinuation(
}
void SyncedDeviceTracker::WriteLocalDeviceInfo(const DeviceInfo& info) {
- sync_pb::DeviceInfoSpecifics specifics;
DCHECK_EQ(cache_guid_, info.guid());
- specifics.set_cache_guid(cache_guid_);
- specifics.set_client_name(info.client_name());
- specifics.set_chrome_version(info.chrome_version());
- specifics.set_sync_user_agent(info.sync_user_agent());
- specifics.set_device_type(info.device_type());
-
- WriteDeviceInfo(specifics, local_device_info_tag_);
+ WriteDeviceInfo(info, local_device_info_tag_);
}
-void SyncedDeviceTracker::WriteDeviceInfo(
- const sync_pb::DeviceInfoSpecifics& specifics,
- const std::string& tag) {
+void SyncedDeviceTracker::WriteDeviceInfo(const DeviceInfo& info,
+ const std::string& tag) {
syncer::WriteTransaction trans(FROM_HERE, user_share_);
syncer::WriteNode node(&trans);
+ sync_pb::DeviceInfoSpecifics specifics;
+ specifics.set_cache_guid(info.guid());
+ specifics.set_client_name(info.client_name());
+ specifics.set_chrome_version(info.chrome_version());
+ specifics.set_sync_user_agent(info.sync_user_agent());
+ specifics.set_device_type(info.device_type());
+
if (node.InitByClientTagLookup(syncer::DEVICE_INFO, tag) ==
syncer::BaseNode::INIT_OK) {
+ const sync_pb::DeviceInfoSpecifics& sync_specifics =
+ node.GetDeviceInfoSpecifics();
+ if (sync_specifics.has_backup_timestamp())
+ specifics.set_backup_timestamp(sync_specifics.backup_timestamp());
node.SetDeviceInfoSpecifics(specifics);
node.SetTitle(specifics.client_name());
} else {
@@ -195,4 +199,33 @@ void SyncedDeviceTracker::WriteDeviceInfo(
}
}
+void SyncedDeviceTracker::UpdateLocalDeviceBackupTime(base::Time backup_time) {
+ syncer::WriteTransaction trans(FROM_HERE, user_share_);
+ syncer::WriteNode node(&trans);
+
+ if (node.InitByClientTagLookup(syncer::DEVICE_INFO, local_device_info_tag_)
+ == syncer::BaseNode::INIT_OK) {
+ sync_pb::DeviceInfoSpecifics specifics = node.GetDeviceInfoSpecifics();
+ int64 new_backup_timestamp = syncer::TimeToProtoTime(backup_time);
+ if (!specifics.has_backup_timestamp() ||
+ specifics.backup_timestamp() != new_backup_timestamp) {
+ specifics.set_backup_timestamp(new_backup_timestamp);
+ node.SetDeviceInfoSpecifics(specifics);
+ }
+ }
+}
+
+base::Time SyncedDeviceTracker::GetLocalDeviceBackupTime() const {
+ syncer::ReadTransaction trans(FROM_HERE, user_share_);
+ syncer::ReadNode node(&trans);
+ if (node.InitByClientTagLookup(syncer::DEVICE_INFO, local_device_info_tag_)
+ == syncer::BaseNode::INIT_OK &&
+ node.GetDeviceInfoSpecifics().has_backup_timestamp()) {
+ return syncer::ProtoTimeToTime(
+ node.GetDeviceInfoSpecifics().backup_timestamp());
+ } else {
+ return base::Time();
+ }
+}
+
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/synced_device_tracker.h ('k') | chrome/browser/sync/glue/synced_device_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698