Commit 224a36cc authored by bengr's avatar bengr Committed by Commit bot

Use chromium version for data reduction proxy version

Provide a method to get the chromium version for use as the
data reduction proxy version.

BUG=410127

Review URL: https://codereview.chromium.org/533003002

Cr-Commit-Position: refs/heads/master@{#295906}
parent 9f334b9e
......@@ -235,7 +235,6 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
data_reduction_proxy_auth_request_handler_.reset(
new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
data_reduction_proxy::kClientAndroidWebview,
data_reduction_proxy::kAndroidWebViewProtocolVersion,
data_reduction_proxy_settings->params(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
......
......@@ -650,7 +650,6 @@ void IOThread::InitAsync() {
globals_->data_reduction_proxy_auth_request_handler.reset(
new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
DataReductionProxyChromeSettings::GetClient(),
chrome::VersionInfo().Version(),
globals_->data_reduction_proxy_params.get(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
globals_->data_reduction_proxy_delegate.reset(
......
......@@ -31,7 +31,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_statistics_prefs.h"
......@@ -443,7 +442,6 @@ void ProfileImplIOData::InitializeInternal(
data_reduction_proxy_auth_request_handler_.reset(
new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
DataReductionProxyChromeSettings::GetClient(),
chrome::VersionInfo().Version(),
data_reduction_proxy_params_.get(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
data_reduction_proxy_usage_stats_.reset(
......
......@@ -10,6 +10,7 @@
'target_name': 'data_reduction_proxy_browser',
'type': 'static_library',
'dependencies': [
'data_reduction_proxy_version_header',
'../base/base.gyp:base',
'../crypto/crypto.gyp:crypto',
'../net/net.gyp:net',
......@@ -90,6 +91,39 @@
'data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h',
],
},
{
'target_name': 'data_reduction_proxy_version_header',
'type': 'none',
'direct_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
],
},
'actions': [
{
'action_name': 'version_header',
'message': 'Generating version header file: <@(_outputs)',
'inputs': [
'<(version_path)',
'data_reduction_proxy/common/version.h.in',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/components/data_reduction_proxy/common/version.h',
],
'action': [
'python',
'<(version_py_path)',
'-e', 'VERSION_FULL="<(version_full)"',
'data_reduction_proxy/common/version.h.in',
'<@(_outputs)',
],
'includes': [
'../build/util/version.gypi',
],
},
],
},
],
}
......@@ -16,6 +16,7 @@
#include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h"
#include "components/data_reduction_proxy/common/version.h"
#include "crypto/random.h"
#include "net/base/host_port_pair.h"
#include "net/proxy/proxy_server.h"
......@@ -42,22 +43,42 @@ bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() {
data_reduction_proxy::switches::kDataReductionProxyKey);
}
DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler(
const std::string& client,
DataReductionProxyParams* params,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
: client_(client),
data_reduction_proxy_params_(params),
network_task_runner_(network_task_runner) {
GetChromiumBuildAndPatch(ChromiumVersion(), &build_number_, &patch_number_);
Init();
}
DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler(
const std::string& client,
const std::string& version,
DataReductionProxyParams* params,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
: data_reduction_proxy_params_(params),
: client_(client),
data_reduction_proxy_params_(params),
network_task_runner_(network_task_runner) {
client_ = client;
GetChromiumBuildAndPatch(version, &build_number_, &patch_number_);
Init();
}
std::string DataReductionProxyAuthRequestHandler::ChromiumVersion() const {
#if defined(PRODUCT_VERSION)
return PRODUCT_VERSION;
#else
return std::string();
#endif
}
void DataReductionProxyAuthRequestHandler::GetChromiumBuildAndPatch(
const std::string& version,
std::string* build,
std::string* patch) {
std::string* patch) const {
std::vector<std::string> version_parts;
base::SplitString(version, '.', &version_parts);
if (version_parts.size() != 4)
......
......@@ -40,14 +40,9 @@ class DataReductionProxyAuthRequestHandler {
static bool IsKeySetOnCommandLine();
// Constructs a DataReductionProxyAuthRequestHandler object with the given
// client, version, params, and network task runner. The Chromium |version| is
// expected to be of the form "xx.xx.xx.xx". If it isn't of this form,
// |build_number_| and |patch_number_| are set to empty strings and not
// included in the header. http://crbug.com/410127 will change this so that
// the version is retrieved inside this constructor.
// client type, params, and network task runner.
DataReductionProxyAuthRequestHandler(
const std::string& client,
const std::string& version,
DataReductionProxyParams* params,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
......@@ -92,6 +87,13 @@ class DataReductionProxyAuthRequestHandler {
// Visible for testing.
virtual std::string GetDefaultKey() const;
// Visible for testing.
DataReductionProxyAuthRequestHandler(
const std::string& client,
const std::string& version,
DataReductionProxyParams* params,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
private:
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
Authorization);
......@@ -100,11 +102,14 @@ class DataReductionProxyAuthRequestHandler {
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
AuthHashForSalt);
// Returns the version of Chromium that is being used.
std::string ChromiumVersion() const;
// Returns the build and patch numbers of |version|. If |version| isn't of the
// form xx.xx.xx.xx build and patch are not modified.
void GetChromiumBuildAndPatch(const std::string& version,
std::string* build,
std::string* patch);
std::string* patch) const;
// Stores the supplied key and sets up credentials suitable for authenticating
// with the data reduction proxy.
......
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//components/data_reduction_proxy/common/version.gni")
static_library("common") {
sources = [
"data_reduction_proxy_headers.cc",
......@@ -13,6 +15,7 @@ static_library("common") {
]
deps = [
":version_header",
"//base",
]
}
......@@ -28,3 +31,9 @@ source_set("unit_tests") {
"//testing/gtest",
]
}
process_version("version_header") {
source = "version.h.in"
output = "$target_gen_dir/version.h"
}
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Runs the version processing script over the given template file to produce
# an output file. This is used for generating various forms of files that
# incorporate the product name and version.
#
# This template automatically includes VERSION,
#
# Parameters:
# source:
# File name of source template file to read.
#
# output:
# File name of file to write.
#
# visibility (optional)
#
# Example:
# process_version("myversion") {
# source = "myfile.h.in"
# output = "$target_gen_dir/myfile.h"
# }
template("process_version") {
assert(defined(invoker.source), "Source must be defined for $target_name")
assert(defined(invoker.output), "Output must be defined for $target_name")
action(target_name) {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
script = "//build/util/version.py"
version_path = "//chrome/VERSION"
inputs = [
version_path,
invoker.source,
]
outputs = [ invoker.output ]
args = [
"-f", rebase_path(version_path, root_build_dir),
rebase_path(invoker.source, root_build_dir),
rebase_path(invoker.output, root_build_dir),
]
}
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// version.h is generated from version.h.in. Edit the source!
#ifndef DATA_REDUCTION_PROXY_COMMON_VERSION_INFO_H_
#define DATA_REDUCTION_PROXY_COMMON_VERSION_INFO_H_
#define PRODUCT_VERSION "@VERSION_FULL@"
#endif // DATA_REDUCTION_PROXY_COMMON_VERSION_INFO_H_
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