summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-23 09:40:47 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-23 09:40:47 +0000
commit8ad8051519e60fb7ddfa97b7e4e27586c99a8ec4 (patch)
treea0272a2abe5ae3cba39369b8f3ed69ae61824ba8 /google_apis
parent46d78188ccbeb77c54643ef3d5084f8f6e07ba23 (diff)
downloadchromium_src-8ad8051519e60fb7ddfa97b7e4e27586c99a8ec4.zip
chromium_src-8ad8051519e60fb7ddfa97b7e4e27586c99a8ec4.tar.gz
chromium_src-8ad8051519e60fb7ddfa97b7e4e27586c99a8ec4.tar.bz2
Retrieve chrome build info in GCMProfileService, instead of GCMDriver
Since GCMDriver is going to be moved into component, it cannot access chrome build info. So we now let GCMProfileService retrieve and pass it. Also change to define build info in GCMClient, instead of relying on the one defined in proto buffer generated file. BUG=356716 TEST=existing tests Patch Review URL: https://codereview.chromium.org/293053014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/gcm/gcm_client.cc8
-rw-r--r--google_apis/gcm/gcm_client.h35
-rw-r--r--google_apis/gcm/gcm_client_impl.cc72
-rw-r--r--google_apis/gcm/gcm_client_impl.h4
-rw-r--r--google_apis/gcm/gcm_client_impl_unittest.cc4
5 files changed, 109 insertions, 14 deletions
diff --git a/google_apis/gcm/gcm_client.cc b/google_apis/gcm/gcm_client.cc
index dd2a316..93a2d07 100644
--- a/google_apis/gcm/gcm_client.cc
+++ b/google_apis/gcm/gcm_client.cc
@@ -6,6 +6,14 @@
namespace gcm {
+GCMClient::ChromeBuildInfo::ChromeBuildInfo()
+ : platform(PLATFORM_UNKNOWN),
+ channel(CHANNEL_UNKNOWN) {
+}
+
+GCMClient::ChromeBuildInfo::~ChromeBuildInfo() {
+}
+
GCMClient::OutgoingMessage::OutgoingMessage()
: time_to_live(kMaximumTTL) {
}
diff --git a/google_apis/gcm/gcm_client.h b/google_apis/gcm/gcm_client.h
index 178b18f..02111c8 100644
--- a/google_apis/gcm/gcm_client.h
+++ b/google_apis/gcm/gcm_client.h
@@ -20,10 +20,6 @@ class FilePath;
class SequencedTaskRunner;
}
-namespace checkin_proto {
-class ChromeBuildProto;
-}
-
namespace net {
class URLRequestContextGetter;
}
@@ -58,6 +54,33 @@ class GCM_EXPORT GCMClient {
UNKNOWN_ERROR
};
+ enum ChromePlatform {
+ PLATFORM_WIN,
+ PLATFORM_MAC,
+ PLATFORM_LINUX,
+ PLATFORM_CROS,
+ PLATFORM_IOS,
+ PLATFORM_ANDROID,
+ PLATFORM_UNKNOWN
+ };
+
+ enum ChromeChannel {
+ CHANNEL_STABLE,
+ CHANNEL_BETA,
+ CHANNEL_DEV,
+ CHANNEL_CANARY,
+ CHANNEL_UNKNOWN
+ };
+
+ struct GCM_EXPORT ChromeBuildInfo {
+ ChromeBuildInfo();
+ ~ChromeBuildInfo();
+
+ ChromePlatform platform;
+ ChromeChannel channel;
+ std::string version;
+ };
+
// Message data consisting of key-value pairs.
typedef std::map<std::string, std::string> MessageData;
@@ -173,7 +196,7 @@ class GCM_EXPORT GCMClient {
// Begins initialization of the GCM Client. This will not trigger a
// connection.
- // |chrome_build_proto|: chrome info, i.e., version, channel and etc.
+ // |chrome_build_info|: 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.
@@ -181,7 +204,7 @@ class GCM_EXPORT GCMClient {
// |delegate|: the delegate whose methods will be called asynchronously in
// response to events and messages.
virtual void Initialize(
- const checkin_proto::ChromeBuildProto& chrome_build_proto,
+ const ChromeBuildInfo& chrome_build_info,
const base::FilePath& store_path,
const std::vector<std::string>& account_ids,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index 3225454..b5a3ae6 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -21,6 +21,7 @@
#include "google_apis/gcm/engine/connection_factory_impl.h"
#include "google_apis/gcm/engine/gcm_store_impl.h"
#include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
+#include "google_apis/gcm/protocol/checkin.pb.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
#include "net/http/http_network_session.h"
#include "net/url_request/url_request_context.h"
@@ -115,6 +116,67 @@ GCMClient::Result ToGCMClientResult(MCSClient::MessageSendStatus status) {
return GCMClientImpl::UNKNOWN_ERROR;
}
+void ToCheckinProtoVersion(
+ const GCMClient::ChromeBuildInfo& chrome_build_info,
+ checkin_proto::ChromeBuildProto* android_build_info) {
+ checkin_proto::ChromeBuildProto_Platform platform;
+ switch (chrome_build_info.platform) {
+ case GCMClient::PLATFORM_WIN:
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_WIN;
+ break;
+ case GCMClient::PLATFORM_MAC:
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_MAC;
+ break;
+ case GCMClient::PLATFORM_LINUX:
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_LINUX;
+ break;
+ case GCMClient::PLATFORM_IOS:
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_IOS;
+ break;
+ case GCMClient::PLATFORM_ANDROID:
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_ANDROID;
+ break;
+ case GCMClient::PLATFORM_CROS:
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_CROS;
+ break;
+ case GCMClient::PLATFORM_UNKNOWN:
+ // For unknown platform, return as LINUX.
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_LINUX;
+ break;
+ default:
+ NOTREACHED();
+ platform = checkin_proto::ChromeBuildProto_Platform_PLATFORM_LINUX;
+ break;
+ }
+ android_build_info->set_platform(platform);
+
+ checkin_proto::ChromeBuildProto_Channel channel;
+ switch (chrome_build_info.channel) {
+ case GCMClient::CHANNEL_STABLE:
+ channel = checkin_proto::ChromeBuildProto_Channel_CHANNEL_STABLE;
+ break;
+ case GCMClient::CHANNEL_BETA:
+ channel = checkin_proto::ChromeBuildProto_Channel_CHANNEL_BETA;
+ break;
+ case GCMClient::CHANNEL_DEV:
+ channel = checkin_proto::ChromeBuildProto_Channel_CHANNEL_DEV;
+ break;
+ case GCMClient::CHANNEL_CANARY:
+ channel = checkin_proto::ChromeBuildProto_Channel_CHANNEL_CANARY;
+ break;
+ case GCMClient::CHANNEL_UNKNOWN:
+ channel = checkin_proto::ChromeBuildProto_Channel_CHANNEL_UNKNOWN;
+ break;
+ default:
+ NOTREACHED();
+ channel = checkin_proto::ChromeBuildProto_Channel_CHANNEL_UNKNOWN;
+ break;
+ }
+ android_build_info->set_channel(channel);
+
+ android_build_info->set_chrome_version(chrome_build_info.version);
+}
+
MessageType DecodeMessageType(const std::string& value) {
if (kMessageTypeDeletedMessagesKey == value)
return DELETED_MESSAGES;
@@ -201,7 +263,7 @@ GCMClientImpl::~GCMClientImpl() {
}
void GCMClientImpl::Initialize(
- const checkin_proto::ChromeBuildProto& chrome_build_proto,
+ const ChromeBuildInfo& chrome_build_info,
const base::FilePath& path,
const std::vector<std::string>& account_ids,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
@@ -220,7 +282,7 @@ void GCMClientImpl::Initialize(
DCHECK(network_session_params);
network_session_ = new net::HttpNetworkSession(*network_session_params);
- chrome_build_proto_.CopyFrom(chrome_build_proto);
+ chrome_build_info_ = chrome_build_info;
account_ids_ = account_ids;
gcm_store_.reset(
@@ -280,7 +342,7 @@ void GCMClientImpl::InitializeMCSClient(
net_log_.net_log(),
&recorder_);
mcs_client_ = internals_builder_->BuildMCSClient(
- chrome_build_proto_.chrome_version(),
+ chrome_build_info_.version,
clock_.get(),
connection_factory_.get(),
gcm_store_.get(),
@@ -333,11 +395,13 @@ void GCMClientImpl::StartCheckin() {
if (checkin_request_.get())
return;
+ checkin_proto::ChromeBuildProto chrome_build_proto;
+ ToCheckinProtoVersion(chrome_build_info_, &chrome_build_proto);
CheckinRequest::RequestInfo request_info(device_checkin_info_.android_id,
device_checkin_info_.secret,
gservices_settings_.digest(),
account_ids_,
- chrome_build_proto_);
+ chrome_build_proto);
checkin_request_.reset(
new CheckinRequest(gservices_settings_.GetCheckinURL(),
request_info,
diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h
index 5c4c84a..e2f1b02 100644
--- a/google_apis/gcm/gcm_client_impl.h
+++ b/google_apis/gcm/gcm_client_impl.h
@@ -81,7 +81,7 @@ class GCM_EXPORT GCMClientImpl
// Overridden from GCMClient:
virtual void Initialize(
- const checkin_proto::ChromeBuildProto& chrome_build_proto,
+ const ChromeBuildInfo& chrome_build_info,
const base::FilePath& store_path,
const std::vector<std::string>& account_ids,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
@@ -249,7 +249,7 @@ class GCM_EXPORT GCMClientImpl
// Information about the chrome build.
// TODO(fgorski): Check if it can be passed in constructor and made const.
- checkin_proto::ChromeBuildProto chrome_build_proto_;
+ ChromeBuildInfo chrome_build_info_;
// Persistent data store for keeping device credentials, messages and user to
// serial number mappings.
diff --git a/google_apis/gcm/gcm_client_impl_unittest.cc b/google_apis/gcm/gcm_client_impl_unittest.cc
index 6280370..8da4887 100644
--- a/google_apis/gcm/gcm_client_impl_unittest.cc
+++ b/google_apis/gcm/gcm_client_impl_unittest.cc
@@ -444,8 +444,8 @@ void GCMClientImplTest::InitializeGCMClient() {
clock()->Advance(base::TimeDelta::FromMilliseconds(1));
// Actual initialization.
- checkin_proto::ChromeBuildProto chrome_build_proto;
- gcm_client_->Initialize(chrome_build_proto,
+ GCMClient::ChromeBuildInfo chrome_build_info;
+ gcm_client_->Initialize(chrome_build_info,
temp_directory_.path(),
std::vector<std::string>(),
message_loop_.message_loop_proxy(),