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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc

Issue 1933653004: Reset the Lo-Fi main frame state when there is a new main frame request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check data_reduction_proxy_io_data_ Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 base::Time DataReductionProxyRequestOptions::Now() const { 171 base::Time DataReductionProxyRequestOptions::Now() const {
172 return base::Time::Now(); 172 return base::Time::Now();
173 } 173 }
174 174
175 void DataReductionProxyRequestOptions::RandBytes(void* output, 175 void DataReductionProxyRequestOptions::RandBytes(void* output,
176 size_t length) const { 176 size_t length) const {
177 crypto::RandBytes(output, length); 177 crypto::RandBytes(output, length);
178 } 178 }
179 179
180 void DataReductionProxyRequestOptions::MaybeAddRequestHeader( 180 void DataReductionProxyRequestOptions::AddRequestHeader(
181 const net::ProxyServer& proxy_server,
182 net::HttpRequestHeaders* request_headers) { 181 net::HttpRequestHeaders* request_headers) {
183 DCHECK(thread_checker_.CalledOnValidThread());
184 if (!proxy_server.is_valid())
185 return;
186 if (proxy_server.is_direct())
187 return;
188 if (proxy_server.host_port_pair().IsEmpty())
189 return;
190 if (data_reduction_proxy_config_->IsDataReductionProxy(
191 proxy_server.host_port_pair(), NULL)) {
192 SetHeader(request_headers);
193 }
194 }
195
196 void DataReductionProxyRequestOptions::SetHeader(
197 net::HttpRequestHeaders* headers) {
198 base::Time now = Now(); 182 base::Time now = Now();
199 // Authorization credentials must be regenerated if they are expired. 183 // Authorization credentials must be regenerated if they are expired.
200 if (!use_assigned_credentials_ && (now > credentials_expiration_time_)) 184 if (!use_assigned_credentials_ && (now > credentials_expiration_time_))
201 UpdateCredentials(); 185 UpdateCredentials();
202 const char kChromeProxyHeader[] = "Chrome-Proxy"; 186 const char kChromeProxyHeader[] = "Chrome-Proxy";
203 std::string header_value; 187 std::string header_value;
204 if (headers->HasHeader(kChromeProxyHeader)) { 188 if (request_headers->HasHeader(kChromeProxyHeader)) {
205 headers->GetHeader(kChromeProxyHeader, &header_value); 189 request_headers->GetHeader(kChromeProxyHeader, &header_value);
206 headers->RemoveHeader(kChromeProxyHeader); 190 request_headers->RemoveHeader(kChromeProxyHeader);
207 header_value += ", "; 191 header_value += ", ";
208 } 192 }
209 header_value += header_value_; 193 header_value += header_value_;
210 headers->SetHeader(kChromeProxyHeader, header_value); 194 request_headers->SetHeader(kChromeProxyHeader, header_value);
211 } 195 }
212 196
213 void DataReductionProxyRequestOptions::ComputeCredentials( 197 void DataReductionProxyRequestOptions::ComputeCredentials(
214 const base::Time& now, 198 const base::Time& now,
215 std::string* session, 199 std::string* session,
216 std::string* credentials) const { 200 std::string* credentials) const {
217 DCHECK(session); 201 DCHECK(session);
218 DCHECK(credentials); 202 DCHECK(credentials);
219 int64_t timestamp = (now - base::Time::UnixEpoch()).InMilliseconds() / 1000; 203 int64_t timestamp = (now - base::Time::UnixEpoch()).InMilliseconds() / 1000;
220 204
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (base::TrimWhitespaceASCII(kv_pair.first, base::TRIM_ALL) == 317 if (base::TrimWhitespaceASCII(kv_pair.first, base::TRIM_ALL) ==
334 kSecureSessionHeaderOption) { 318 kSecureSessionHeaderOption) {
335 return base::TrimWhitespaceASCII(kv_pair.second, base::TRIM_ALL) 319 return base::TrimWhitespaceASCII(kv_pair.second, base::TRIM_ALL)
336 .as_string(); 320 .as_string();
337 } 321 }
338 } 322 }
339 return ""; 323 return "";
340 } 324 }
341 325
342 } // namespace data_reduction_proxy 326 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698