OLD | NEW |
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_config.h" |
15 #include "net/proxy/proxy_info.h" | 16 #include "net/proxy/proxy_info.h" |
16 #include "net/proxy/proxy_retry_info.h" | 17 #include "net/proxy/proxy_retry_info.h" |
17 #include "net/proxy/proxy_server.h" | 18 #include "net/proxy/proxy_server.h" |
18 #include "net/proxy/proxy_service.h" | 19 #include "net/proxy/proxy_service.h" |
19 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
20 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
21 #include "url/url_constants.h" | 22 #include "url/url_constants.h" |
22 | 23 |
23 using base::FieldTrialList; | 24 using base::FieldTrialList; |
24 | 25 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 net::ProxyInfo result; | 360 net::ProxyInfo result; |
360 request->context()->proxy_service()->config().proxy_rules().Apply( | 361 request->context()->proxy_service()->config().proxy_rules().Apply( |
361 request->url(), &result); | 362 request->url(), &result); |
362 if (!result.proxy_server().is_valid()) | 363 if (!result.proxy_server().is_valid()) |
363 return false; | 364 return false; |
364 if (result.proxy_server().is_direct()) | 365 if (result.proxy_server().is_direct()) |
365 return false; | 366 return false; |
366 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); | 367 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); |
367 } | 368 } |
368 | 369 |
| 370 bool DataReductionProxyParams::IsBypassedByDataReductionProxyLocalRules( |
| 371 const net::URLRequest& request, |
| 372 const net::ProxyConfig& data_reduction_proxy_config) const { |
| 373 DCHECK(request.context()); |
| 374 DCHECK(request.context()->proxy_service()); |
| 375 net::ProxyInfo result; |
| 376 data_reduction_proxy_config.proxy_rules().Apply( |
| 377 request.url(), &result); |
| 378 if (!result.proxy_server().is_valid()) |
| 379 return true; |
| 380 if (result.proxy_server().is_direct()) |
| 381 return true; |
| 382 return !IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); |
| 383 } |
| 384 |
369 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { | 385 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { |
370 #if defined(DATA_REDUCTION_DEV_HOST) | 386 #if defined(DATA_REDUCTION_DEV_HOST) |
371 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 387 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
372 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) | 388 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) |
373 return std::string(); | 389 return std::string(); |
374 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || | 390 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || |
375 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == | 391 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == |
376 kEnabled)) { | 392 kEnabled)) { |
377 return DATA_REDUCTION_DEV_HOST; | 393 return DATA_REDUCTION_DEV_HOST; |
378 } | 394 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 } | 524 } |
509 | 525 |
510 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { | 526 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
511 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) | 527 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) |
512 return DATA_REDUCTION_PROXY_WARMUP_URL; | 528 return DATA_REDUCTION_PROXY_WARMUP_URL; |
513 #endif | 529 #endif |
514 return std::string(); | 530 return std::string(); |
515 } | 531 } |
516 | 532 |
517 } // namespace data_reduction_proxy | 533 } // namespace data_reduction_proxy |
OLD | NEW |