OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/loader/test_resource_handler.h" | 5 #include "content/browser/loader/test_resource_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/loader/resource_controller.h" | 8 #include "content/browser/loader/resource_controller.h" |
9 #include "content/public/common/resource_response.h" | 9 #include "content/public/common/resource_response.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 DISALLOW_COPY_AND_ASSIGN(ScopedCallDepthTracker); | 31 DISALLOW_COPY_AND_ASSIGN(ScopedCallDepthTracker); |
32 }; | 32 }; |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 TestResourceHandler::TestResourceHandler(net::URLRequestStatus* request_status, | 36 TestResourceHandler::TestResourceHandler(net::URLRequestStatus* request_status, |
37 std::string* body) | 37 std::string* body) |
38 : ResourceHandler(nullptr), | 38 : ResourceHandler(nullptr), |
39 request_status_ptr_(request_status), | 39 request_status_ptr_(request_status), |
40 body_ptr_(body), | 40 body_ptr_(body), |
41 deferred_run_loop_(new base::RunLoop()) { | 41 deferred_run_loop_(new base::RunLoop()), |
| 42 weak_ptr_factory_(this) { |
42 SetBufferSize(2048); | 43 SetBufferSize(2048); |
43 } | 44 } |
44 | 45 |
45 TestResourceHandler::TestResourceHandler() | 46 TestResourceHandler::TestResourceHandler() |
46 : TestResourceHandler(nullptr, nullptr) {} | 47 : TestResourceHandler(nullptr, nullptr) {} |
47 | 48 |
48 TestResourceHandler::~TestResourceHandler() {} | 49 TestResourceHandler::~TestResourceHandler() {} |
49 | 50 |
50 void TestResourceHandler::SetController(ResourceController* controller) { | 51 void TestResourceHandler::SetController(ResourceController* controller) { |
51 controller_ = controller; | 52 controller_ = controller; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 224 |
224 void TestResourceHandler::WaitUntilDeferred() { | 225 void TestResourceHandler::WaitUntilDeferred() { |
225 deferred_run_loop_->Run(); | 226 deferred_run_loop_->Run(); |
226 deferred_run_loop_.reset(new base::RunLoop()); | 227 deferred_run_loop_.reset(new base::RunLoop()); |
227 } | 228 } |
228 | 229 |
229 void TestResourceHandler::WaitUntilResponseComplete() { | 230 void TestResourceHandler::WaitUntilResponseComplete() { |
230 response_complete_run_loop_.Run(); | 231 response_complete_run_loop_.Run(); |
231 } | 232 } |
232 | 233 |
| 234 base::WeakPtr<TestResourceHandler> TestResourceHandler::GetWeakPtr() { |
| 235 return weak_ptr_factory_.GetWeakPtr(); |
| 236 } |
| 237 |
233 } // namespace content | 238 } // namespace content |
OLD | NEW |