Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc |
index 91397846bb53c36587cf591ed52b7926be1d1342..7f0382e235b503e74ba94d764af4f086d069b65b 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc |
@@ -1,92 +1,49 @@ |
// 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. |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" |
#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/single_thread_task_runner.h" |
-#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_piece.h" |
#include "base/strings/string_split.h" |
#include "base/strings/string_tokenizer.h" |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/time/time.h" |
-#include "base/version.h" |
#include "build/build_config.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" |
-#include "components/data_reduction_proxy/core/common/version.h" |
#include "components/variations/variations_associated_data.h" |
#include "crypto/random.h" |
#include "net/base/host_port_pair.h" |
#include "net/base/load_flags.h" |
#include "net/proxy/proxy_server.h" |
#include "net/url_request/url_request.h" |
#if defined(USE_GOOGLE_API_KEYS_FOR_AUTH_KEY) |
#include "google_apis/google_api_keys.h" |
#endif |
namespace data_reduction_proxy { |
namespace { |
std::string FormatOption(const std::string& name, const std::string& value) { |
return name + "=" + value; |
} |
-// Returns the version of Chromium that is being used, e.g. "1.2.3.4". |
-const char* ChromiumVersion() { |
- // Assert at compile time that the Chromium version is at least somewhat |
- // properly formed, e.g. the version string is at least as long as "0.0.0.0", |
- // and starts and ends with numeric digits. This is to prevent another |
- // regression like http://crbug.com/595471. |
- static_assert(arraysize(PRODUCT_VERSION) >= arraysize("0.0.0.0") && |
- '0' <= PRODUCT_VERSION[0] && PRODUCT_VERSION[0] <= '9' && |
- '0' <= PRODUCT_VERSION[arraysize(PRODUCT_VERSION) - 2] && |
- PRODUCT_VERSION[arraysize(PRODUCT_VERSION) - 2] <= '9', |
- "PRODUCT_VERSION must be a string of the form " |
- "'MAJOR.MINOR.BUILD.PATCH', e.g. '1.2.3.4'. " |
- "PRODUCT_VERSION='" PRODUCT_VERSION "' is badly formed."); |
- |
- return PRODUCT_VERSION; |
-} |
- |
-// Returns the build and patch numbers of |version_string|. |version_string| |
-// must be a properly formed Chromium version number, e.g. "1.2.3.4". |
-void GetChromiumBuildAndPatch(const std::string& version_string, |
- std::string* build, |
- std::string* patch) { |
- base::Version version(version_string); |
- DCHECK(version.IsValid()); |
- DCHECK_EQ(4U, version.components().size()); |
- |
- *build = base::Uint64ToString(version.components()[2]); |
- *patch = base::Uint64ToString(version.components()[3]); |
-} |
- |
-#define CLIENT_ENUM(name, str_value) \ |
- case name: \ |
- return str_value; |
-const char* GetString(Client client) { |
- switch (client) { CLIENT_ENUMS_LIST } |
- NOTREACHED(); |
- return ""; |
-} |
-#undef CLIENT_ENUM |
- |
} // namespace |
const char kSessionHeaderOption[] = "ps"; |
const char kCredentialsHeaderOption[] = "sid"; |
const char kSecureSessionHeaderOption[] = "s"; |
const char kBuildNumberHeaderOption[] = "b"; |
const char kPatchNumberHeaderOption[] = "p"; |
const char kClientHeaderOption[] = "c"; |
const char kExperimentsOption[] = "exp"; |
@@ -100,31 +57,33 @@ const char kAndroidWebViewProtocolVersion[] = ""; |
bool DataReductionProxyRequestOptions::IsKeySetOnCommandLine() { |
const base::CommandLine& command_line = |
*base::CommandLine::ForCurrentProcess(); |
return command_line.HasSwitch( |
data_reduction_proxy::switches::kDataReductionProxyKey); |
} |
DataReductionProxyRequestOptions::DataReductionProxyRequestOptions( |
Client client, |
DataReductionProxyConfig* config) |
- : DataReductionProxyRequestOptions(client, ChromiumVersion(), config) {} |
+ : DataReductionProxyRequestOptions(client, |
+ util::ChromiumVersion(), |
+ config) {} |
DataReductionProxyRequestOptions::DataReductionProxyRequestOptions( |
Client client, |
const std::string& version, |
DataReductionProxyConfig* config) |
- : client_(GetString(client)), |
+ : client_(util::GetStringForClient(client)), |
use_assigned_credentials_(false), |
data_reduction_proxy_config_(config) { |
DCHECK(data_reduction_proxy_config_); |
- GetChromiumBuildAndPatch(version, &build_, &patch_); |
+ util::GetChromiumBuildAndPatch(version, &build_, &patch_); |
// Constructed on the UI thread, but should be checked on the IO thread. |
thread_checker_.DetachFromThread(); |
} |
DataReductionProxyRequestOptions::~DataReductionProxyRequestOptions() { |
} |
void DataReductionProxyRequestOptions::Init() { |
key_ = GetDefaultKey(), |
UpdateCredentials(); |