| 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 EXPECT_TRUE(next_states_[req_id] & kStageAuthRequired) << | 486 EXPECT_TRUE(next_states_[req_id] & kStageAuthRequired) << |
| 487 event_order_[req_id]; | 487 event_order_[req_id]; |
| 488 next_states_[req_id] = kStageBeforeSendHeaders | | 488 next_states_[req_id] = kStageBeforeSendHeaders | |
| 489 kStageHeadersReceived | // Request canceled by delegate simulates empty | 489 kStageHeadersReceived | // Request canceled by delegate simulates empty |
| 490 // response. | 490 // response. |
| 491 kStageResponseStarted | // data: URLs do not trigger sending headers | 491 kStageResponseStarted | // data: URLs do not trigger sending headers |
| 492 kStageBeforeRedirect; // a delegate can trigger a redirection | 492 kStageBeforeRedirect; // a delegate can trigger a redirection |
| 493 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 493 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
| 494 } | 494 } |
| 495 | 495 |
| 496 bool TestNetworkDelegate::CanGetCookies(const net::URLRequest* request, | 496 bool TestNetworkDelegate::OnCanGetCookies(const net::URLRequest& request, |
| 497 const net::CookieList& cookie_list) { | 497 const net::CookieList& cookie_list) { |
| 498 bool allow = true; | 498 bool allow = true; |
| 499 if (cookie_options_bit_mask_ & NO_GET_COOKIES) | 499 if (cookie_options_bit_mask_ & NO_GET_COOKIES) |
| 500 allow = false; | 500 allow = false; |
| 501 | 501 |
| 502 if (!allow) { | 502 if (!allow) { |
| 503 blocked_get_cookies_count_++; | 503 blocked_get_cookies_count_++; |
| 504 } | 504 } |
| 505 | 505 |
| 506 return allow; | 506 return allow; |
| 507 } | 507 } |
| 508 | 508 |
| 509 bool TestNetworkDelegate::CanSetCookie(const net::URLRequest* request, | 509 bool TestNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, |
| 510 const std::string& cookie_line, | 510 const std::string& cookie_line, |
| 511 net::CookieOptions* options) { | 511 net::CookieOptions* options) { |
| 512 bool allow = true; | 512 bool allow = true; |
| 513 if (cookie_options_bit_mask_ & NO_SET_COOKIE) | 513 if (cookie_options_bit_mask_ & NO_SET_COOKIE) |
| 514 allow = false; | 514 allow = false; |
| 515 | 515 |
| 516 if (cookie_options_bit_mask_ & FORCE_SESSION) | 516 if (cookie_options_bit_mask_ & FORCE_SESSION) |
| 517 options->set_force_session(); | 517 options->set_force_session(); |
| 518 | 518 |
| 519 if (!allow) { | 519 if (!allow) { |
| 520 blocked_set_cookie_count_++; | 520 blocked_set_cookie_count_++; |
| 521 } else { | 521 } else { |
| 522 set_cookie_count_++; | 522 set_cookie_count_++; |
| 523 } | 523 } |
| 524 | 524 |
| 525 return allow; | 525 return allow; |
| 526 } | 526 } |
| 527 | 527 |
| 528 bool TestNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, |
| 529 const FilePath& path) const { |
| 530 return true; |
| 531 } |
| 532 |
| 528 // static | 533 // static |
| 529 std::string ScopedCustomUrlRequestTestHttpHost::value_("127.0.0.1"); | 534 std::string ScopedCustomUrlRequestTestHttpHost::value_("127.0.0.1"); |
| 530 | 535 |
| 531 ScopedCustomUrlRequestTestHttpHost::ScopedCustomUrlRequestTestHttpHost( | 536 ScopedCustomUrlRequestTestHttpHost::ScopedCustomUrlRequestTestHttpHost( |
| 532 const std::string& new_value) | 537 const std::string& new_value) |
| 533 : old_value_(value_), | 538 : old_value_(value_), |
| 534 new_value_(new_value) { | 539 new_value_(new_value) { |
| 535 value_ = new_value_; | 540 value_ = new_value_; |
| 536 } | 541 } |
| 537 | 542 |
| 538 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() { | 543 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() { |
| 539 DCHECK_EQ(value_, new_value_); | 544 DCHECK_EQ(value_, new_value_); |
| 540 value_ = old_value_; | 545 value_ = old_value_; |
| 541 } | 546 } |
| 542 | 547 |
| 543 // static | 548 // static |
| 544 const std::string& ScopedCustomUrlRequestTestHttpHost::value() { | 549 const std::string& ScopedCustomUrlRequestTestHttpHost::value() { |
| 545 return value_; | 550 return value_; |
| 546 } | 551 } |
| OLD | NEW |