summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-17 05:40:06 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-17 05:40:06 +0000
commit61161fdc716423ae44471cb08893977a8ed995ae (patch)
tree7e15efa48ae620addf6bfd7966835b99d1600022 /sync
parent9874e3fbb370cab52617c2d4dd64340d75a9c8b2 (diff)
downloadchromium_src-61161fdc716423ae44471cb08893977a8ed995ae.zip
chromium_src-61161fdc716423ae44471cb08893977a8ed995ae.tar.gz
chromium_src-61161fdc716423ae44471cb08893977a8ed995ae.tar.bz2
sync: add Google API Key to all ClientToServerMessages.
Also move setting of "must have" sync fields to PostClientToServerMessage (from DownloadUpdatesCommand & BuildCommitCommand). Needed for M23 branch. BUG= Review URL: https://chromiumcodereview.appspot.com/10916276 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/DEPS1
-rw-r--r--sync/engine/build_commit_command.cc5
-rw-r--r--sync/engine/commit.cc2
-rw-r--r--sync/engine/download_updates_command.cc6
-rw-r--r--sync/engine/syncer_proto_util.cc24
-rw-r--r--sync/engine/syncer_proto_util.h2
-rw-r--r--sync/protocol/sync.proto3
-rw-r--r--sync/sync.gyp1
-rw-r--r--sync/test/engine/mock_connection_manager.cc2
9 files changed, 24 insertions, 22 deletions
diff --git a/sync/DEPS b/sync/DEPS
index e3938ed..bbe2669 100644
--- a/sync/DEPS
+++ b/sync/DEPS
@@ -6,6 +6,7 @@ include_rules = [
# to test.
"+base",
"+build",
+ "+google_apis",
"+testing",
# Force subdirectories to explicitly define DEPS.
diff --git a/sync/engine/build_commit_command.cc b/sync/engine/build_commit_command.cc
index ade6acb..8e51ddb 100644
--- a/sync/engine/build_commit_command.cc
+++ b/sync/engine/build_commit_command.cc
@@ -111,11 +111,6 @@ SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
commit_message->set_cache_guid(
session->write_transaction()->directory()->cache_guid());
AddExtensionsActivityToMessage(session, commit_message);
- SyncerProtoUtil::SetProtocolVersion(commit_message_);
- SyncerProtoUtil::AddRequestBirthday(
- session->write_transaction()->directory(), commit_message_);
- SyncerProtoUtil::AddBagOfChips(
- session->write_transaction()->directory(), commit_message_);
// Cache previously computed position values. Because |commit_ids|
// is already in sibling order, we should always hit this map after
diff --git a/sync/engine/commit.cc b/sync/engine/commit.cc
index 731643a..49443e9 100644
--- a/sync/engine/commit.cc
+++ b/sync/engine/commit.cc
@@ -101,7 +101,7 @@ SyncerError BuildAndPostCommitsImpl(Syncer* syncer,
DVLOG(1) << "Sending commit message.";
TRACE_EVENT_BEGIN0("sync", "PostCommit");
const SyncerError post_result = SyncerProtoUtil::PostClientToServerMessage(
- commit_message, &commit_response, session);
+ &commit_message, &commit_response, session);
TRACE_EVENT_END0("sync", "PostCommit");
if (post_result != SYNCER_OK) {
diff --git a/sync/engine/download_updates_command.cc b/sync/engine/download_updates_command.cc
index cd0730a..50ad8a0 100644
--- a/sync/engine/download_updates_command.cc
+++ b/sync/engine/download_updates_command.cc
@@ -109,16 +109,12 @@ SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) {
get_updates->mutable_caller_info()->set_notifications_enabled(
session->context()->notifications_enabled());
- SyncerProtoUtil::SetProtocolVersion(&client_to_server_message);
- SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message);
- SyncerProtoUtil::AddBagOfChips(dir, &client_to_server_message);
-
DebugInfo* debug_info = client_to_server_message.mutable_debug_info();
AppendClientDebugInfoIfNeeded(session, debug_info);
SyncerError result = SyncerProtoUtil::PostClientToServerMessage(
- client_to_server_message,
+ &client_to_server_message,
&update_response,
session);
diff --git a/sync/engine/syncer_proto_util.cc b/sync/engine/syncer_proto_util.cc
index 81b3c64..c24b538 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 =
diff --git a/sync/engine/syncer_proto_util.h b/sync/engine/syncer_proto_util.h
index fab1406..8256dbd 100644
--- a/sync/engine/syncer_proto_util.h
+++ b/sync/engine/syncer_proto_util.h
@@ -43,7 +43,7 @@ class SyncerProtoUtil {
// Returns true on success. Also handles store birthday verification: will
// produce a SyncError if the birthday is incorrect.
static SyncerError PostClientToServerMessage(
- const sync_pb::ClientToServerMessage& msg,
+ sync_pb::ClientToServerMessage* msg,
sync_pb::ClientToServerResponse* response,
sessions::SyncSession* session);
diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto
index 5e637ed..618e129 100644
--- a/sync/protocol/sync.proto
+++ b/sync/protocol/sync.proto
@@ -499,6 +499,9 @@ message ClientToServerMessage {
// Per-client state for use by the server. Sent with every message sent to the
// server.
optional ChipBag bag_of_chips = 11;
+
+ // Google API key.
+ optional string api_key = 12;
};
message CommitResponse {
diff --git a/sync/sync.gyp b/sync/sync.gyp
index 1e21ad4..1d29098 100644
--- a/sync/sync.gyp
+++ b/sync/sync.gyp
@@ -29,6 +29,7 @@
'../base/base.gyp:base',
'../build/temp_gyp/googleurl.gyp:googleurl',
'../crypto/crypto.gyp:crypto',
+ '../google_apis/google_apis.gyp:google_apis',
'../net/net.gyp:net',
'../sql/sql.gyp:sql',
'protocol/sync_proto.gyp:sync_proto',
diff --git a/sync/test/engine/mock_connection_manager.cc b/sync/test/engine/mock_connection_manager.cc
index 8d03a10..cc4b09c 100644
--- a/sync/test/engine/mock_connection_manager.cc
+++ b/sync/test/engine/mock_connection_manager.cc
@@ -82,6 +82,8 @@ bool MockConnectionManager::PostBufferToPath(PostBufferParams* params,
ClientToServerMessage post;
CHECK(post.ParseFromString(params->buffer_in));
CHECK(post.has_protocol_version());
+ CHECK(post.has_api_key());
+ CHECK(post.has_bag_of_chips());
last_request_.CopyFrom(post);
client_stuck_ = post.sync_problem_detected();
sync_pb::ClientToServerResponse response;