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

Side by Side Diff: net/url_request/url_request_test_util.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: Rebased on master 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
« no previous file with comments | « net/url_request/url_request_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/url_request/url_request_test_util.h" 5 #include "net/url_request/url_request_test_util.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 completed_requests_(0), 323 completed_requests_(0),
324 canceled_requests_(0), 324 canceled_requests_(0),
325 cookie_options_bit_mask_(0), 325 cookie_options_bit_mask_(0),
326 blocked_get_cookies_count_(0), 326 blocked_get_cookies_count_(0),
327 blocked_set_cookie_count_(0), 327 blocked_set_cookie_count_(0),
328 set_cookie_count_(0), 328 set_cookie_count_(0),
329 observed_before_proxy_headers_sent_callbacks_(0), 329 observed_before_proxy_headers_sent_callbacks_(0),
330 before_send_headers_count_(0), 330 before_send_headers_count_(0),
331 headers_received_count_(0), 331 headers_received_count_(0),
332 total_network_bytes_received_(0), 332 total_network_bytes_received_(0),
333 total_network_bytes_sent_(0),
333 has_load_timing_info_before_redirect_(false), 334 has_load_timing_info_before_redirect_(false),
334 has_load_timing_info_before_auth_(false), 335 has_load_timing_info_before_auth_(false),
335 can_access_files_(true), 336 can_access_files_(true),
336 first_party_only_cookies_enabled_(false), 337 first_party_only_cookies_enabled_(false),
337 cancel_request_with_policy_violating_referrer_(false), 338 cancel_request_with_policy_violating_referrer_(false),
338 will_be_intercepted_on_next_error_(false) {} 339 will_be_intercepted_on_next_error_(false) {}
339 340
340 TestNetworkDelegate::~TestNetworkDelegate() { 341 TestNetworkDelegate::~TestNetworkDelegate() {
341 for (std::map<int, int>::iterator i = next_states_.begin(); 342 for (std::map<int, int>::iterator i = next_states_.begin();
342 i != next_states_.end(); ++i) { 343 i != next_states_.end(); ++i) {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 last_error_ = request->status().error(); 506 last_error_ = request->status().error();
506 } 507 }
507 } 508 }
508 509
509 void TestNetworkDelegate::OnNetworkBytesReceived(const URLRequest& request, 510 void TestNetworkDelegate::OnNetworkBytesReceived(const URLRequest& request,
510 int64_t bytes_received) { 511 int64_t bytes_received) {
511 event_order_[request.identifier()] += "OnNetworkBytesReceived\n"; 512 event_order_[request.identifier()] += "OnNetworkBytesReceived\n";
512 total_network_bytes_received_ += bytes_received; 513 total_network_bytes_received_ += bytes_received;
513 } 514 }
514 515
516 void TestNetworkDelegate::OnNetworkBytesSent(const URLRequest& request,
517 int64_t bytes_sent) {
518 event_order_[request.identifier()] += "OnNetworkBytesSent\n";
519 total_network_bytes_sent_ += bytes_sent;
520 }
521
515 void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) { 522 void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) {
516 int req_id = request->identifier(); 523 int req_id = request->identifier();
517 InitRequestStatesIfNew(req_id); 524 InitRequestStatesIfNew(req_id);
518 event_order_[req_id] += "OnCompleted\n"; 525 event_order_[req_id] += "OnCompleted\n";
519 // Expect "Success -> (next_states_ & kStageCompletedSuccess)" 526 // Expect "Success -> (next_states_ & kStageCompletedSuccess)"
520 // is logically identical to 527 // is logically identical to
521 // Expect "!(Success) || (next_states_ & kStageCompletedSuccess)" 528 // Expect "!(Success) || (next_states_ & kStageCompletedSuccess)"
522 EXPECT_TRUE(!request->status().is_success() || 529 EXPECT_TRUE(!request->status().is_success() ||
523 (next_states_[req_id] & kStageCompletedSuccess)) << 530 (next_states_[req_id] & kStageCompletedSuccess)) <<
524 event_order_[req_id]; 531 event_order_[req_id];
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 URLRequestJob* job = main_intercept_job_; 638 URLRequestJob* job = main_intercept_job_;
632 main_intercept_job_ = NULL; 639 main_intercept_job_ = NULL;
633 return job; 640 return job;
634 } 641 }
635 642
636 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) { 643 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) {
637 main_intercept_job_ = job; 644 main_intercept_job_ = job;
638 } 645 }
639 646
640 } // namespace net 647 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698