Commit 19f51e45 authored by ryansturm's avatar ryansturm Committed by Commit bot

Adding version info to the client config request

This information will easily allow the server to use different
experiments in different channels and different versions.

BUG=622374

Review-Url: https://codereview.chromium.org/2103223002
Cr-Commit-Position: refs/heads/master@{#403207}
parent 9e3f106c
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_content_client.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/data_reduction_proxy/content/browser/content_lofi_decider.h" #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h"
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -78,7 +80,8 @@ CreateDataReductionProxyChromeIOData( ...@@ -78,7 +80,8 @@ CreateDataReductionProxyChromeIOData(
data_reduction_proxy_io_data( data_reduction_proxy_io_data(
new data_reduction_proxy::DataReductionProxyIOData( new data_reduction_proxy::DataReductionProxyIOData(
DataReductionProxyChromeSettings::GetClient(), flags, net_log, DataReductionProxyChromeSettings::GetClient(), flags, net_log,
io_task_runner, ui_task_runner, enabled, GetUserAgent())); io_task_runner, ui_task_runner, enabled, GetUserAgent(),
version_info::GetChannelString(chrome::GetChannel())));
data_reduction_proxy_io_data->set_lofi_decider( data_reduction_proxy_io_data->set_lofi_decider(
base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider())); base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider()));
......
...@@ -92,7 +92,7 @@ CronetDataReductionProxy::CronetDataReductionProxy( ...@@ -92,7 +92,7 @@ CronetDataReductionProxy::CronetDataReductionProxy(
data_reduction_proxy::Client::CRONET_ANDROID, data_reduction_proxy::Client::CRONET_ANDROID,
data_reduction_proxy::DataReductionProxyParams::kAllowed | data_reduction_proxy::DataReductionProxyParams::kAllowed |
data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed, data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed,
net_log, task_runner, task_runner, false, user_agent)); net_log, task_runner, task_runner, false, user_agent, std::string()));
io_data_->request_options()->SetKeyOnIO(key); io_data_->request_options()->SetKeyOnIO(key);
} }
......
...@@ -370,6 +370,15 @@ void DataReductionProxyConfigServiceClient::RetrieveRemoteConfig() { ...@@ -370,6 +370,15 @@ void DataReductionProxyConfigServiceClient::RetrieveRemoteConfig() {
const std::string& session_key = request_options_->GetSecureSession(); const std::string& session_key = request_options_->GetSecureSession();
if (!session_key.empty()) if (!session_key.empty())
request.set_session_key(request_options_->GetSecureSession()); request.set_session_key(request_options_->GetSecureSession());
data_reduction_proxy::VersionInfo* version_info =
request.mutable_version_info();
uint32_t build;
uint32_t patch;
util::GetChromiumBuildAndPatchAsInts(util::ChromiumVersion(), &build, &patch);
version_info->set_client(util::GetStringForClient(io_data_->client()));
version_info->set_build(build);
version_info->set_patch(patch);
version_info->set_channel(io_data_->channel());
request.SerializeToString(&serialized_request); request.SerializeToString(&serialized_request);
std::unique_ptr<net::URLFetcher> fetcher = std::unique_ptr<net::URLFetcher> fetcher =
GetURLFetcherForConfig(config_service_url_, serialized_request); GetURLFetcherForConfig(config_service_url_, serialized_request);
......
...@@ -96,7 +96,8 @@ DataReductionProxyIOData::DataReductionProxyIOData( ...@@ -96,7 +96,8 @@ DataReductionProxyIOData::DataReductionProxyIOData(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
bool enabled, bool enabled,
const std::string& user_agent) const std::string& user_agent,
const std::string& channel)
: client_(client), : client_(client),
net_log_(net_log), net_log_(net_log),
io_task_runner_(io_task_runner), io_task_runner_(io_task_runner),
...@@ -105,6 +106,7 @@ DataReductionProxyIOData::DataReductionProxyIOData( ...@@ -105,6 +106,7 @@ DataReductionProxyIOData::DataReductionProxyIOData(
url_request_context_getter_(nullptr), url_request_context_getter_(nullptr),
basic_url_request_context_getter_( basic_url_request_context_getter_(
new BasicHTTPURLRequestContextGetter(user_agent, io_task_runner)), new BasicHTTPURLRequestContextGetter(user_agent, io_task_runner)),
channel_(channel),
weak_factory_(this) { weak_factory_(this) {
DCHECK(net_log); DCHECK(net_log);
DCHECK(io_task_runner_); DCHECK(io_task_runner_);
......
...@@ -58,7 +58,8 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate { ...@@ -58,7 +58,8 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate {
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
bool enabled, bool enabled,
const std::string& user_agent); const std::string& user_agent,
const std::string& channel);
virtual ~DataReductionProxyIOData(); virtual ~DataReductionProxyIOData();
...@@ -178,6 +179,12 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate { ...@@ -178,6 +179,12 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate {
lofi_ui_service_ = std::move(lofi_ui_service); lofi_ui_service_ = std::move(lofi_ui_service);
} }
// The production channel of this build.
std::string channel() const { return channel_; }
// The Client type of this build.
Client client() const { return client_; }
private: private:
friend class TestDataReductionProxyIOData; friend class TestDataReductionProxyIOData;
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyIODataTest, TestConstruction); FRIEND_TEST_ALL_PREFIXES(DataReductionProxyIODataTest, TestConstruction);
...@@ -206,7 +213,7 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate { ...@@ -206,7 +213,7 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate {
void StoreSerializedConfig(const std::string& serialized_config); void StoreSerializedConfig(const std::string& serialized_config);
// The type of Data Reduction Proxy client. // The type of Data Reduction Proxy client.
Client client_; const Client client_;
// Parameters including DNS names and allowable configurations. // Parameters including DNS names and allowable configurations.
std::unique_ptr<DataReductionProxyConfig> config_; std::unique_ptr<DataReductionProxyConfig> config_;
...@@ -257,6 +264,9 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate { ...@@ -257,6 +264,9 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate {
// does not use alternate protocols. // does not use alternate protocols.
scoped_refptr<net::URLRequestContextGetter> basic_url_request_context_getter_; scoped_refptr<net::URLRequestContextGetter> basic_url_request_context_getter_;
// The production channel of this build.
const std::string channel_;
base::WeakPtrFactory<DataReductionProxyIOData> weak_factory_; base::WeakPtrFactory<DataReductionProxyIOData> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyIOData); DISALLOW_COPY_AND_ASSIGN(DataReductionProxyIOData);
......
...@@ -102,7 +102,7 @@ TEST_F(DataReductionProxyIODataTest, TestConstruction) { ...@@ -102,7 +102,7 @@ TEST_F(DataReductionProxyIODataTest, TestConstruction) {
new DataReductionProxyIOData( new DataReductionProxyIOData(
Client::UNKNOWN, DataReductionProxyParams::kAllowed, net_log(), Client::UNKNOWN, DataReductionProxyParams::kAllowed, net_log(),
task_runner(), task_runner(), false /* enabled */, task_runner(), task_runner(), false /* enabled */,
std::string() /* user_agent */)); std::string() /* user_agent */, std::string() /* channel */));
// Check that the SimpleURLRequestContextGetter uses vanilla HTTP. // Check that the SimpleURLRequestContextGetter uses vanilla HTTP.
net::URLRequestContext* request_context = net::URLRequestContext* request_context =
......
...@@ -47,12 +47,21 @@ const char* ChromiumVersion() { ...@@ -47,12 +47,21 @@ const char* ChromiumVersion() {
void GetChromiumBuildAndPatch(const std::string& version_string, void GetChromiumBuildAndPatch(const std::string& version_string,
std::string* build, std::string* build,
std::string* patch) { std::string* patch) {
uint32_t build_number;
uint32_t patch_number;
GetChromiumBuildAndPatchAsInts(version_string, &build_number, &patch_number);
*build = base::Uint64ToString(build_number);
*patch = base::Uint64ToString(patch_number);
}
void GetChromiumBuildAndPatchAsInts(const std::string& version_string,
uint32_t* build,
uint32_t* patch) {
base::Version version(version_string); base::Version version(version_string);
DCHECK(version.IsValid()); DCHECK(version.IsValid());
DCHECK_EQ(4U, version.components().size()); DCHECK_EQ(4U, version.components().size());
*build = version.components()[2];
*build = base::Uint64ToString(version.components()[2]); *patch = version.components()[3];
*patch = base::Uint64ToString(version.components()[3]);
} }
const char* GetStringForClient(Client client) { const char* GetStringForClient(Client client) {
......
...@@ -46,12 +46,20 @@ namespace util { ...@@ -46,12 +46,20 @@ namespace util {
// Returns the version of Chromium that is being used, e.g. "1.2.3.4". // Returns the version of Chromium that is being used, e.g. "1.2.3.4".
const char* ChromiumVersion(); const char* ChromiumVersion();
// Returns the build and patch numbers of |version_string|. |version_string| // Returns the build and patch numbers of |version_string| as std::string.
// must be a properly formed Chromium version number, e.g. "1.2.3.4". // |version_string| must be a properly formed Chromium version number, e.g.
// "1.2.3.4".
void GetChromiumBuildAndPatch(const std::string& version_string, void GetChromiumBuildAndPatch(const std::string& version_string,
std::string* build, std::string* build,
std::string* patch); std::string* patch);
// Returns the build and patch numbers of |version_string| as unit32_t.
// |version_string| must be a properly formed Chromium version number, e.g.
// "1.2.3.4".
void GetChromiumBuildAndPatchAsInts(const std::string& version_string,
uint32_t* build,
uint32_t* patch);
// Get the human-readable version of |client|. // Get the human-readable version of |client|.
const char* GetStringForClient(Client client); const char* GetStringForClient(Client client);
......
...@@ -109,4 +109,24 @@ message ProxyServer { ...@@ -109,4 +109,24 @@ message ProxyServer {
message CreateClientConfigRequest { message CreateClientConfigRequest {
// A previous per-session key that was assigned by the service. // A previous per-session key that was assigned by the service.
optional string session_key = 1; optional string session_key = 1;
// Build version information.
optional VersionInfo version_info = 2;
} }
// Build version information.
message VersionInfo {
// The client's platform type. See
// components/data_reduction_proxy/core/common/data_reduction_proxy_util.h for
// allowed strings in CLIENT_ENUMS_LIST.
optional string client = 1;
// The build number, e.g. 2171
optional int32 build = 2;
// The patch number of the chromium client: always a non-negative integer.
optional int32 patch = 3;
// The production channel, e.g. "canary", "dev", "beta", "stable".
optional string channel = 4;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment