OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/content/browser/content_lofi_decider.h
" | 5 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h
" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" |
21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" |
22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
23 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 23 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" |
24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" | 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" |
26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" | 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" |
27 #include "content/public/browser/resource_request_info.h" | 27 #include "content/public/browser/resource_request_info.h" |
| 28 #include "content/public/common/previews_state.h" |
28 #include "net/base/load_flags.h" | 29 #include "net/base/load_flags.h" |
29 #include "net/base/network_delegate_impl.h" | 30 #include "net/base/network_delegate_impl.h" |
30 #include "net/http/http_request_headers.h" | 31 #include "net/http/http_request_headers.h" |
31 #include "net/proxy/proxy_info.h" | 32 #include "net/proxy/proxy_info.h" |
32 #include "net/proxy/proxy_retry_info.h" | 33 #include "net/proxy/proxy_retry_info.h" |
33 #include "net/socket/socket_test_util.h" | 34 #include "net/socket/socket_test_util.h" |
34 #include "net/url_request/url_request.h" | 35 #include "net/url_request/url_request.h" |
35 #include "net/url_request/url_request_test_util.h" | 36 #include "net/url_request/url_request_test_util.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
37 | 38 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 100 |
100 void AllocateRequestInfoForTesting(net::URLRequest* request, | 101 void AllocateRequestInfoForTesting(net::URLRequest* request, |
101 content::ResourceType resource_type, | 102 content::ResourceType resource_type, |
102 bool is_using_lofi) { | 103 bool is_using_lofi) { |
103 content::ResourceRequestInfo::AllocateForTesting( | 104 content::ResourceRequestInfo::AllocateForTesting( |
104 request, resource_type, NULL, -1, -1, -1, | 105 request, resource_type, NULL, -1, -1, -1, |
105 resource_type == content::RESOURCE_TYPE_MAIN_FRAME, | 106 resource_type == content::RESOURCE_TYPE_MAIN_FRAME, |
106 false, // parent_is_main_frame | 107 false, // parent_is_main_frame |
107 false, // allow_download | 108 false, // allow_download |
108 false, // is_async | 109 false, // is_async |
109 is_using_lofi); | 110 is_using_lofi ? content::SERVER_LOFI_ON : content::PREVIEWS_OFF); |
110 } | 111 } |
111 | 112 |
112 std::unique_ptr<net::URLRequest> CreateRequest(bool is_main_frame, | 113 std::unique_ptr<net::URLRequest> CreateRequest(bool is_main_frame, |
113 bool is_using_lofi) { | 114 bool is_using_lofi) { |
114 std::unique_ptr<net::URLRequest> request = context_.CreateRequest( | 115 std::unique_ptr<net::URLRequest> request = context_.CreateRequest( |
115 GURL("http://www.google.com/"), net::IDLE, &delegate_); | 116 GURL("http://www.google.com/"), net::IDLE, &delegate_); |
116 AllocateRequestInfoForTesting( | 117 AllocateRequestInfoForTesting( |
117 request.get(), (is_main_frame ? content::RESOURCE_TYPE_MAIN_FRAME | 118 request.get(), (is_main_frame ? content::RESOURCE_TYPE_MAIN_FRAME |
118 : content::RESOURCE_TYPE_SUB_FRAME), | 119 : content::RESOURCE_TYPE_SUB_FRAME), |
119 is_using_lofi); | 120 is_using_lofi); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 EXPECT_EQ("exp=ignore_preview_blacklist", header_value); | 682 EXPECT_EQ("exp=ignore_preview_blacklist", header_value); |
682 | 683 |
683 headers.SetHeader(chrome_proxy_header(), "Foo"); | 684 headers.SetHeader(chrome_proxy_header(), "Foo"); |
684 lofi_decider->MaybeSetIgnorePreviewsBlacklistDirective(&headers); | 685 lofi_decider->MaybeSetIgnorePreviewsBlacklistDirective(&headers); |
685 EXPECT_TRUE(headers.HasHeader(chrome_proxy_header())); | 686 EXPECT_TRUE(headers.HasHeader(chrome_proxy_header())); |
686 headers.GetHeader(chrome_proxy_header(), &header_value); | 687 headers.GetHeader(chrome_proxy_header(), &header_value); |
687 EXPECT_EQ("Foo, exp=ignore_preview_blacklist", header_value); | 688 EXPECT_EQ("Foo, exp=ignore_preview_blacklist", header_value); |
688 } | 689 } |
689 | 690 |
690 } // namespace data_reduction_roxy | 691 } // namespace data_reduction_roxy |
OLD | NEW |