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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_params.cc

Issue 390533003: Bypassed Bytes UMAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments Created 6 years, 5 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/browser/data_reduction_proxy_params.h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
bengr 2014/07/21 22:23:56 #include "base/time/time.h"
megjablon 2014/07/22 02:11:30 Done.
9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h "
10 #include "net/proxy/proxy_info.h" 10 #include "net/proxy/proxy_info.h"
11 #include "net/proxy/proxy_retry_info.h"
11 #include "net/proxy/proxy_service.h" 12 #include "net/proxy/proxy_service.h"
12 #include "net/url_request/url_request.h" 13 #include "net/url_request/url_request.h"
13 #include "net/url_request/url_request_context.h" 14 #include "net/url_request/url_request_context.h"
14 15
15 using base::FieldTrialList; 16 using base::FieldTrialList;
16 17
17 namespace { 18 namespace {
18 const char kEnabled[] = "Enabled"; 19 const char kEnabled[] = "Enabled";
19 } 20 }
20 21
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 if (promo_allowed_ && !allowed_) { 156 if (promo_allowed_ && !allowed_) {
156 DVLOG(1) << "The data reduction proxy promo cannot be allowed if the " 157 DVLOG(1) << "The data reduction proxy promo cannot be allowed if the "
157 << "data reduction proxy is not allowed"; 158 << "data reduction proxy is not allowed";
158 return false; 159 return false;
159 } 160 }
160 return true; 161 return true;
161 162
162 } 163 }
163 164
164
165 void DataReductionProxyParams::InitWithoutChecks() { 165 void DataReductionProxyParams::InitWithoutChecks() {
166 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 166 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
167 std::string origin; 167 std::string origin;
168 if (!command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) { 168 if (!command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) {
169 origin = command_line.GetSwitchValueASCII( 169 origin = command_line.GetSwitchValueASCII(
170 switches::kDataReductionProxyDev); 170 switches::kDataReductionProxyDev);
171 } 171 }
172 if (origin.empty()) 172 if (origin.empty())
173 origin = command_line.GetSwitchValueASCII(switches::kDataReductionProxy); 173 origin = command_line.GetSwitchValueASCII(switches::kDataReductionProxy);
174 std::string fallback_origin = 174 std::string fallback_origin =
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return std::string(); 322 return std::string();
323 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || 323 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) ||
324 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == 324 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") ==
325 kEnabled)) { 325 kEnabled)) {
326 return DATA_REDUCTION_DEV_HOST; 326 return DATA_REDUCTION_DEV_HOST;
327 } 327 }
328 #endif 328 #endif
329 return std::string(); 329 return std::string();
330 } 330 }
331 331
332 bool DataReductionProxyParams::AreDataReductionProxiesBypassed(
333 const net::URLRequest& request, base::TimeDelta* delay_seconds) const {
334 DCHECK(request.context());
335 if (request.context() == NULL ||
336 request.context()->proxy_service() == NULL) {
337 return AreProxiesBypassed(
338 request.context()->proxy_service()->proxy_retry_info(),
339 request.url().SchemeIs(url::kHttpsScheme),
340 delay_seconds);
341 }
342
343 return false;
344 }
345
346 bool DataReductionProxyParams::AreProxiesBypassed(
347 const net::ProxyRetryInfoMap& retry_map,
348 bool is_https,
349 base::TimeDelta* delay_seconds) const {
350 if (retry_map.size() == 0)
351 return false;
352
353 if (is_https && alt_allowed_) {
354 if (ArePrimaryAndFallbackBypassed(
355 retry_map, ssl_origin_, GURL(), delay_seconds)) {
356 return true;
357 }
358 } else {
359 if (allowed_) {
360 if (ArePrimaryAndFallbackBypassed(retry_map,
bengr 2014/07/21 22:23:57 Here and below you can probably fit all parameters
megjablon 2014/07/22 02:11:29 Done.
361 origin_,
362 fallback_origin_,
363 delay_seconds)) {
364 return true;
365 }
366 }
367
368 if (alt_allowed_) {
369 if (ArePrimaryAndFallbackBypassed(retry_map,
370 alt_origin_,
371 alt_fallback_origin_,
372 delay_seconds)) {
373 return true;
374 }
375 }
376 }
377
378 return false;
379 }
380
381 bool DataReductionProxyParams::ArePrimaryAndFallbackBypassed(
382 const net::ProxyRetryInfoMap& retry_map,
383 const GURL& primary,
384 const GURL& fallback,
385 base::TimeDelta* delay_seconds) const {
bengr 2014/07/21 22:23:57 This is no longer in seconds and it otherwise vagu
megjablon 2014/07/22 02:11:29 Done.
386 base::TimeDelta shortest_delay;
387 net::ProxyRetryInfoMap::const_iterator found;
388
389 found = retry_map.find(
390 net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ?
391 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP,
bengr 2014/07/21 22:23:56 #include "net/proxy/proxy_server.h"
megjablon 2014/07/22 02:11:29 Done.
392 net::HostPortPair::FromURL(primary)).ToURI());
393 if (!(found == retry_map.end())) {
394 shortest_delay = found->second.current_delay;
bengr 2014/07/21 22:23:57 There are only two possible delays, so this should
megjablon 2014/07/22 02:11:30 Done.
395 if (fallback_allowed_ && fallback.is_valid()) {
396 found = retry_map.find(
397 net::ProxyServer(fallback.SchemeIs(url::kHttpsScheme) ?
bengr 2014/07/21 22:23:57 #include "url/url_constants.h"
megjablon 2014/07/22 02:11:29 Done.
398 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP,
399 net::HostPortPair::FromURL(fallback)).ToURI());
bengr 2014/07/21 22:23:56 #include "net/base/host_port_pair.h"
megjablon 2014/07/22 02:11:30 Done.
400 if (!(found == retry_map.end())) {
401 if(shortest_delay > found->second.current_delay)
402 shortest_delay = found->second.current_delay;
403 if (delay_seconds != NULL)
404 *delay_seconds = shortest_delay;
405 return true;
406 }
407 } else {
408 if (delay_seconds != NULL)
409 *delay_seconds = shortest_delay;
410 return true;
411 }
412 }
413
414 return false;
415 }
416
332 std::string DataReductionProxyParams::GetDefaultOrigin() const { 417 std::string DataReductionProxyParams::GetDefaultOrigin() const {
333 #if defined(SPDY_PROXY_AUTH_ORIGIN) 418 #if defined(SPDY_PROXY_AUTH_ORIGIN)
334 return SPDY_PROXY_AUTH_ORIGIN; 419 return SPDY_PROXY_AUTH_ORIGIN;
335 #endif 420 #endif
336 return std::string(); 421 return std::string();
337 } 422 }
338 423
339 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { 424 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const {
340 #if defined(DATA_REDUCTION_FALLBACK_HOST) 425 #if defined(DATA_REDUCTION_FALLBACK_HOST)
341 return DATA_REDUCTION_FALLBACK_HOST; 426 return DATA_REDUCTION_FALLBACK_HOST;
(...skipping 30 matching lines...) Expand all
372 } 457 }
373 458
374 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { 459 std::string DataReductionProxyParams::GetDefaultWarmupURL() const {
375 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) 460 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL)
376 return DATA_REDUCTION_PROXY_WARMUP_URL; 461 return DATA_REDUCTION_PROXY_WARMUP_URL;
377 #endif 462 #endif
378 return std::string(); 463 return std::string();
379 } 464 }
380 465
381 } // namespace data_reduction_proxy 466 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698