Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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::OnRawBytesRead(const URLRequest& request, |
| 508 int bytes_read) { | 508 int bytes_read) { |
| 509 } | 509 } |
| 510 | 510 |
| 511 void TestNetworkDelegate::OnNetworkBytesReceived(const URLRequest& request, | |
| 512 int64 bytes_received) { | |
| 513 total_network_bytes_received_ += bytes_received; | |
|
tbansal1
2015/08/17 20:51:17
nit: May be add the event to event_order_ for easi
sclittle
2015/08/17 23:35:14
Done.
| |
| 514 } | |
| 515 | |
| 511 void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) { | 516 void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) { |
| 512 int req_id = request->identifier(); | 517 int req_id = request->identifier(); |
| 513 InitRequestStatesIfNew(req_id); | 518 InitRequestStatesIfNew(req_id); |
| 514 event_order_[req_id] += "OnCompleted\n"; | 519 event_order_[req_id] += "OnCompleted\n"; |
| 515 // Expect "Success -> (next_states_ & kStageCompletedSuccess)" | 520 // Expect "Success -> (next_states_ & kStageCompletedSuccess)" |
| 516 // is logically identical to | 521 // is logically identical to |
| 517 // Expect "!(Success) || (next_states_ & kStageCompletedSuccess)" | 522 // Expect "!(Success) || (next_states_ & kStageCompletedSuccess)" |
| 518 EXPECT_TRUE(!request->status().is_success() || | 523 EXPECT_TRUE(!request->status().is_success() || |
| 519 (next_states_[req_id] & kStageCompletedSuccess)) << | 524 (next_states_[req_id] & kStageCompletedSuccess)) << |
| 520 event_order_[req_id]; | 525 event_order_[req_id]; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 URLRequestJob* job = main_intercept_job_; | 632 URLRequestJob* job = main_intercept_job_; |
| 628 main_intercept_job_ = NULL; | 633 main_intercept_job_ = NULL; |
| 629 return job; | 634 return job; |
| 630 } | 635 } |
| 631 | 636 |
| 632 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) { | 637 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) { |
| 633 main_intercept_job_ = job; | 638 main_intercept_job_ = job; |
| 634 } | 639 } |
| 635 | 640 |
| 636 } // namespace net | 641 } // namespace net |
| OLD | NEW |