summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorfgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-22 07:49:59 +0000
committerfgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-22 07:49:59 +0000
commit495a7db9fe26af7797c8ee0c14c212068b3a91ff (patch)
tree6abf415535310428081abec384126b90e63710dc /google_apis
parente1407cd51ad10acf1ae553da898565debdc64936 (diff)
downloadchromium_src-495a7db9fe26af7797c8ee0c14c212068b3a91ff.zip
chromium_src-495a7db9fe26af7797c8ee0c14c212068b3a91ff.tar.gz
chromium_src-495a7db9fe26af7797c8ee0c14c212068b3a91ff.tar.bz2
[GCM] Adding a list of accounts present on the client to checkin request
We need to bind device id (profile specific) to accounts running in that profile. For that reason we are grabbing all of the accounts as tracked by the ProfileOAuth2TokenService and pass them to Initialize method of GCMClientImpl. The list of accounts is then passed to CheckinRequest when the request is happening. Once the CheckinRequest is done more often than simply on login, we may want to give a more updated list of accounts than the one present on startup of Chromium. For now there is no reason to handle that case. BUG=343203 Review URL: https://codereview.chromium.org/171513004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/gcm/engine/checkin_request.cc8
-rw-r--r--google_apis/gcm/engine/checkin_request.h11
-rw-r--r--google_apis/gcm/engine/checkin_request_unittest.cc13
-rw-r--r--google_apis/gcm/gcm_client.h2
-rw-r--r--google_apis/gcm/gcm_client_impl.cc18
-rw-r--r--google_apis/gcm/gcm_client_impl.h2
-rw-r--r--google_apis/gcm/gcm_client_impl_unittest.cc1
-rw-r--r--google_apis/gcm/tools/mcs_probe.cc2
8 files changed, 43 insertions, 14 deletions
diff --git a/google_apis/gcm/engine/checkin_request.cc b/google_apis/gcm/engine/checkin_request.cc
index 5e55f15..94a6fc9 100644
--- a/google_apis/gcm/engine/checkin_request.cc
+++ b/google_apis/gcm/engine/checkin_request.cc
@@ -52,6 +52,7 @@ CheckinRequest::CheckinRequest(
const checkin_proto::ChromeBuildProto& chrome_build_proto,
uint64 android_id,
uint64 security_token,
+ const std::vector<std::string>& account_ids,
net::URLRequestContextGetter* request_context_getter)
: request_context_getter_(request_context_getter),
callback_(callback),
@@ -59,6 +60,7 @@ CheckinRequest::CheckinRequest(
chrome_build_proto_(chrome_build_proto),
android_id_(android_id),
security_token_(security_token),
+ account_ids_(account_ids),
weak_ptr_factory_(this) {
}
@@ -81,6 +83,12 @@ void CheckinRequest::Start() {
checkin->set_type(checkin_proto::DEVICE_CHROME_BROWSER);
#endif
+ for (std::vector<std::string>::const_iterator iter = account_ids_.begin();
+ iter != account_ids_.end();
+ ++iter) {
+ request.add_account_cookie("[" + *iter + "]");
+ }
+
std::string upload_data;
CHECK(request.SerializeToString(&upload_data));
diff --git a/google_apis/gcm/engine/checkin_request.h b/google_apis/gcm/engine/checkin_request.h
index ede7ffd..e11089a 100644
--- a/google_apis/gcm/engine/checkin_request.h
+++ b/google_apis/gcm/engine/checkin_request.h
@@ -5,6 +5,9 @@
#ifndef GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_
#define GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_
+#include <string>
+#include <vector>
+
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
@@ -35,6 +38,7 @@ class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate {
const checkin_proto::ChromeBuildProto& chrome_build_proto,
uint64 android_id,
uint64 security_token,
+ const std::vector<std::string>& account_ids,
net::URLRequestContextGetter* request_context_getter);
virtual ~CheckinRequest();
@@ -53,9 +57,10 @@ class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate {
net::BackoffEntry backoff_entry_;
scoped_ptr<net::URLFetcher> url_fetcher_;
- checkin_proto::ChromeBuildProto chrome_build_proto_;
- uint64 android_id_;
- uint64 security_token_;
+ const checkin_proto::ChromeBuildProto chrome_build_proto_;
+ const uint64 android_id_;
+ const uint64 security_token_;
+ const std::vector<std::string> account_ids_;
base::WeakPtrFactory<CheckinRequest> weak_ptr_factory_;
diff --git a/google_apis/gcm/engine/checkin_request_unittest.cc b/google_apis/gcm/engine/checkin_request_unittest.cc
index ba77f9f..0142e0c 100644
--- a/google_apis/gcm/engine/checkin_request_unittest.cc
+++ b/google_apis/gcm/engine/checkin_request_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <string>
+#include <vector>
#include "google_apis/gcm/engine/checkin_request.h"
#include "google_apis/gcm/protocol/checkin.pb.h"
@@ -85,6 +86,7 @@ class CheckinRequestTest : public testing::Test {
net::TestURLFetcherFactory url_fetcher_factory_;
scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_;
checkin_proto::ChromeBuildProto chrome_build_proto_;
+ std::vector<std::string> account_ids_;
scoped_ptr<CheckinRequest> request_;
};
@@ -94,7 +96,9 @@ CheckinRequestTest::CheckinRequestTest()
security_token_(kBlankSecurityToken),
checkin_device_type_(0),
url_request_context_getter_(new net::TestURLRequestContextGetter(
- message_loop_.message_loop_proxy())) {}
+ message_loop_.message_loop_proxy())) {
+ account_ids_.push_back("account_id");
+}
CheckinRequestTest::~CheckinRequestTest() {}
@@ -116,12 +120,12 @@ void CheckinRequestTest::CreateRequest(uint64 android_id,
// Then create a request with that protobuf and specified android_id,
// security_token.
request_.reset(new CheckinRequest(
- base::Bind(&CheckinRequestTest::FetcherCallback,
- base::Unretained(this)),
+ base::Bind(&CheckinRequestTest::FetcherCallback, base::Unretained(this)),
kDefaultBackoffPolicy,
chrome_build_proto_,
android_id,
security_token,
+ account_ids_,
url_request_context_getter_.get()));
// Setting android_id_ and security_token_ to blank value, not used elsewhere
@@ -193,6 +197,9 @@ TEST_F(CheckinRequestTest, FetcherData) {
EXPECT_EQ(checkin_proto::DEVICE_CHROME_BROWSER,
request_proto.checkin().type());
#endif
+
+ EXPECT_EQ(1, request_proto.account_cookie_size());
+ EXPECT_EQ("[account_id]", request_proto.account_cookie(0));
}
TEST_F(CheckinRequestTest, ResponseBodyEmpty) {
diff --git a/google_apis/gcm/gcm_client.h b/google_apis/gcm/gcm_client.h
index 8bb616d..9280c68 100644
--- a/google_apis/gcm/gcm_client.h
+++ b/google_apis/gcm/gcm_client.h
@@ -135,6 +135,7 @@ class GCM_EXPORT GCMClient {
// Begins initialization of the GCM Client.
// |chrome_build_proto|: chrome info, i.e., version, channel and etc.
// |store_path|: path to the GCM store.
+ // |account_ids|: account IDs to be related to the device when checking in.
// |blocking_task_runner|: for running blocking file tasks.
// |url_request_context_getter|: for url requests.
// |delegate|: the delegate whose methods will be called asynchronously in
@@ -142,6 +143,7 @@ class GCM_EXPORT GCMClient {
virtual void Initialize(
const checkin_proto::ChromeBuildProto& chrome_build_proto,
const base::FilePath& store_path,
+ const std::vector<std::string>& account_ids,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter,
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index 491599c..d039fdc 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -126,6 +126,7 @@ GCMClientImpl::~GCMClientImpl() {
void GCMClientImpl::Initialize(
const checkin_proto::ChromeBuildProto& chrome_build_proto,
const base::FilePath& path,
+ const std::vector<std::string>& account_ids,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter,
@@ -136,6 +137,7 @@ void GCMClientImpl::Initialize(
chrome_build_proto_.CopyFrom(chrome_build_proto);
url_request_context_getter_ = url_request_context_getter;
+ account_ids_ = account_ids;
gcm_store_.reset(new GCMStoreImpl(false, path, blocking_task_runner));
gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted,
@@ -232,14 +234,14 @@ void GCMClientImpl::ResetState() {
void GCMClientImpl::StartCheckin(const CheckinInfo& checkin_info) {
checkin_request_.reset(
- new CheckinRequest(
- base::Bind(&GCMClientImpl::OnCheckinCompleted,
- weak_ptr_factory_.GetWeakPtr()),
- kDefaultBackoffPolicy,
- chrome_build_proto_,
- checkin_info.android_id,
- checkin_info.secret,
- url_request_context_getter_));
+ new CheckinRequest(base::Bind(&GCMClientImpl::OnCheckinCompleted,
+ weak_ptr_factory_.GetWeakPtr()),
+ kDefaultBackoffPolicy,
+ chrome_build_proto_,
+ checkin_info.android_id,
+ checkin_info.secret,
+ account_ids_,
+ url_request_context_getter_));
checkin_request_->Start();
}
diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h
index 40b90f2..9299bd5 100644
--- a/google_apis/gcm/gcm_client_impl.h
+++ b/google_apis/gcm/gcm_client_impl.h
@@ -50,6 +50,7 @@ class GCM_EXPORT GCMClientImpl : public GCMClient {
virtual void Initialize(
const checkin_proto::ChromeBuildProto& chrome_build_proto,
const base::FilePath& store_path,
+ const std::vector<std::string>& account_ids,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter,
@@ -195,6 +196,7 @@ class GCM_EXPORT GCMClientImpl : public GCMClient {
scoped_ptr<MCSClient> mcs_client_;
scoped_ptr<CheckinRequest> checkin_request_;
+ std::vector<std::string> account_ids_;
// Currently pending registrations. GCMClientImpl owns the
// RegistrationRequests.
diff --git a/google_apis/gcm/gcm_client_impl_unittest.cc b/google_apis/gcm/gcm_client_impl_unittest.cc
index 18b41c6..42ecf86 100644
--- a/google_apis/gcm/gcm_client_impl_unittest.cc
+++ b/google_apis/gcm/gcm_client_impl_unittest.cc
@@ -280,6 +280,7 @@ void GCMClientImplTest::InitializeGCMClient() {
checkin_proto::ChromeBuildProto chrome_build_proto;
gcm_client_->Initialize(chrome_build_proto,
temp_directory_.path(),
+ std::vector<std::string>(),
message_loop_.message_loop_proxy(),
url_request_context_getter_,
this);
diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc
index 991413d..48815df 100644
--- a/google_apis/gcm/tools/mcs_probe.cc
+++ b/google_apis/gcm/tools/mcs_probe.cc
@@ -8,6 +8,7 @@
#include <cstddef>
#include <cstdio>
#include <string>
+#include <vector>
#include "base/at_exit.h"
#include "base/command_line.h"
@@ -426,6 +427,7 @@ void MCSProbe::CheckIn() {
chrome_build_proto,
0,
0,
+ std::vector<std::string>(),
url_request_context_getter_.get()));
checkin_request_->Start();
}