| 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 =
|
|
|