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

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

Issue 1421983002: Include tab IDs when reporting data use accounting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_use_scoped_vector
Patch Set: Fixed external_data_use_observer test Created 5 years, 1 month 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 OnNetworkBytesReceived(const URLRequest& request, 96 void OnNetworkBytesReceived(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, 101 void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) override {
102 int64_t bytes_sent) override {
103 IncrementAndCompareCounter("on_network_bytes_sent_count"); 102 IncrementAndCompareCounter("on_network_bytes_sent_count");
104 } 103 }
105 104
106 void OnCompleted(URLRequest* request, bool started) override { 105 void OnCompleted(URLRequest* request, bool started) override {
107 IncrementAndCompareCounter("on_completed_count"); 106 IncrementAndCompareCounter("on_completed_count");
108 } 107 }
109 108
110 void OnURLRequestDestroyed(URLRequest* request) override { 109 void OnURLRequestDestroyed(URLRequest* request) override {
111 IncrementAndCompareCounter("on_url_request_destroyed_count"); 110 IncrementAndCompareCounter("on_url_request_destroyed_count");
112 } 111 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 scoped_ptr<ProxyInfo> proxy_info(new ProxyInfo()); 194 scoped_ptr<ProxyInfo> proxy_info(new ProxyInfo());
196 195
197 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(), 196 EXPECT_EQ(OK, OnBeforeURLRequest(request.get(),
198 completion_callback.callback(), NULL)); 197 completion_callback.callback(), NULL));
199 OnResolveProxy(GURL(), 0, *proxy_service, proxy_info.get()); 198 OnResolveProxy(GURL(), 0, *proxy_service, proxy_info.get());
200 OnProxyFallback(ProxyServer(), 0); 199 OnProxyFallback(ProxyServer(), 0);
201 EXPECT_EQ(OK, OnBeforeSendHeaders(NULL, completion_callback.callback(), 200 EXPECT_EQ(OK, OnBeforeSendHeaders(NULL, completion_callback.callback(),
202 request_headers.get())); 201 request_headers.get()));
203 OnBeforeSendProxyHeaders(NULL, ProxyInfo(), request_headers.get()); 202 OnBeforeSendProxyHeaders(NULL, ProxyInfo(), request_headers.get());
204 OnSendHeaders(NULL, *request_headers); 203 OnSendHeaders(NULL, *request_headers);
205 OnNetworkBytesSent(*request, 42); 204 OnNetworkBytesSent(request.get(), 42);
206 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(), 205 EXPECT_EQ(OK, OnHeadersReceived(NULL, completion_callback.callback(),
207 response_headers.get(), NULL, NULL)); 206 response_headers.get(), NULL, NULL));
208 OnResponseStarted(request.get()); 207 OnResponseStarted(request.get());
209 OnNetworkBytesReceived(*request, 42); 208 OnNetworkBytesReceived(request.get(), 42);
210 OnCompleted(request.get(), false); 209 OnCompleted(request.get(), false);
211 OnURLRequestDestroyed(request.get()); 210 OnURLRequestDestroyed(request.get());
212 OnPACScriptError(0, base::string16()); 211 OnPACScriptError(0, base::string16());
213 EXPECT_EQ( 212 EXPECT_EQ(
214 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, 213 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION,
215 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); 214 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL));
216 EXPECT_FALSE(OnCanGetCookies(*request, CookieList())); 215 EXPECT_FALSE(OnCanGetCookies(*request, CookieList()));
217 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL)); 216 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL));
218 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath())); 217 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath()));
219 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL())); 218 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL()));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 const GURL& new_location) override { 276 const GURL& new_location) override {
278 ++(*counters_)["on_before_redirect_count"]; 277 ++(*counters_)["on_before_redirect_count"];
279 EXPECT_EQ(1, (*counters_)["on_before_redirect_count"]); 278 EXPECT_EQ(1, (*counters_)["on_before_redirect_count"]);
280 } 279 }
281 280
282 void OnResponseStartedInternal(URLRequest* request) override { 281 void OnResponseStartedInternal(URLRequest* request) override {
283 ++(*counters_)["on_response_started_count"]; 282 ++(*counters_)["on_response_started_count"];
284 EXPECT_EQ(1, (*counters_)["on_response_started_count"]); 283 EXPECT_EQ(1, (*counters_)["on_response_started_count"]);
285 } 284 }
286 285
287 void OnNetworkBytesReceivedInternal(const URLRequest& request, 286 void OnNetworkBytesReceivedInternal(URLRequest* request,
288 int64_t bytes_received) override { 287 int64_t bytes_received) override {
289 ++(*counters_)["on_network_bytes_received_count"]; 288 ++(*counters_)["on_network_bytes_received_count"];
290 EXPECT_EQ(1, (*counters_)["on_network_bytes_received_count"]); 289 EXPECT_EQ(1, (*counters_)["on_network_bytes_received_count"]);
291 } 290 }
292 291
293 void OnNetworkBytesSentInternal(const URLRequest& request, 292 void OnNetworkBytesSentInternal(URLRequest* request,
294 int64_t bytes_sent) override { 293 int64_t bytes_sent) override {
295 ++(*counters_)["on_network_bytes_sent_count"]; 294 ++(*counters_)["on_network_bytes_sent_count"];
296 EXPECT_EQ(1, (*counters_)["on_network_bytes_sent_count"]); 295 EXPECT_EQ(1, (*counters_)["on_network_bytes_sent_count"]);
297 } 296 }
298 297
299 void OnCompletedInternal(URLRequest* request, bool started) override { 298 void OnCompletedInternal(URLRequest* request, bool started) override {
300 ++(*counters_)["on_completed_count"]; 299 ++(*counters_)["on_completed_count"];
301 EXPECT_EQ(1, (*counters_)["on_completed_count"]); 300 EXPECT_EQ(1, (*counters_)["on_completed_count"]);
302 } 301 }
303 302
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 CountersMap layered_network_delegate_counters; 381 CountersMap layered_network_delegate_counters;
383 TestNetworkDelegateImpl* test_network_delegate_; 382 TestNetworkDelegateImpl* test_network_delegate_;
384 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; 383 scoped_ptr<TestLayeredNetworkDelegate> layered_network_delegate_;
385 }; 384 };
386 385
387 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { 386 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) {
388 layered_network_delegate_->CallAndVerify(); 387 layered_network_delegate_->CallAndVerify();
389 } 388 }
390 389
391 } // namespace net 390 } // 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