Chromium Code Reviews| 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 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 void TestURLLoaderClient::OnDataDownloaded(int64_t data_length, | 39 void TestURLLoaderClient::OnDataDownloaded(int64_t data_length, |
| 40 int64_t encoded_data_length) { | 40 int64_t encoded_data_length) { |
| 41 has_data_downloaded_ = true; | 41 has_data_downloaded_ = true; |
| 42 download_data_length_ += data_length; | 42 download_data_length_ += data_length; |
| 43 encoded_download_data_length_ += encoded_data_length; | 43 encoded_download_data_length_ += encoded_data_length; |
| 44 if (quit_closure_for_on_data_downloaded_) | 44 if (quit_closure_for_on_data_downloaded_) |
| 45 quit_closure_for_on_data_downloaded_.Run(); | 45 quit_closure_for_on_data_downloaded_.Run(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void TestURLLoaderClient::OnTransferSizeUpdated(int64_t transfer_size_diff) { | |
|
mmenke
2016/12/13 20:01:25
EXPECT_GT(transfer_size_diff, 0);?
yhirano
2016/12/14 16:47:27
Done.
| |
| 49 body_transfer_size_ += transfer_size_diff; | |
| 50 } | |
| 51 | |
| 48 void TestURLLoaderClient::OnStartLoadingResponseBody( | 52 void TestURLLoaderClient::OnStartLoadingResponseBody( |
| 49 mojo::ScopedDataPipeConsumerHandle body) { | 53 mojo::ScopedDataPipeConsumerHandle body) { |
| 50 response_body_ = std::move(body); | 54 response_body_ = std::move(body); |
| 51 if (quit_closure_for_on_start_loading_response_body_) | 55 if (quit_closure_for_on_start_loading_response_body_) |
| 52 quit_closure_for_on_start_loading_response_body_.Run(); | 56 quit_closure_for_on_start_loading_response_body_.Run(); |
| 53 } | 57 } |
| 54 | 58 |
| 55 void TestURLLoaderClient::OnComplete( | 59 void TestURLLoaderClient::OnComplete( |
| 56 const ResourceRequestCompletionStatus& status) { | 60 const ResourceRequestCompletionStatus& status) { |
| 57 has_received_completion_ = true; | 61 has_received_completion_ = true; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 void TestURLLoaderClient::RunUntilComplete() { | 114 void TestURLLoaderClient::RunUntilComplete() { |
| 111 if (has_received_completion_) | 115 if (has_received_completion_) |
| 112 return; | 116 return; |
| 113 base::RunLoop run_loop; | 117 base::RunLoop run_loop; |
| 114 quit_closure_for_on_complete_ = run_loop.QuitClosure(); | 118 quit_closure_for_on_complete_ = run_loop.QuitClosure(); |
| 115 run_loop.Run(); | 119 run_loop.Run(); |
| 116 quit_closure_for_on_complete_.Reset(); | 120 quit_closure_for_on_complete_.Reset(); |
| 117 } | 121 } |
| 118 | 122 |
| 119 } // namespace content | 123 } // namespace content |
| OLD | NEW |