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

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

Issue 1362793003: Notify NetworkDelegate when bytes have been sent over the network. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial patch set Created 5 years, 2 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
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const ProxyInfo& proxy_info, 67 const ProxyInfo& proxy_info,
68 HttpRequestHeaders* headers) override { 68 HttpRequestHeaders* headers) override {
69 IncrementAndCompareCounter("on_before_send_proxy_headers_count"); 69 IncrementAndCompareCounter("on_before_send_proxy_headers_count");
70 } 70 }
71 71
72 void OnSendHeaders(URLRequest* request, 72 void OnSendHeaders(URLRequest* request,
73 const HttpRequestHeaders& headers) override { 73 const HttpRequestHeaders& headers) override {
74 IncrementAndCompareCounter("on_send_headers_count"); 74 IncrementAndCompareCounter("on_send_headers_count");
75 } 75 }
76 76
77 void OnNetworkBytesSent(const URLRequest& request,
78 int64_t bytes_sent) override {
79 IncrementAndCompareCounter("on_network_bytes_sent_count");
80 }
81
77 int OnHeadersReceived( 82 int OnHeadersReceived(
78 URLRequest* request, 83 URLRequest* request,
79 const CompletionCallback& callback, 84 const CompletionCallback& callback,
80 const HttpResponseHeaders* original_response_headers, 85 const HttpResponseHeaders* original_response_headers,
81 scoped_refptr<HttpResponseHeaders>* override_response_headers, 86 scoped_refptr<HttpResponseHeaders>* override_response_headers,
82 GURL* allowed_unsafe_redirect_url) override { 87 GURL* allowed_unsafe_redirect_url) override {
83 IncrementAndCompareCounter("on_headers_received_count"); 88 IncrementAndCompareCounter("on_headers_received_count");
84 return OK; 89 return OK;
85 } 90 }
86 91
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 ++(*counters_)["on_before_send_proxy_headers_count"]; 255 ++(*counters_)["on_before_send_proxy_headers_count"];
251 EXPECT_EQ(1, (*counters_)["on_before_send_proxy_headers_count"]); 256 EXPECT_EQ(1, (*counters_)["on_before_send_proxy_headers_count"]);
252 } 257 }
253 258
254 void OnSendHeadersInternal(URLRequest* request, 259 void OnSendHeadersInternal(URLRequest* request,
255 const HttpRequestHeaders& headers) override { 260 const HttpRequestHeaders& headers) override {
256 ++(*counters_)["on_send_headers_count"]; 261 ++(*counters_)["on_send_headers_count"];
257 EXPECT_EQ(1, (*counters_)["on_send_headers_count"]); 262 EXPECT_EQ(1, (*counters_)["on_send_headers_count"]);
258 } 263 }
259 264
265 void OnNetworkBytesSentInternal(const URLRequest& request,
266 int64_t bytes_sent) override {
267 ++(*counters_)["on_network_bytes_sent_count"];
268 EXPECT_EQ(1, (*counters_)["on_network_bytes_sent_count"]);
269 }
270
260 void OnHeadersReceivedInternal( 271 void OnHeadersReceivedInternal(
261 URLRequest* request, 272 URLRequest* request,
262 const CompletionCallback& callback, 273 const CompletionCallback& callback,
263 const HttpResponseHeaders* original_response_headers, 274 const HttpResponseHeaders* original_response_headers,
264 scoped_refptr<HttpResponseHeaders>* override_response_headers, 275 scoped_refptr<HttpResponseHeaders>* override_response_headers,
265 GURL* allowed_unsafe_redirect_url) override { 276 GURL* allowed_unsafe_redirect_url) override {
266 ++(*counters_)["on_headers_received_count"]; 277 ++(*counters_)["on_headers_received_count"];
267 EXPECT_EQ(1, (*counters_)["on_headers_received_count"]); 278 EXPECT_EQ(1, (*counters_)["on_headers_received_count"]);
268 } 279 }
269 280
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 CountersMap layered_network_delegate_counters; 381 CountersMap layered_network_delegate_counters;
371 TestNetworkDelegateImpl* test_network_delegate_; 382 TestNetworkDelegateImpl* test_network_delegate_;
372 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; 383 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_;
373 }; 384 };
374 385
375 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { 386 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) {
376 layered_network_delegate_->CallAndVerify(); 387 layered_network_delegate_->CallAndVerify();
377 } 388 }
378 389
379 } // namespace net 390 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698