| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 void OnResponseStarted(URLRequest* request) override { | 92 void OnResponseStarted(URLRequest* request) override { |
| 93 IncrementAndCompareCounter("on_response_started_count"); | 93 IncrementAndCompareCounter("on_response_started_count"); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void OnNetworkBytesReceived(const URLRequest& request, | 96 void OnNetworkBytesReceived(const URLRequest& request, |
| 97 int64_t bytes_received) override { | 97 int64_t bytes_received) override { |
| 98 IncrementAndCompareCounter("on_network_bytes_received_count"); | 98 IncrementAndCompareCounter("on_network_bytes_received_count"); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void OnNetworkBytesSent(const URLRequest& request, |
| 102 int64_t bytes_sent) override { |
| 103 IncrementAndCompareCounter("on_network_bytes_sent_count"); |
| 104 } |
| 105 |
| 101 void OnCompleted(URLRequest* request, bool started) override { | 106 void OnCompleted(URLRequest* request, bool started) override { |
| 102 IncrementAndCompareCounter("on_completed_count"); | 107 IncrementAndCompareCounter("on_completed_count"); |
| 103 } | 108 } |
| 104 | 109 |
| 105 void OnURLRequestDestroyed(URLRequest* request) override { | 110 void OnURLRequestDestroyed(URLRequest* request) override { |
| 106 IncrementAndCompareCounter("on_url_request_destroyed_count"); | 111 IncrementAndCompareCounter("on_url_request_destroyed_count"); |
| 107 } | 112 } |
| 108 | 113 |
| 109 void OnPACScriptError(int line_number, const base::string16& error) override { | 114 void OnPACScriptError(int line_number, const base::string16& error) override { |
| 110 IncrementAndCompareCounter("on_pac_script_error_count"); | 115 IncrementAndCompareCounter("on_pac_script_error_count"); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 scoped_ptr<ProxyInfo> proxy_info(new ProxyInfo()); | 195 scoped_ptr<ProxyInfo> proxy_info(new ProxyInfo()); |
| 191 | 196 |
| 192 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(), | 197 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(), |
| 193 completion_callback.callback(), NULL)); | 198 completion_callback.callback(), NULL)); |
| 194 OnResolveProxy(GURL(), 0, *proxy_service, proxy_info.get()); | 199 OnResolveProxy(GURL(), 0, *proxy_service, proxy_info.get()); |
| 195 OnProxyFallback(ProxyServer(), 0); | 200 OnProxyFallback(ProxyServer(), 0); |
| 196 EXPECT_EQ(OK, OnBeforeSendHeaders(NULL, completion_callback.callback(), | 201 EXPECT_EQ(OK, OnBeforeSendHeaders(NULL, completion_callback.callback(), |
| 197 request_headers.get())); | 202 request_headers.get())); |
| 198 OnBeforeSendProxyHeaders(NULL, ProxyInfo(), request_headers.get()); | 203 OnBeforeSendProxyHeaders(NULL, ProxyInfo(), request_headers.get()); |
| 199 OnSendHeaders(NULL, *request_headers); | 204 OnSendHeaders(NULL, *request_headers); |
| 205 OnNetworkBytesSent(*request, 42); |
| 200 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(), | 206 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(), |
| 201 response_headers.get(), NULL, NULL)); | 207 response_headers.get(), NULL, NULL)); |
| 202 OnResponseStarted(request.get()); | 208 OnResponseStarted(request.get()); |
| 203 OnNetworkBytesReceived(*request, 42); | 209 OnNetworkBytesReceived(*request, 42); |
| 204 OnCompleted(request.get(), false); | 210 OnCompleted(request.get(), false); |
| 205 OnURLRequestDestroyed(request.get()); | 211 OnURLRequestDestroyed(request.get()); |
| 206 OnPACScriptError(0, base::string16()); | 212 OnPACScriptError(0, base::string16()); |
| 207 EXPECT_EQ( | 213 EXPECT_EQ( |
| 208 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, | 214 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, |
| 209 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); | 215 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 ++(*counters_)["on_response_started_count"]; | 283 ++(*counters_)["on_response_started_count"]; |
| 278 EXPECT_EQ(1, (*counters_)["on_response_started_count"]); | 284 EXPECT_EQ(1, (*counters_)["on_response_started_count"]); |
| 279 } | 285 } |
| 280 | 286 |
| 281 void OnNetworkBytesReceivedInternal(const URLRequest& request, | 287 void OnNetworkBytesReceivedInternal(const URLRequest& request, |
| 282 int64_t bytes_received) override { | 288 int64_t bytes_received) override { |
| 283 ++(*counters_)["on_network_bytes_received_count"]; | 289 ++(*counters_)["on_network_bytes_received_count"]; |
| 284 EXPECT_EQ(1, (*counters_)["on_network_bytes_received_count"]); | 290 EXPECT_EQ(1, (*counters_)["on_network_bytes_received_count"]); |
| 285 } | 291 } |
| 286 | 292 |
| 293 void OnNetworkBytesSentInternal(const URLRequest& request, |
| 294 int64_t bytes_sent) override { |
| 295 ++(*counters_)["on_network_bytes_sent_count"]; |
| 296 EXPECT_EQ(1, (*counters_)["on_network_bytes_sent_count"]); |
| 297 } |
| 298 |
| 287 void OnCompletedInternal(URLRequest* request, bool started) override { | 299 void OnCompletedInternal(URLRequest* request, bool started) override { |
| 288 ++(*counters_)["on_completed_count"]; | 300 ++(*counters_)["on_completed_count"]; |
| 289 EXPECT_EQ(1, (*counters_)["on_completed_count"]); | 301 EXPECT_EQ(1, (*counters_)["on_completed_count"]); |
| 290 } | 302 } |
| 291 | 303 |
| 292 void OnURLRequestDestroyedInternal(URLRequest* request) override { | 304 void OnURLRequestDestroyedInternal(URLRequest* request) override { |
| 293 ++(*counters_)["on_url_request_destroyed_count"]; | 305 ++(*counters_)["on_url_request_destroyed_count"]; |
| 294 EXPECT_EQ(1, (*counters_)["on_url_request_destroyed_count"]); | 306 EXPECT_EQ(1, (*counters_)["on_url_request_destroyed_count"]); |
| 295 } | 307 } |
| 296 | 308 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 CountersMap layered_network_delegate_counters; | 382 CountersMap layered_network_delegate_counters; |
| 371 TestNetworkDelegateImpl* test_network_delegate_; | 383 TestNetworkDelegateImpl* test_network_delegate_; |
| 372 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; | 384 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; |
| 373 }; | 385 }; |
| 374 | 386 |
| 375 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { | 387 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { |
| 376 layered_network_delegate_->CallAndVerify(); | 388 layered_network_delegate_->CallAndVerify(); |
| 377 } | 389 } |
| 378 | 390 |
| 379 } // namespace net | 391 } // namespace net |
| OLD | NEW |