Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: net/base/layered_network_delegate_unittest.cc

Issue 1284993005: Notify NetworkDelegate when bytes have been received over the network. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed empty cronet OnRawBytesRead implementation Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/layered_network_delegate.cc ('k') | net/base/network_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 void OnBeforeRedirect(URLRequest* request, 87 void OnBeforeRedirect(URLRequest* request,
88 const GURL& new_location) override { 88 const GURL& new_location) override {
89 IncrementAndCompareCounter("on_before_redirect_count"); 89 IncrementAndCompareCounter("on_before_redirect_count");
90 } 90 }
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 OnRawBytesRead(const URLRequest& request, int bytes_read) override { 96 void OnNetworkBytesReceived(const URLRequest& request,
97 IncrementAndCompareCounter("on_raw_bytes_read_count"); 97 int64_t bytes_received) override {
98 IncrementAndCompareCounter("on_network_bytes_received_count");
98 } 99 }
99 100
100 void OnCompleted(URLRequest* request, bool started) override { 101 void OnCompleted(URLRequest* request, bool started) override {
101 IncrementAndCompareCounter("on_completed_count"); 102 IncrementAndCompareCounter("on_completed_count");
102 } 103 }
103 104
104 void OnURLRequestDestroyed(URLRequest* request) override { 105 void OnURLRequestDestroyed(URLRequest* request) override {
105 IncrementAndCompareCounter("on_url_request_destroyed_count"); 106 IncrementAndCompareCounter("on_url_request_destroyed_count");
106 } 107 }
107 108
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 completion_callback.callback(), NULL)); 193 completion_callback.callback(), NULL));
193 OnResolveProxy(GURL(), 0, *proxy_service, proxy_info.get()); 194 OnResolveProxy(GURL(), 0, *proxy_service, proxy_info.get());
194 OnProxyFallback(ProxyServer(), 0); 195 OnProxyFallback(ProxyServer(), 0);
195 EXPECT_EQ(OK, OnBeforeSendHeaders(NULL, completion_callback.callback(), 196 EXPECT_EQ(OK, OnBeforeSendHeaders(NULL, completion_callback.callback(),
196 request_headers.get())); 197 request_headers.get()));
197 OnBeforeSendProxyHeaders(NULL, ProxyInfo(), request_headers.get()); 198 OnBeforeSendProxyHeaders(NULL, ProxyInfo(), request_headers.get());
198 OnSendHeaders(NULL, *request_headers); 199 OnSendHeaders(NULL, *request_headers);
199 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(), 200 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(),
200 response_headers.get(), NULL, NULL)); 201 response_headers.get(), NULL, NULL));
201 OnResponseStarted(request.get()); 202 OnResponseStarted(request.get());
202 OnRawBytesRead(*request, 0); 203 OnNetworkBytesReceived(*request, 42);
203 OnCompleted(request.get(), false); 204 OnCompleted(request.get(), false);
204 OnURLRequestDestroyed(request.get()); 205 OnURLRequestDestroyed(request.get());
205 OnPACScriptError(0, base::string16()); 206 OnPACScriptError(0, base::string16());
206 EXPECT_EQ( 207 EXPECT_EQ(
207 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, 208 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION,
208 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); 209 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL));
209 EXPECT_FALSE(OnCanGetCookies(*request, CookieList())); 210 EXPECT_FALSE(OnCanGetCookies(*request, CookieList()));
210 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL)); 211 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL));
211 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath())); 212 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath()));
212 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL())); 213 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL()));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 const GURL& new_location) override { 271 const GURL& new_location) override {
271 ++(*counters_)["on_before_redirect_count"]; 272 ++(*counters_)["on_before_redirect_count"];
272 EXPECT_EQ(1, (*counters_)["on_before_redirect_count"]); 273 EXPECT_EQ(1, (*counters_)["on_before_redirect_count"]);
273 } 274 }
274 275
275 void OnResponseStartedInternal(URLRequest* request) override { 276 void OnResponseStartedInternal(URLRequest* request) override {
276 ++(*counters_)["on_response_started_count"]; 277 ++(*counters_)["on_response_started_count"];
277 EXPECT_EQ(1, (*counters_)["on_response_started_count"]); 278 EXPECT_EQ(1, (*counters_)["on_response_started_count"]);
278 } 279 }
279 280
280 void OnRawBytesReadInternal(const URLRequest& request, 281 void OnNetworkBytesReceivedInternal(const URLRequest& request,
281 int bytes_read) override { 282 int64_t bytes_received) override {
282 ++(*counters_)["on_raw_bytes_read_count"]; 283 ++(*counters_)["on_network_bytes_received_count"];
283 EXPECT_EQ(1, (*counters_)["on_raw_bytes_read_count"]); 284 EXPECT_EQ(1, (*counters_)["on_network_bytes_received_count"]);
284 } 285 }
285 286
286 void OnCompletedInternal(URLRequest* request, bool started) override { 287 void OnCompletedInternal(URLRequest* request, bool started) override {
287 ++(*counters_)["on_completed_count"]; 288 ++(*counters_)["on_completed_count"];
288 EXPECT_EQ(1, (*counters_)["on_completed_count"]); 289 EXPECT_EQ(1, (*counters_)["on_completed_count"]);
289 } 290 }
290 291
291 void OnURLRequestDestroyedInternal(URLRequest* request) override { 292 void OnURLRequestDestroyedInternal(URLRequest* request) override {
292 ++(*counters_)["on_url_request_destroyed_count"]; 293 ++(*counters_)["on_url_request_destroyed_count"];
293 EXPECT_EQ(1, (*counters_)["on_url_request_destroyed_count"]); 294 EXPECT_EQ(1, (*counters_)["on_url_request_destroyed_count"]);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 CountersMap layered_network_delegate_counters; 370 CountersMap layered_network_delegate_counters;
370 TestNetworkDelegateImpl* test_network_delegate_; 371 TestNetworkDelegateImpl* test_network_delegate_;
371 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; 372 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_;
372 }; 373 };
373 374
374 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { 375 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) {
375 layered_network_delegate_->CallAndVerify(); 376 layered_network_delegate_->CallAndVerify();
376 } 377 }
377 378
378 } // namespace net 379 } // namespace net
OLDNEW
« no previous file with comments | « net/base/layered_network_delegate.cc ('k') | net/base/network_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698