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

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

Issue 382313003: Add data reduction functionality to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head Created 6 years, 3 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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " 13 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h "
14 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
15 #include "net/proxy/proxy_info.h" 15 #include "net/proxy/proxy_info.h"
16 #include "net/proxy/proxy_retry_info.h" 16 #include "net/proxy/proxy_retry_info.h"
17 #include "net/proxy/proxy_server.h" 17 #include "net/proxy/proxy_server.h"
18 #include "net/proxy/proxy_service.h" 18 #include "net/proxy/proxy_service.h"
19 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
20 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
21 #include "url/url_constants.h" 21 #include "url/url_constants.h"
22 22
23 using base::FieldTrialList; 23 using base::FieldTrialList;
24 24
25 namespace { 25 namespace {
26
26 const char kEnabled[] = "Enabled"; 27 const char kEnabled[] = "Enabled";
27 } 28 const char kDefaultOrigin[] = "https://proxy.googlezip.net:443/";
29 const char kDevHost[] = "http://proxy-dev.googlezip.net:80/";
30 const char kDefaultFallbackOrigin[] = "http://compress.googlezip.net:80/";
31 const char kDefaultSslOrigin[] = "http://ssl.googlezip.net:1043/";
32 const char kDefaultAltOrigin[] = "https://proxy.googlezip.net:443/";
33 const char kDefaultAltFallbackOrigin[] = "http://compress.googlezip.net:80/";
34 const char kDefaultProbeUrl[] = "http://check.googlezip.net/connect";
35 const char kDefaultWarmupUrl[] = "http://www.gstatic.com/generate_204";
36
37 } // namespace anonymous
28 38
29 namespace data_reduction_proxy { 39 namespace data_reduction_proxy {
30 40
31 // static 41 // static
32 bool DataReductionProxyParams::IsIncludedInFieldTrial() {
33 return base::FieldTrialList::FindFullName(
34 "DataCompressionProxyRollout") == kEnabled;
35 }
36
37 // static
38 bool DataReductionProxyParams::IsIncludedInAlternativeFieldTrial() { 42 bool DataReductionProxyParams::IsIncludedInAlternativeFieldTrial() {
39 return base::FieldTrialList::FindFullName( 43 return base::FieldTrialList::FindFullName(
40 "DataCompressionProxyAlternativeConfiguration") == kEnabled; 44 "DataCompressionProxyAlternativeConfiguration") == kEnabled;
41 } 45 }
42 46
43 // static 47 // static
44 bool DataReductionProxyParams::IsIncludedInPromoFieldTrial() { 48 bool DataReductionProxyParams::IsIncludedInPromoFieldTrial() {
45 return FieldTrialList::FindFullName( 49 return FieldTrialList::FindFullName(
46 "DataCompressionProxyPromoVisibility") == kEnabled; 50 "DataCompressionProxyPromoVisibility") == kEnabled;
47 } 51 }
48 52
49 // static 53 // static
50 bool DataReductionProxyParams::IsIncludedInPreconnectHintingFieldTrial() { 54 bool DataReductionProxyParams::IsIncludedInPreconnectHintingFieldTrial() {
51 return IsIncludedInFieldTrial() && 55 return FieldTrialList::FindFullName(
52 FieldTrialList::FindFullName(
53 "DataCompressionProxyPreconnectHints") == kEnabled; 56 "DataCompressionProxyPreconnectHints") == kEnabled;
54 } 57 }
55 58
56 // static 59 // static
57 bool DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() { 60 bool DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() {
58 return IsIncludedInFieldTrial() && 61 return FieldTrialList::FindFullName(
59 FieldTrialList::FindFullName(
60 "DataCompressionProxyCriticalBypass") == kEnabled; 62 "DataCompressionProxyCriticalBypass") == kEnabled;
61 } 63 }
62 64
63 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo() 65 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo()
64 : proxy_servers(), 66 : proxy_servers(),
65 is_fallback(false), 67 is_fallback(false),
66 is_alternative(false), 68 is_alternative(false),
67 is_ssl(false) { 69 is_ssl(false) {
68 } 70 }
69 71
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 request->context()->proxy_service()->config().proxy_rules().Apply( 362 request->context()->proxy_service()->config().proxy_rules().Apply(
361 request->url(), &result); 363 request->url(), &result);
362 if (!result.proxy_server().is_valid()) 364 if (!result.proxy_server().is_valid())
363 return false; 365 return false;
364 if (result.proxy_server().is_direct()) 366 if (result.proxy_server().is_direct())
365 return false; 367 return false;
366 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); 368 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL);
367 } 369 }
368 370
369 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { 371 std::string DataReductionProxyParams::GetDefaultDevOrigin() const {
370 #if defined(DATA_REDUCTION_DEV_HOST)
371 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 372 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
372 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) 373 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev))
373 return std::string(); 374 return std::string();
374 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || 375 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) ||
375 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == 376 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") ==
376 kEnabled)) { 377 kEnabled)) {
377 return DATA_REDUCTION_DEV_HOST; 378 return kDevHost;
378 } 379 }
379 #endif
380 return std::string(); 380 return std::string();
381 } 381 }
382 382
383 bool DataReductionProxyParams::AreDataReductionProxiesBypassed( 383 bool DataReductionProxyParams::AreDataReductionProxiesBypassed(
384 const net::URLRequest& request, base::TimeDelta* min_retry_delay) const { 384 const net::URLRequest& request, base::TimeDelta* min_retry_delay) const {
385 if (request.context() != NULL && 385 if (request.context() != NULL &&
386 request.context()->proxy_service() != NULL) { 386 request.context()->proxy_service() != NULL) {
387 return AreProxiesBypassed( 387 return AreProxiesBypassed(
388 request.context()->proxy_service()->proxy_retry_info(), 388 request.context()->proxy_service()->proxy_retry_info(),
389 request.url().SchemeIs(url::kHttpsScheme), 389 request.url().SchemeIs(url::kHttpsScheme),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 if (found != retry_map.end() && 458 if (found != retry_map.end() &&
459 min_retry_delay && 459 min_retry_delay &&
460 *min_retry_delay > found->second.current_delay) { 460 *min_retry_delay > found->second.current_delay) {
461 *min_retry_delay = found->second.current_delay; 461 *min_retry_delay = found->second.current_delay;
462 } 462 }
463 } 463 }
464 464
465 return found != retry_map.end(); 465 return found != retry_map.end();
466 } 466 }
467 467
468 // TODO(kundaji): Remove tests for macro definitions.
468 std::string DataReductionProxyParams::GetDefaultOrigin() const { 469 std::string DataReductionProxyParams::GetDefaultOrigin() const {
469 #if defined(SPDY_PROXY_AUTH_ORIGIN) 470 return kDefaultOrigin;
470 return SPDY_PROXY_AUTH_ORIGIN;
471 #endif
472 return std::string();
473 } 471 }
474 472
475 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { 473 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const {
476 #if defined(DATA_REDUCTION_FALLBACK_HOST) 474 return kDefaultFallbackOrigin;
477 return DATA_REDUCTION_FALLBACK_HOST;
478 #endif
479 return std::string();
480 } 475 }
481 476
482 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { 477 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const {
483 #if defined(DATA_REDUCTION_PROXY_SSL_ORIGIN) 478 return kDefaultSslOrigin;
484 return DATA_REDUCTION_PROXY_SSL_ORIGIN;
485 #endif
486 return std::string();
487 } 479 }
488 480
489 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { 481 std::string DataReductionProxyParams::GetDefaultAltOrigin() const {
490 #if defined(DATA_REDUCTION_PROXY_ALT_ORIGIN) 482 return kDefaultAltOrigin;
491 return DATA_REDUCTION_PROXY_ALT_ORIGIN;
492 #endif
493 return std::string();
494 } 483 }
495 484
496 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { 485 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const {
497 #if defined(DATA_REDUCTION_PROXY_ALT_FALLBACK_ORIGIN) 486 return kDefaultAltFallbackOrigin;
498 return DATA_REDUCTION_PROXY_ALT_FALLBACK_ORIGIN;
499 #endif
500 return std::string();
501 } 487 }
502 488
503 std::string DataReductionProxyParams::GetDefaultProbeURL() const { 489 std::string DataReductionProxyParams::GetDefaultProbeURL() const {
504 #if defined(DATA_REDUCTION_PROXY_PROBE_URL) 490 return kDefaultProbeUrl;
505 return DATA_REDUCTION_PROXY_PROBE_URL;
506 #endif
507 return std::string();
508 } 491 }
509 492
510 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { 493 std::string DataReductionProxyParams::GetDefaultWarmupURL() const {
511 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) 494 return kDefaultWarmupUrl;
512 return DATA_REDUCTION_PROXY_WARMUP_URL;
513 #endif
514 return std::string();
515 } 495 }
516 496
517 } // namespace data_reduction_proxy 497 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698