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_protocol.
h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.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/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_te
st_utils.h" | 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_te
st_utils.h" |
15 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" | 15 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
16 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers_te
st_utils.h" | |
17 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
18 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
19 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
20 #include "net/base/network_delegate.h" | 19 #include "net/base/network_delegate.h" |
21 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
22 #include "net/http/http_transaction_test_util.h" | 21 #include "net/http/http_transaction_test_util.h" |
23 #include "net/proxy/proxy_service.h" | 22 #include "net/proxy/proxy_service.h" |
24 #include "net/socket/socket_test_util.h" | 23 #include "net/socket/socket_test_util.h" |
25 #include "net/url_request/static_http_user_agent_settings.h" | 24 #include "net/url_request/static_http_user_agent_settings.h" |
26 #include "net/url_request/url_request.h" | 25 #include "net/url_request/url_request.h" |
27 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
28 #include "net/url_request/url_request_test_util.h" | 27 #include "net/url_request/url_request_test_util.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
30 | 29 |
31 using net::HttpResponseHeaders; | 30 using net::HttpResponseHeaders; |
32 using net::HostPortPair; | 31 using net::HostPortPair; |
33 using net::MockRead; | 32 using net::MockRead; |
34 using net::MockWrite; | 33 using net::MockWrite; |
35 using net::ProxyRetryInfoMap; | 34 using net::ProxyRetryInfoMap; |
36 using net::ProxyService; | 35 using net::ProxyService; |
37 using net::StaticSocketDataProvider; | 36 using net::StaticSocketDataProvider; |
38 using net::TestDelegate; | 37 using net::TestDelegate; |
39 using net::URLRequest; | 38 using net::URLRequest; |
40 using net::TestURLRequestContext; | 39 using net::TestURLRequestContext; |
41 | 40 |
42 | 41 |
| 42 namespace { |
| 43 // Transform "normal"-looking headers (\n-separated) to the appropriate |
| 44 // input format for ParseRawHeaders (\0-separated). |
| 45 void HeadersToRaw(std::string* headers) { |
| 46 std::replace(headers->begin(), headers->end(), '\n', '\0'); |
| 47 if (!headers->empty()) |
| 48 *headers += '\0'; |
| 49 } |
| 50 |
| 51 } // namespace |
| 52 |
| 53 |
43 namespace data_reduction_proxy { | 54 namespace data_reduction_proxy { |
44 | 55 |
45 // A test network delegate that exercises the bypass logic of the data | 56 // A test network delegate that exercises the bypass logic of the data |
46 // reduction proxy. | 57 // reduction proxy. |
47 class TestDataReductionProxyNetworkDelegate : public net::NetworkDelegate { | 58 class TestDataReductionProxyNetworkDelegate : public net::NetworkDelegate { |
48 public: | 59 public: |
49 TestDataReductionProxyNetworkDelegate( | 60 TestDataReductionProxyNetworkDelegate( |
50 TestDataReductionProxyParams* test_params, | 61 TestDataReductionProxyParams* test_params, |
51 DataReductionProxyBypassType* bypass_type) | 62 DataReductionProxyBypassType* bypass_type) |
52 : net::NetworkDelegate(), | 63 : net::NetworkDelegate(), |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 &other_proxy_info); | 914 &other_proxy_info); |
904 EXPECT_FALSE(other_proxy_info.is_direct()); | 915 EXPECT_FALSE(other_proxy_info.is_direct()); |
905 | 916 |
906 OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config, | 917 OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config, |
907 empty_proxy_retry_info, &test_params, | 918 empty_proxy_retry_info, &test_params, |
908 &data_reduction_proxy_info); | 919 &data_reduction_proxy_info); |
909 EXPECT_TRUE(data_reduction_proxy_info.is_direct()); | 920 EXPECT_TRUE(data_reduction_proxy_info.is_direct()); |
910 } | 921 } |
911 | 922 |
912 } // namespace data_reduction_proxy | 923 } // namespace data_reduction_proxy |
OLD | NEW |