| 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/http/http_response_body_drainer.h" | 5 #include "net/http/http_response_body_drainer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" |
| 17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 #include "net/base/test_completion_callback.h" | 22 #include "net/base/test_completion_callback.h" |
| 22 #include "net/cert/ct_policy_enforcer.h" | 23 #include "net/cert/ct_policy_enforcer.h" |
| 23 #include "net/cert/mock_cert_verifier.h" | 24 #include "net/cert/mock_cert_verifier.h" |
| 24 #include "net/cert/multi_log_ct_verifier.h" | 25 #include "net/cert/multi_log_ct_verifier.h" |
| 25 #include "net/http/http_network_session.h" | 26 #include "net/http/http_network_session.h" |
| 26 #include "net/http/http_server_properties_impl.h" | 27 #include "net/http/http_server_properties_impl.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 public: | 44 public: |
| 44 CloseResultWaiter() | 45 CloseResultWaiter() |
| 45 : result_(false), | 46 : result_(false), |
| 46 have_result_(false), | 47 have_result_(false), |
| 47 waiting_for_result_(false) {} | 48 waiting_for_result_(false) {} |
| 48 | 49 |
| 49 int WaitForResult() { | 50 int WaitForResult() { |
| 50 CHECK(!waiting_for_result_); | 51 CHECK(!waiting_for_result_); |
| 51 while (!have_result_) { | 52 while (!have_result_) { |
| 52 waiting_for_result_ = true; | 53 waiting_for_result_ = true; |
| 53 base::MessageLoop::current()->Run(); | 54 base::RunLoop().Run(); |
| 54 waiting_for_result_ = false; | 55 waiting_for_result_ = false; |
| 55 } | 56 } |
| 56 return result_; | 57 return result_; |
| 57 } | 58 } |
| 58 | 59 |
| 59 void set_result(bool result) { | 60 void set_result(bool result) { |
| 60 result_ = result; | 61 result_ = result; |
| 61 have_result_ = true; | 62 have_result_ = true; |
| 62 if (waiting_for_result_) | 63 if (waiting_for_result_) |
| 63 base::MessageLoop::current()->QuitWhenIdle(); | 64 base::MessageLoop::current()->QuitWhenIdle(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 TEST_F(HttpResponseBodyDrainerTest, DrainBodyCantReuse) { | 337 TEST_F(HttpResponseBodyDrainerTest, DrainBodyCantReuse) { |
| 337 mock_stream_->set_num_chunks(1); | 338 mock_stream_->set_num_chunks(1); |
| 338 mock_stream_->set_can_reuse_connection(false); | 339 mock_stream_->set_can_reuse_connection(false); |
| 339 drainer_->Start(session_.get()); | 340 drainer_->Start(session_.get()); |
| 340 EXPECT_TRUE(result_waiter_.WaitForResult()); | 341 EXPECT_TRUE(result_waiter_.WaitForResult()); |
| 341 } | 342 } |
| 342 | 343 |
| 343 } // namespace | 344 } // namespace |
| 344 | 345 |
| 345 } // namespace net | 346 } // namespace net |
| OLD | NEW |