| 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_url_loader_client.h" | 5 #include "content/browser/loader/test_url_loader_client.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 TestURLLoaderClient::TestURLLoaderClient() : binding_(this) {} | 13 TestURLLoaderClient::TestURLLoaderClient() : binding_(this) {} |
| 14 TestURLLoaderClient::~TestURLLoaderClient() {} | 14 TestURLLoaderClient::~TestURLLoaderClient() {} |
| 15 | 15 |
| 16 void TestURLLoaderClient::OnReceiveResponse( | 16 void TestURLLoaderClient::OnReceiveResponse( |
| 17 const ResourceResponseHead& response_head, | 17 const ResourceResponseHead& response_head, |
| 18 mojom::DownloadedTempFilePtr downloaded_file) { | 18 mojom::DownloadedTempFileAssociatedPtrInfo downloaded_file) { |
| 19 EXPECT_FALSE(has_received_response_); | 19 EXPECT_FALSE(has_received_response_); |
| 20 EXPECT_FALSE(has_received_cached_metadata_); | 20 EXPECT_FALSE(has_received_cached_metadata_); |
| 21 EXPECT_FALSE(has_received_completion_); | 21 EXPECT_FALSE(has_received_completion_); |
| 22 has_received_response_ = true; | 22 has_received_response_ = true; |
| 23 response_head_ = response_head; | 23 response_head_ = response_head; |
| 24 if (quit_closure_for_on_receive_response_) | 24 if (quit_closure_for_on_receive_response_) |
| 25 quit_closure_for_on_receive_response_.Run(); | 25 quit_closure_for_on_receive_response_.Run(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void TestURLLoaderClient::OnReceiveRedirect( | 28 void TestURLLoaderClient::OnReceiveRedirect( |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void TestURLLoaderClient::RunUntilComplete() { | 154 void TestURLLoaderClient::RunUntilComplete() { |
| 155 if (has_received_completion_) | 155 if (has_received_completion_) |
| 156 return; | 156 return; |
| 157 base::RunLoop run_loop; | 157 base::RunLoop run_loop; |
| 158 quit_closure_for_on_complete_ = run_loop.QuitClosure(); | 158 quit_closure_for_on_complete_ = run_loop.QuitClosure(); |
| 159 run_loop.Run(); | 159 run_loop.Run(); |
| 160 quit_closure_for_on_complete_.Reset(); | 160 quit_closure_for_on_complete_.Reset(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace content | 163 } // namespace content |
| OLD | NEW |