Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: content/browser/loader/test_url_loader_client.cc

Issue 2574143003: Implement upload progress handling in Mojo loading (Closed)
Patch Set: +content_browsertests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 std::string(reinterpret_cast<const char*>(data.data()), data.size()); 55 std::string(reinterpret_cast<const char*>(data.data()), data.size());
56 if (quit_closure_for_on_receive_cached_metadata_) 56 if (quit_closure_for_on_receive_cached_metadata_)
57 quit_closure_for_on_receive_cached_metadata_.Run(); 57 quit_closure_for_on_receive_cached_metadata_.Run();
58 } 58 }
59 59
60 void TestURLLoaderClient::OnTransferSizeUpdated(int32_t transfer_size_diff) { 60 void TestURLLoaderClient::OnTransferSizeUpdated(int32_t transfer_size_diff) {
61 EXPECT_GT(transfer_size_diff, 0); 61 EXPECT_GT(transfer_size_diff, 0);
62 body_transfer_size_ += transfer_size_diff; 62 body_transfer_size_ += transfer_size_diff;
63 } 63 }
64 64
65 void TestURLLoaderClient::OnUploadProgress(int64_t current_position,
66 int64_t total_size,
67 const base::Closure& ack_callback) {
mmenke 2017/01/18 17:00:46 Have sanity checks here? Haven't received redirec
tzik 2017/01/19 11:53:09 Done.
68 current_upload_position_ = current_position;
69 total_upload_size_ = total_size;
70 ack_callback.Run();
71 }
72
65 void TestURLLoaderClient::OnStartLoadingResponseBody( 73 void TestURLLoaderClient::OnStartLoadingResponseBody(
66 mojo::ScopedDataPipeConsumerHandle body) { 74 mojo::ScopedDataPipeConsumerHandle body) {
67 response_body_ = std::move(body); 75 response_body_ = std::move(body);
68 if (quit_closure_for_on_start_loading_response_body_) 76 if (quit_closure_for_on_start_loading_response_body_)
69 quit_closure_for_on_start_loading_response_body_.Run(); 77 quit_closure_for_on_start_loading_response_body_.Run();
70 } 78 }
71 79
72 void TestURLLoaderClient::OnComplete( 80 void TestURLLoaderClient::OnComplete(
73 const ResourceRequestCompletionStatus& status) { 81 const ResourceRequestCompletionStatus& status) {
74 has_received_completion_ = true; 82 has_received_completion_ = true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void TestURLLoaderClient::RunUntilComplete() { 150 void TestURLLoaderClient::RunUntilComplete() {
143 if (has_received_completion_) 151 if (has_received_completion_)
144 return; 152 return;
145 base::RunLoop run_loop; 153 base::RunLoop run_loop;
146 quit_closure_for_on_complete_ = run_loop.QuitClosure(); 154 quit_closure_for_on_complete_ = run_loop.QuitClosure();
147 run_loop.Run(); 155 run_loop.Run();
148 quit_closure_for_on_complete_.Reset(); 156 quit_closure_for_on_complete_.Reset();
149 } 157 }
150 158
151 } // namespace content 159 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698