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

Side by Side Diff: net/url_request/url_request_test_util.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/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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 destroyed_requests_(0), 320 destroyed_requests_(0),
321 completed_requests_(0), 321 completed_requests_(0),
322 canceled_requests_(0), 322 canceled_requests_(0),
323 cookie_options_bit_mask_(0), 323 cookie_options_bit_mask_(0),
324 blocked_get_cookies_count_(0), 324 blocked_get_cookies_count_(0),
325 blocked_set_cookie_count_(0), 325 blocked_set_cookie_count_(0),
326 set_cookie_count_(0), 326 set_cookie_count_(0),
327 observed_before_proxy_headers_sent_callbacks_(0), 327 observed_before_proxy_headers_sent_callbacks_(0),
328 before_send_headers_count_(0), 328 before_send_headers_count_(0),
329 headers_received_count_(0), 329 headers_received_count_(0),
330 total_network_bytes_received_(0),
330 has_load_timing_info_before_redirect_(false), 331 has_load_timing_info_before_redirect_(false),
331 has_load_timing_info_before_auth_(false), 332 has_load_timing_info_before_auth_(false),
332 can_access_files_(true), 333 can_access_files_(true),
333 first_party_only_cookies_enabled_(false), 334 first_party_only_cookies_enabled_(false),
334 cancel_request_with_policy_violating_referrer_(false), 335 cancel_request_with_policy_violating_referrer_(false),
335 will_be_intercepted_on_next_error_(false) { 336 will_be_intercepted_on_next_error_(false) {}
336 }
337 337
338 TestNetworkDelegate::~TestNetworkDelegate() { 338 TestNetworkDelegate::~TestNetworkDelegate() {
339 for (std::map<int, int>::iterator i = next_states_.begin(); 339 for (std::map<int, int>::iterator i = next_states_.begin();
340 i != next_states_.end(); ++i) { 340 i != next_states_.end(); ++i) {
341 event_order_[i->first] += "~TestNetworkDelegate\n"; 341 event_order_[i->first] += "~TestNetworkDelegate\n";
342 EXPECT_TRUE(i->second & kStageDestruction) << event_order_[i->first]; 342 EXPECT_TRUE(i->second & kStageDestruction) << event_order_[i->first];
343 } 343 }
344 } 344 }
345 345
346 bool TestNetworkDelegate::GetLoadTimingInfoBeforeRedirect( 346 bool TestNetworkDelegate::GetLoadTimingInfoBeforeRedirect(
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 event_order_[req_id] += "OnResponseStarted\n"; 497 event_order_[req_id] += "OnResponseStarted\n";
498 EXPECT_TRUE(next_states_[req_id] & kStageResponseStarted) << 498 EXPECT_TRUE(next_states_[req_id] & kStageResponseStarted) <<
499 event_order_[req_id]; 499 event_order_[req_id];
500 next_states_[req_id] = kStageCompletedSuccess | kStageCompletedError; 500 next_states_[req_id] = kStageCompletedSuccess | kStageCompletedError;
501 if (request->status().status() == URLRequestStatus::FAILED) { 501 if (request->status().status() == URLRequestStatus::FAILED) {
502 error_count_++; 502 error_count_++;
503 last_error_ = request->status().error(); 503 last_error_ = request->status().error();
504 } 504 }
505 } 505 }
506 506
507 void TestNetworkDelegate::OnRawBytesRead(const URLRequest& request, 507 void TestNetworkDelegate::OnNetworkBytesReceived(const URLRequest& request,
508 int bytes_read) { 508 int64_t bytes_received) {
509 event_order_[request.identifier()] += "OnNetworkBytesReceived\n";
510 total_network_bytes_received_ += bytes_received;
509 } 511 }
510 512
511 void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) { 513 void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) {
512 int req_id = request->identifier(); 514 int req_id = request->identifier();
513 InitRequestStatesIfNew(req_id); 515 InitRequestStatesIfNew(req_id);
514 event_order_[req_id] += "OnCompleted\n"; 516 event_order_[req_id] += "OnCompleted\n";
515 // Expect "Success -> (next_states_ & kStageCompletedSuccess)" 517 // Expect "Success -> (next_states_ & kStageCompletedSuccess)"
516 // is logically identical to 518 // is logically identical to
517 // Expect "!(Success) || (next_states_ & kStageCompletedSuccess)" 519 // Expect "!(Success) || (next_states_ & kStageCompletedSuccess)"
518 EXPECT_TRUE(!request->status().is_success() || 520 EXPECT_TRUE(!request->status().is_success() ||
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 URLRequestJob* job = main_intercept_job_; 629 URLRequestJob* job = main_intercept_job_;
628 main_intercept_job_ = NULL; 630 main_intercept_job_ = NULL;
629 return job; 631 return job;
630 } 632 }
631 633
632 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) { 634 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) {
633 main_intercept_job_ = job; 635 main_intercept_job_ = job;
634 } 636 }
635 637
636 } // namespace net 638 } // 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