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 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 GURL* allowed_unsafe_redirect_url) override { | 73 GURL* allowed_unsafe_redirect_url) override { |
74 IncrementAndCompareCounter("on_headers_received_count"); | 74 IncrementAndCompareCounter("on_headers_received_count"); |
75 return OK; | 75 return OK; |
76 } | 76 } |
77 | 77 |
78 void OnBeforeRedirect(URLRequest* request, | 78 void OnBeforeRedirect(URLRequest* request, |
79 const GURL& new_location) override { | 79 const GURL& new_location) override { |
80 IncrementAndCompareCounter("on_before_redirect_count"); | 80 IncrementAndCompareCounter("on_before_redirect_count"); |
81 } | 81 } |
82 | 82 |
83 void OnResponseStarted(URLRequest* request) override { | 83 void OnResponseStarted(URLRequest* request, int net_error) override { |
84 IncrementAndCompareCounter("on_response_started_count"); | 84 IncrementAndCompareCounter("on_response_started_count"); |
85 } | 85 } |
86 | 86 |
87 void OnNetworkBytesReceived(URLRequest* request, | 87 void OnNetworkBytesReceived(URLRequest* request, |
88 int64_t bytes_received) override { | 88 int64_t bytes_received) override { |
89 IncrementAndCompareCounter("on_network_bytes_received_count"); | 89 IncrementAndCompareCounter("on_network_bytes_received_count"); |
90 } | 90 } |
91 | 91 |
92 void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) override { | 92 void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) override { |
93 IncrementAndCompareCounter("on_network_bytes_sent_count"); | 93 IncrementAndCompareCounter("on_network_bytes_sent_count"); |
94 } | 94 } |
95 | 95 |
96 void OnCompleted(URLRequest* request, bool started) override { | 96 void OnCompleted(URLRequest* request, bool started, int net_error) override { |
97 IncrementAndCompareCounter("on_completed_count"); | 97 IncrementAndCompareCounter("on_completed_count"); |
98 } | 98 } |
99 | 99 |
100 void OnURLRequestDestroyed(URLRequest* request) override { | 100 void OnURLRequestDestroyed(URLRequest* request) override { |
101 IncrementAndCompareCounter("on_url_request_destroyed_count"); | 101 IncrementAndCompareCounter("on_url_request_destroyed_count"); |
102 } | 102 } |
103 | 103 |
104 void OnPACScriptError(int line_number, const base::string16& error) override { | 104 void OnPACScriptError(int line_number, const base::string16& error) override { |
105 IncrementAndCompareCounter("on_pac_script_error_count"); | 105 IncrementAndCompareCounter("on_pac_script_error_count"); |
106 } | 106 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(), | 187 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(), |
188 completion_callback.callback(), NULL)); | 188 completion_callback.callback(), NULL)); |
189 EXPECT_EQ(OK, OnBeforeStartTransaction(NULL, completion_callback.callback(), | 189 EXPECT_EQ(OK, OnBeforeStartTransaction(NULL, completion_callback.callback(), |
190 request_headers.get())); | 190 request_headers.get())); |
191 OnBeforeSendHeaders(NULL, ProxyInfo(), proxy_retry_info, | 191 OnBeforeSendHeaders(NULL, ProxyInfo(), proxy_retry_info, |
192 request_headers.get()); | 192 request_headers.get()); |
193 OnStartTransaction(NULL, *request_headers); | 193 OnStartTransaction(NULL, *request_headers); |
194 OnNetworkBytesSent(request.get(), 42); | 194 OnNetworkBytesSent(request.get(), 42); |
195 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(), | 195 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(), |
196 response_headers.get(), NULL, NULL)); | 196 response_headers.get(), NULL, NULL)); |
197 OnResponseStarted(request.get()); | 197 OnResponseStarted(request.get(), net::OK); |
198 OnNetworkBytesReceived(request.get(), 42); | 198 OnNetworkBytesReceived(request.get(), 42); |
199 OnCompleted(request.get(), false); | 199 OnCompleted(request.get(), false, net::OK); |
200 OnURLRequestDestroyed(request.get()); | 200 OnURLRequestDestroyed(request.get()); |
201 OnPACScriptError(0, base::string16()); | 201 OnPACScriptError(0, base::string16()); |
202 EXPECT_EQ( | 202 EXPECT_EQ( |
203 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, | 203 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, |
204 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); | 204 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); |
205 EXPECT_FALSE(OnCanGetCookies(*request, CookieList())); | 205 EXPECT_FALSE(OnCanGetCookies(*request, CookieList())); |
206 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL)); | 206 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL)); |
207 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath())); | 207 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath())); |
208 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL())); | 208 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL())); |
209 EXPECT_FALSE(OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 209 EXPECT_FALSE(OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 CountersMap layered_network_delegate_counters; | 358 CountersMap layered_network_delegate_counters; |
359 TestNetworkDelegateImpl* test_network_delegate_; | 359 TestNetworkDelegateImpl* test_network_delegate_; |
360 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; | 360 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; |
361 }; | 361 }; |
362 | 362 |
363 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { | 363 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { |
364 layered_network_delegate_->CallAndVerify(); | 364 layered_network_delegate_->CallAndVerify(); |
365 } | 365 } |
366 | 366 |
367 } // namespace net | 367 } // namespace net |
OLD | NEW |