Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc

Issue 1024553009: Add the ability to use DataReductionProxyParams from DataReductionProxyConfigServiceClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_control_local
Patch Set: Forgot implementation of DataReductionProxyMutableConfigValues::IsDataReductionProxy in downstream … Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 675b05ce0eac90242ac431572271f9fe1b62102b..1b95890bd2fd6450a7b975ac4fdc06720599045c 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
@@ -99,6 +99,7 @@ DataReductionProxyRequestOptions::DataReductionProxyRequestOptions(
DataReductionProxyConfig* config,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
: client_(GetString(client)),
+ use_assigned_credentials_(false),
data_reduction_proxy_config_(config),
network_task_runner_(network_task_runner) {
GetChromiumBuildAndPatch(ChromiumVersion(), &build_, &patch_);
@@ -110,6 +111,7 @@ DataReductionProxyRequestOptions::DataReductionProxyRequestOptions(
DataReductionProxyConfig* config,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
: client_(GetString(client)),
+ use_assigned_credentials_(false),
data_reduction_proxy_config_(config),
network_task_runner_(network_task_runner) {
GetChromiumBuildAndPatch(version, &build_, &patch_);
@@ -227,7 +229,7 @@ void DataReductionProxyRequestOptions::SetHeader(
net::HttpRequestHeaders* headers) {
base::Time now = Now();
// Authorization credentials must be regenerated if they are expired.
- if (now > credentials_expiration_time_)
+ if (!use_assigned_credentials_ && (now > credentials_expiration_time_))
UpdateCredentials();
UpdateLoFi();
const char kChromeProxyHeader[] = "Chrome-Proxy";
@@ -264,8 +266,6 @@ void DataReductionProxyRequestOptions::ComputeCredentials(
}
void DataReductionProxyRequestOptions::UpdateCredentials() {
- std::string session;
- std::string credentials;
base::Time now = Now();
ComputeCredentials(now, &session_, &credentials_);
credentials_expiration_time_ = now + base::TimeDelta::FromHours(24);
@@ -293,6 +293,18 @@ void DataReductionProxyRequestOptions::PopulateConfigResponse(
config_parser::TimeToISO8601(expiration_time));
}
+void DataReductionProxyRequestOptions::SetCredentials(
+ const std::string& session,
+ const std::string& credentials) {
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
+ session_ = session;
+ credentials_ = credentials;
+ // Force skipping of credential regeneration. It should be handled by the
+ // caller.
+ use_assigned_credentials_ = true;
+ RegenerateRequestHeaderValue();
+}
+
std::string DataReductionProxyRequestOptions::GetDefaultKey() const {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();

Powered by Google App Engine
This is Rietveld 408576698