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 "net/base/layered_network_delegate.h" | 5 #include "net/base/layered_network_delegate.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "net/base/auth.h" | 15 #include "net/base/auth.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/base/network_delegate_impl.h" | 17 #include "net/base/network_delegate_impl.h" |
18 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
19 #include "net/base/test_completion_callback.h" | 19 #include "net/base/test_completion_callback.h" |
20 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
21 #include "net/proxy/proxy_config_service.h" | 21 #include "net/proxy/proxy_config_service.h" |
22 #include "net/proxy/proxy_info.h" | 22 #include "net/proxy/proxy_info.h" |
23 #include "net/proxy/proxy_retry_info.h" | 23 #include "net/proxy/proxy_retry_info.h" |
| 24 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
24 #include "net/url_request/url_request.h" | 25 #include "net/url_request/url_request.h" |
25 #include "net/url_request/url_request_test_util.h" | 26 #include "net/url_request/url_request_test_util.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
28 | 29 |
29 namespace net { | 30 namespace net { |
30 namespace { | 31 namespace { |
31 | 32 |
32 typedef std::map<const char*, int> CountersMap; | 33 typedef std::map<const char*, int> CountersMap; |
33 | 34 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 : LayeredNetworkDelegate(std::move(network_delegate)), | 169 : LayeredNetworkDelegate(std::move(network_delegate)), |
169 context_(true), | 170 context_(true), |
170 counters_(counters) { | 171 counters_(counters) { |
171 context_.Init(); | 172 context_.Init(); |
172 } | 173 } |
173 | 174 |
174 ~TestLayeredNetworkDelegate() override {} | 175 ~TestLayeredNetworkDelegate() override {} |
175 | 176 |
176 void CallAndVerify() { | 177 void CallAndVerify() { |
177 scoped_refptr<AuthChallengeInfo> auth_challenge(new AuthChallengeInfo()); | 178 scoped_refptr<AuthChallengeInfo> auth_challenge(new AuthChallengeInfo()); |
178 std::unique_ptr<URLRequest> request = | 179 std::unique_ptr<URLRequest> request = context_.CreateRequest( |
179 context_.CreateRequest(GURL(), IDLE, &delegate_); | 180 GURL(), IDLE, &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); |
180 std::unique_ptr<HttpRequestHeaders> request_headers( | 181 std::unique_ptr<HttpRequestHeaders> request_headers( |
181 new HttpRequestHeaders()); | 182 new HttpRequestHeaders()); |
182 scoped_refptr<HttpResponseHeaders> response_headers( | 183 scoped_refptr<HttpResponseHeaders> response_headers( |
183 new HttpResponseHeaders("")); | 184 new HttpResponseHeaders("")); |
184 TestCompletionCallback completion_callback; | 185 TestCompletionCallback completion_callback; |
185 ProxyRetryInfoMap proxy_retry_info; | 186 ProxyRetryInfoMap proxy_retry_info; |
186 | 187 |
187 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(), | 188 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(), |
188 completion_callback.callback(), NULL)); | 189 completion_callback.callback(), NULL)); |
189 EXPECT_EQ(OK, OnBeforeStartTransaction(NULL, completion_callback.callback(), | 190 EXPECT_EQ(OK, OnBeforeStartTransaction(NULL, completion_callback.callback(), |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 CountersMap layered_network_delegate_counters; | 359 CountersMap layered_network_delegate_counters; |
359 TestNetworkDelegateImpl* test_network_delegate_; | 360 TestNetworkDelegateImpl* test_network_delegate_; |
360 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; | 361 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; |
361 }; | 362 }; |
362 | 363 |
363 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { | 364 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { |
364 layered_network_delegate_->CallAndVerify(); | 365 layered_network_delegate_->CallAndVerify(); |
365 } | 366 } |
366 | 367 |
367 } // namespace net | 368 } // namespace net |
OLD | NEW |