| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc
|
| index 4678e8e71f92f70eac01e61f67236f42e3afb266..a1083825ff8bcefa4e36ab1a0cc50b01e5041118 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc
|
| @@ -29,21 +29,20 @@
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers_test_utils.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
|
| #include "net/base/host_port_pair.h"
|
| -#include "net/base/load_flags.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/base/proxy_delegate.h"
|
| #include "net/http/http_request_headers.h"
|
| #include "net/http/http_response_headers.h"
|
| #include "net/http/http_util.h"
|
| #include "net/proxy/proxy_config.h"
|
| #include "net/proxy/proxy_server.h"
|
| #include "net/socket/socket_test_util.h"
|
| #include "net/url_request/url_request.h"
|
| #include "net/url_request/url_request_test_util.h"
|
| @@ -296,21 +295,20 @@ class DataReductionProxyDelegateTest : public testing::Test {
|
| net::MockClientSocketFactory mock_socket_factory_;
|
| net::TestURLRequestContext context_;
|
| net::URLRequestContextStorage context_storage_;
|
|
|
| TestLoFiUIService* lofi_ui_service_;
|
| std::unique_ptr<net::ProxyDelegate> proxy_delegate_;
|
| std::unique_ptr<DataReductionProxyTestContext> test_context_;
|
| };
|
|
|
| TEST_F(DataReductionProxyDelegateTest, OnResolveProxyHandler) {
|
| - int load_flags = net::LOAD_NORMAL;
|
| GURL url("http://www.google.com/");
|
|
|
| // Data reduction proxy info
|
| net::ProxyInfo data_reduction_proxy_info;
|
| std::string data_reduction_proxy;
|
| base::TrimString(params()->DefaultOrigin(), "/", &data_reduction_proxy);
|
| data_reduction_proxy_info.UsePacString(
|
| "PROXY " +
|
| net::ProxyServer::FromURI(params()->DefaultOrigin(),
|
| net::ProxyServer::SCHEME_HTTP)
|
| @@ -343,72 +341,72 @@ TEST_F(DataReductionProxyDelegateTest, OnResolveProxyHandler) {
|
| net::ProxyRetryInfo retry_info;
|
| retry_info.current_delay = base::TimeDelta::FromSeconds(1000);
|
| retry_info.bad_until = base::TimeTicks().Now() + retry_info.current_delay;
|
| retry_info.try_while_bad = false;
|
| data_reduction_proxy_retry_info[data_reduction_proxy_info.proxy_server()
|
| .ToURI()] = retry_info;
|
|
|
| net::ProxyInfo result;
|
| // Another proxy is used. It should be used afterwards.
|
| result.Use(other_proxy_info);
|
| - OnResolveProxyHandler(url, "GET", load_flags, data_reduction_proxy_config,
|
| + OnResolveProxyHandler(url, "GET", data_reduction_proxy_config,
|
| empty_proxy_retry_info, config(), &result);
|
| EXPECT_EQ(other_proxy_info.proxy_server(), result.proxy_server());
|
|
|
| // A direct connection is used. The data reduction proxy should be used
|
| // afterwards.
|
| // Another proxy is used. It should be used afterwards.
|
| result.Use(direct_proxy_info);
|
| net::ProxyConfig::ID prev_id = result.config_id();
|
| - OnResolveProxyHandler(url, "GET", load_flags, data_reduction_proxy_config,
|
| + OnResolveProxyHandler(url, "GET", data_reduction_proxy_config,
|
| empty_proxy_retry_info, config(), &result);
|
| EXPECT_EQ(data_reduction_proxy_info.proxy_server(), result.proxy_server());
|
| // Only the proxy list should be updated, not the proxy info.
|
| EXPECT_EQ(result.config_id(), prev_id);
|
|
|
| // A direct connection is used, but the data reduction proxy is on the retry
|
| // list. A direct connection should be used afterwards.
|
| result.Use(direct_proxy_info);
|
| prev_id = result.config_id();
|
| - OnResolveProxyHandler(GURL("ws://echo.websocket.org/"), "GET", load_flags,
|
| + OnResolveProxyHandler(GURL("ws://echo.websocket.org/"), "GET",
|
| data_reduction_proxy_config,
|
| data_reduction_proxy_retry_info, config(), &result);
|
| EXPECT_TRUE(result.proxy_server().is_direct());
|
| EXPECT_EQ(result.config_id(), prev_id);
|
|
|
| // Test that ws:// and wss:// URLs bypass the data reduction proxy.
|
| result.UseDirect();
|
| - OnResolveProxyHandler(GURL("wss://echo.websocket.org/"), "GET", load_flags,
|
| + OnResolveProxyHandler(GURL("wss://echo.websocket.org/"), "GET",
|
| data_reduction_proxy_config, empty_proxy_retry_info,
|
| config(), &result);
|
| EXPECT_TRUE(result.is_direct());
|
|
|
| result.UseDirect();
|
| - OnResolveProxyHandler(GURL("wss://echo.websocket.org/"), "GET", load_flags,
|
| + OnResolveProxyHandler(GURL("wss://echo.websocket.org/"), "GET",
|
| data_reduction_proxy_config, empty_proxy_retry_info,
|
| config(), &result);
|
| EXPECT_TRUE(result.is_direct());
|
|
|
| // POST methods go direct.
|
| result.UseDirect();
|
| - OnResolveProxyHandler(url, "POST", load_flags, data_reduction_proxy_config,
|
| + OnResolveProxyHandler(url, "POST", data_reduction_proxy_config,
|
| empty_proxy_retry_info, config(), &result);
|
| EXPECT_TRUE(result.is_direct());
|
|
|
| // Without DataCompressionProxyCriticalBypass Finch trial set, the
|
| // BYPASS_DATA_REDUCTION_PROXY load flag should be ignored.
|
| result.UseDirect();
|
| - OnResolveProxyHandler(url, "GET", load_flags, data_reduction_proxy_config,
|
| + OnResolveProxyHandler(url, "GET", data_reduction_proxy_config,
|
| empty_proxy_retry_info, config(), &result);
|
| EXPECT_FALSE(result.is_direct());
|
|
|
| - OnResolveProxyHandler(url, "GET", load_flags, data_reduction_proxy_config,
|
| + OnResolveProxyHandler(url, "GET", data_reduction_proxy_config,
|
| empty_proxy_retry_info, config(), &other_proxy_info);
|
| EXPECT_FALSE(other_proxy_info.is_direct());
|
| }
|
|
|
| // Verifies that requests that were not proxied through data saver proxy due to
|
| // missing config are recorded properly.
|
| TEST_F(DataReductionProxyDelegateTest, HTTPRequests) {
|
| const struct {
|
| std::string url;
|
| bool enabled_by_user;
|
| @@ -476,23 +474,22 @@ TEST_F(DataReductionProxyDelegateTest, HTTPRequests) {
|
| false /* at_startup */);
|
|
|
| net::ProxyRetryInfoMap empty_proxy_retry_info;
|
|
|
| net::ProxyInfo direct_proxy_info;
|
| direct_proxy_info.UseDirect();
|
| EXPECT_TRUE(direct_proxy_info.is_direct());
|
|
|
| net::ProxyInfo result;
|
| result.Use(direct_proxy_info);
|
| - OnResolveProxyHandler(url, "GET", net::LOAD_NORMAL,
|
| - data_reduction_proxy_config, empty_proxy_retry_info,
|
| - config(), &result);
|
| + OnResolveProxyHandler(url, "GET", data_reduction_proxy_config,
|
| + empty_proxy_retry_info, config(), &result);
|
| histogram_tester.ExpectTotalCount(
|
| "DataReductionProxy.ConfigService.HTTPRequests",
|
| tests[i].expect_histogram ? 1 : 0);
|
|
|
| if (tests[i].expect_histogram) {
|
| histogram_tester.ExpectUniqueSample(
|
| "DataReductionProxy.ConfigService.HTTPRequests",
|
| tests[i].use_direct_proxy ? 0 : 1, 1);
|
| }
|
| }
|
|
|