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

Unified Diff: sync/engine/syncer_proto_util.cc

Issue 10916276: sync: add Google API Key to all ClientToServerMessages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: sync/engine/syncer_proto_util.cc
diff --git a/sync/engine/syncer_proto_util.cc b/sync/engine/syncer_proto_util.cc
index 81b3c64cb97d2b7560bf363089a545bdbdf62bf7..c24b538f230d4613f5a2e4dc6cfeaa2c753244e5 100644
--- a/sync/engine/syncer_proto_util.cc
+++ b/sync/engine/syncer_proto_util.cc
@@ -6,6 +6,7 @@
#include "base/format_macros.h"
#include "base/stringprintf.h"
+#include "google_apis/google_api_keys.h"
#include "sync/engine/net/server_connection_manager.h"
#include "sync/engine/syncer.h"
#include "sync/engine/syncer_types.h"
@@ -346,24 +347,27 @@ SyncProtocolError ConvertLegacyErrorCodeToNewError(
// static
SyncerError SyncerProtoUtil::PostClientToServerMessage(
- const ClientToServerMessage& msg,
+ ClientToServerMessage* msg,
ClientToServerResponse* response,
SyncSession* session) {
CHECK(response);
- DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated.
- 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.";
+ DCHECK(!msg->get_updates().has_from_timestamp()); // Deprecated.
+ DCHECK(!msg->get_updates().has_requested_types()); // Deprecated.
+
+ // Add must-have fields.
+ SetProtocolVersion(msg);
+ AddRequestBirthday(session->context()->directory(), msg);
+ DCHECK(msg->has_store_birthday() || IsVeryFirstGetUpdates(*msg));
+ AddBagOfChips(session->context()->directory(), msg);
+ msg->set_api_key(google_apis::GetAPIKey());
syncable::Directory* dir = session->context()->directory();
- LogClientToServerMessage(msg);
- session->context()->traffic_recorder()->RecordClientToServerMessage(msg);
+ LogClientToServerMessage(*msg);
+ session->context()->traffic_recorder()->RecordClientToServerMessage(*msg);
if (!PostAndProcessHeaders(session->context()->connection_manager(), session,
- msg, response)) {
+ *msg, response)) {
// There was an error establishing communication with the server.
// We can not proceed beyond this point.
const HttpResponse::ServerConnectionCode server_status =

Powered by Google App Engine
This is Rietveld 408576698