OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_resource_type_
provider.h" | 5 #include "components/data_reduction_proxy/content/browser/content_resource_type_
provider.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/test/histogram_tester.h" | 11 #include "base/test/histogram_tester.h" |
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_dele
gate.h" | 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_dele
gate.h" |
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" | 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" |
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" | 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" |
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" |
19 #include "content/public/browser/resource_request_info.h" | 19 #include "content/public/browser/resource_request_info.h" |
| 20 #include "content/public/common/previews_state.h" |
20 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 | 25 |
25 namespace data_reduction_proxy { | 26 namespace data_reduction_proxy { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 86 } |
86 | 87 |
87 void AllocateRequestInfoForTesting(net::URLRequest* request, | 88 void AllocateRequestInfoForTesting(net::URLRequest* request, |
88 content::ResourceType resource_type) { | 89 content::ResourceType resource_type) { |
89 content::ResourceRequestInfo::AllocateForTesting( | 90 content::ResourceRequestInfo::AllocateForTesting( |
90 request, resource_type, NULL, -1, -1, -1, | 91 request, resource_type, NULL, -1, -1, -1, |
91 resource_type == content::RESOURCE_TYPE_MAIN_FRAME, | 92 resource_type == content::RESOURCE_TYPE_MAIN_FRAME, |
92 false, // parent_is_main_frame | 93 false, // parent_is_main_frame |
93 false, // allow_download | 94 false, // allow_download |
94 false, // is_async | 95 false, // is_async |
95 false // is_using_lofi | 96 content::PREVIEWS_OFF); |
96 ); | |
97 } | 97 } |
98 | 98 |
99 std::unique_ptr<net::URLRequest> CreateRequestByType( | 99 std::unique_ptr<net::URLRequest> CreateRequestByType( |
100 const GURL& gurl, | 100 const GURL& gurl, |
101 content::ResourceType resource_type) { | 101 content::ResourceType resource_type) { |
102 std::unique_ptr<net::URLRequest> request = | 102 std::unique_ptr<net::URLRequest> request = |
103 context_.CreateRequest(gurl, net::IDLE, &delegate_); | 103 context_.CreateRequest(gurl, net::IDLE, &delegate_); |
104 AllocateRequestInfoForTesting(request.get(), resource_type); | 104 AllocateRequestInfoForTesting(request.get(), resource_type); |
105 return request; | 105 return request; |
106 } | 106 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 EXPECT_EQ(test.expected_content_type, | 169 EXPECT_EQ(test.expected_content_type, |
170 content_resource_type_provider()->GetContentType(request->url())); | 170 content_resource_type_provider()->GetContentType(request->url())); |
171 | 171 |
172 // Querying for the content type of |request->url()| again should still | 172 // Querying for the content type of |request->url()| again should still |
173 // give the correct result. | 173 // give the correct result. |
174 EXPECT_EQ(test.expected_content_type, | 174 EXPECT_EQ(test.expected_content_type, |
175 content_resource_type_provider()->GetContentType(request->url())); | 175 content_resource_type_provider()->GetContentType(request->url())); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 } // namespace data_reduction_proxy | 179 } // namespace data_reduction_proxy |
OLD | NEW |