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

Unified Diff: sync/engine/syncer_proto_util.cc

Issue 10916174: Implement a bag of chips for sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 8 years, 3 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
« no previous file with comments | « sync/engine/syncer_proto_util.h ('k') | sync/protocol/sync.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/syncer_proto_util.cc
diff --git a/sync/engine/syncer_proto_util.cc b/sync/engine/syncer_proto_util.cc
index 8149ad8e5301500f0c3044e2d4acc97cf3323854..eef0208a71bb95e343012dbb5e3ce5e4ea8ce423 100644
--- a/sync/engine/syncer_proto_util.cc
+++ b/sync/engine/syncer_proto_util.cc
@@ -163,6 +163,12 @@ void SyncerProtoUtil::AddRequestBirthday(syncable::Directory* dir,
}
// static
+void SyncerProtoUtil::AddBagOfChips(syncable::Directory* dir,
+ ClientToServerMessage* msg) {
+ msg->mutable_bag_of_chips()->ParseFromString(dir->bag_of_chips());
+}
+
+// static
void SyncerProtoUtil::SetProtocolVersion(ClientToServerMessage* msg) {
const int current_version =
ClientToServerMessage::default_instance().protocol_version();
@@ -349,6 +355,8 @@ SyncerError SyncerProtoUtil::PostClientToServerMessage(
DCHECK(!msg.get_updates().has_requested_types()); // Deprecated.
DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg))
<< "Must call AddRequestBirthday to set birthday.";
+ DCHECK(msg.has_bag_of_chips())
+ << "Must call AddBagOfChips to set bag_of_chips.";
syncable::Directory* dir = session->context()->directory();
@@ -371,6 +379,9 @@ SyncerError SyncerProtoUtil::PostClientToServerMessage(
session->context()->traffic_recorder()->RecordClientToServerResponse(
*response);
+ // Persist a bag of chips if it has been sent by the server.
+ PersistBagOfChips(dir, *response);
+
SyncProtocolError sync_protocol_error;
// Birthday mismatch overrides any error that is sent by the server.
@@ -509,6 +520,16 @@ const std::string& SyncerProtoUtil::NameFromCommitEntryResponse(
return entry.name();
}
+// static
+void SyncerProtoUtil::PersistBagOfChips(syncable::Directory* dir,
+ const sync_pb::ClientToServerResponse& response) {
+ if (!response.has_new_bag_of_chips())
+ return;
+ std::string bag_of_chips;
+ if (response.new_bag_of_chips().SerializeToString(&bag_of_chips))
+ dir->set_bag_of_chips(bag_of_chips);
+}
+
std::string SyncerProtoUtil::SyncEntityDebugString(
const sync_pb::SyncEntity& entry) {
const std::string& mtime_str =
« no previous file with comments | « sync/engine/syncer_proto_util.h ('k') | sync/protocol/sync.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698