| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 *defer = defer_on_response_completed_; | 195 *defer = defer_on_response_completed_; |
| 196 defer_on_response_completed_ = false; | 196 defer_on_response_completed_ = false; |
| 197 | 197 |
| 198 if (*defer) | 198 if (*defer) |
| 199 deferred_run_loop_->Quit(); | 199 deferred_run_loop_->Quit(); |
| 200 response_complete_run_loop_.Quit(); | 200 response_complete_run_loop_.Quit(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void TestResourceHandler::OnDataDownloaded(int bytes_downloaded) { | 203 void TestResourceHandler::OnDataDownloaded(int bytes_downloaded) { |
| 204 EXPECT_TRUE(expect_on_data_downloaded_); | 204 EXPECT_TRUE(expect_on_data_downloaded_); |
| 205 EXPECT_EQ(1, on_will_start_called_); |
| 206 EXPECT_EQ(1, on_response_started_called_); |
| 207 EXPECT_EQ(0, on_response_completed_called_); |
| 208 |
| 205 total_bytes_downloaded_ += bytes_downloaded; | 209 total_bytes_downloaded_ += bytes_downloaded; |
| 206 } | 210 } |
| 207 | 211 |
| 208 void TestResourceHandler::Resume() { | 212 void TestResourceHandler::Resume() { |
| 209 ScopedCallDepthTracker call_depth_tracker(&call_depth_); | 213 ScopedCallDepthTracker call_depth_tracker(&call_depth_); |
| 210 controller_->Resume(); | 214 controller_->Resume(); |
| 211 } | 215 } |
| 212 | 216 |
| 213 void TestResourceHandler::CancelWithError(net::Error net_error) { | 217 void TestResourceHandler::CancelWithError(net::Error net_error) { |
| 214 ScopedCallDepthTracker call_depth_tracker(&call_depth_); | 218 ScopedCallDepthTracker call_depth_tracker(&call_depth_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 229 | 233 |
| 230 void TestResourceHandler::WaitUntilResponseComplete() { | 234 void TestResourceHandler::WaitUntilResponseComplete() { |
| 231 response_complete_run_loop_.Run(); | 235 response_complete_run_loop_.Run(); |
| 232 } | 236 } |
| 233 | 237 |
| 234 base::WeakPtr<TestResourceHandler> TestResourceHandler::GetWeakPtr() { | 238 base::WeakPtr<TestResourceHandler> TestResourceHandler::GetWeakPtr() { |
| 235 return weak_ptr_factory_.GetWeakPtr(); | 239 return weak_ptr_factory_.GetWeakPtr(); |
| 236 } | 240 } |
| 237 | 241 |
| 238 } // namespace content | 242 } // namespace content |
| OLD | NEW |