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 "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "content/browser/loader/resource_controller.h" | 9 #include "content/browser/loader/resource_controller.h" |
10 #include "content/public/common/resource_response.h" | 10 #include "content/public/common/resource_response.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 defer_on_will_start_ = false; | 135 defer_on_will_start_ = false; |
136 HoldController(std::move(controller)); | 136 HoldController(std::move(controller)); |
137 deferred_run_loop_->Quit(); | 137 deferred_run_loop_->Quit(); |
138 return; | 138 return; |
139 } | 139 } |
140 | 140 |
141 controller->Resume(); | 141 controller->Resume(); |
142 } | 142 } |
143 | 143 |
144 bool TestResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 144 bool TestResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
145 int* buf_size, | 145 int* buf_size) { |
146 int min_size) { | |
147 EXPECT_FALSE(canceled_); | 146 EXPECT_FALSE(canceled_); |
148 EXPECT_FALSE(expect_on_data_downloaded_); | 147 EXPECT_FALSE(expect_on_data_downloaded_); |
149 EXPECT_EQ(0, on_response_completed_called_); | 148 EXPECT_EQ(0, on_response_completed_called_); |
150 // Only create a ScopedCallDepthTracker if not called re-entrantly, as | 149 // Only create a ScopedCallDepthTracker if not called re-entrantly, as |
151 // OnWillRead may be called synchronously in response to a Resume(), but | 150 // OnWillRead may be called synchronously in response to a Resume(), but |
152 // nothing may be called synchronously in response to the OnWillRead call. | 151 // nothing may be called synchronously in response to the OnWillRead call. |
153 std::unique_ptr<ScopedCallDepthTracker> call_depth_tracker; | 152 std::unique_ptr<ScopedCallDepthTracker> call_depth_tracker; |
154 if (call_depth_ == 0) | 153 if (call_depth_ == 0) |
155 call_depth_tracker = base::MakeUnique<ScopedCallDepthTracker>(&call_depth_); | 154 call_depth_tracker = base::MakeUnique<ScopedCallDepthTracker>(&call_depth_); |
156 | 155 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 264 |
266 void TestResourceHandler::WaitUntilResponseComplete() { | 265 void TestResourceHandler::WaitUntilResponseComplete() { |
267 response_complete_run_loop_.Run(); | 266 response_complete_run_loop_.Run(); |
268 } | 267 } |
269 | 268 |
270 base::WeakPtr<TestResourceHandler> TestResourceHandler::GetWeakPtr() { | 269 base::WeakPtr<TestResourceHandler> TestResourceHandler::GetWeakPtr() { |
271 return weak_ptr_factory_.GetWeakPtr(); | 270 return weak_ptr_factory_.GetWeakPtr(); |
272 } | 271 } |
273 | 272 |
274 } // namespace content | 273 } // namespace content |
OLD | NEW |