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

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

Issue 2629513003: Implement CachedMetadata handling on MojoAsyncResourceHandler (Closed)
Patch Set: rebase 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 27 matching lines...) Expand all
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::OnReceiveCachedMetadata(
49 const std::vector<uint8_t>& data) {
mmenke 2017/01/17 18:39:57 EXPECT_FALSE(has_received_cached_metadata_); EXPEC
yhirano 2017/01/18 06:22:42 I added former ones. I'll add latter ones in https
50 has_received_cached_metadata_ = true;
51 cached_metadata_ = data;
52 if (quit_closure_for_on_receive_cached_metadata_)
53 quit_closure_for_on_receive_cached_metadata_.Run();
54 }
55
48 void TestURLLoaderClient::OnTransferSizeUpdated(int32_t transfer_size_diff) { 56 void TestURLLoaderClient::OnTransferSizeUpdated(int32_t transfer_size_diff) {
49 EXPECT_GT(transfer_size_diff, 0); 57 EXPECT_GT(transfer_size_diff, 0);
50 body_transfer_size_ += transfer_size_diff; 58 body_transfer_size_ += transfer_size_diff;
51 } 59 }
52 60
53 void TestURLLoaderClient::OnStartLoadingResponseBody( 61 void TestURLLoaderClient::OnStartLoadingResponseBody(
54 mojo::ScopedDataPipeConsumerHandle body) { 62 mojo::ScopedDataPipeConsumerHandle body) {
55 response_body_ = std::move(body); 63 response_body_ = std::move(body);
56 if (quit_closure_for_on_start_loading_response_body_) 64 if (quit_closure_for_on_start_loading_response_body_)
57 quit_closure_for_on_start_loading_response_body_.Run(); 65 quit_closure_for_on_start_loading_response_body_.Run();
(...skipping 18 matching lines...) Expand all
76 binding_.Bind(&client_ptr_info, associated_group); 84 binding_.Bind(&client_ptr_info, associated_group);
77 return client_ptr_info; 85 return client_ptr_info;
78 } 86 }
79 87
80 void TestURLLoaderClient::Unbind() { 88 void TestURLLoaderClient::Unbind() {
81 binding_.Unbind(); 89 binding_.Unbind();
82 response_body_.reset(); 90 response_body_.reset();
83 } 91 }
84 92
85 void TestURLLoaderClient::RunUntilResponseReceived() { 93 void TestURLLoaderClient::RunUntilResponseReceived() {
94 if (has_received_response_)
95 return;
86 base::RunLoop run_loop; 96 base::RunLoop run_loop;
87 quit_closure_for_on_receive_response_ = run_loop.QuitClosure(); 97 quit_closure_for_on_receive_response_ = run_loop.QuitClosure();
88 run_loop.Run(); 98 run_loop.Run();
89 quit_closure_for_on_receive_response_.Reset(); 99 quit_closure_for_on_receive_response_.Reset();
90 } 100 }
91 101
92 void TestURLLoaderClient::RunUntilRedirectReceived() { 102 void TestURLLoaderClient::RunUntilRedirectReceived() {
103 if (has_received_redirect_)
104 return;
93 base::RunLoop run_loop; 105 base::RunLoop run_loop;
94 quit_closure_for_on_receive_redirect_ = run_loop.QuitClosure(); 106 quit_closure_for_on_receive_redirect_ = run_loop.QuitClosure();
95 run_loop.Run(); 107 run_loop.Run();
96 quit_closure_for_on_receive_redirect_.Reset(); 108 quit_closure_for_on_receive_redirect_.Reset();
97 } 109 }
98 110
99 void TestURLLoaderClient::RunUntilDataDownloaded() { 111 void TestURLLoaderClient::RunUntilDataDownloaded() {
112 if (has_data_downloaded_)
113 return;
100 base::RunLoop run_loop; 114 base::RunLoop run_loop;
101 quit_closure_for_on_data_downloaded_ = run_loop.QuitClosure(); 115 quit_closure_for_on_data_downloaded_ = run_loop.QuitClosure();
102 run_loop.Run(); 116 run_loop.Run();
103 quit_closure_for_on_data_downloaded_.Reset(); 117 quit_closure_for_on_data_downloaded_.Reset();
104 } 118 }
105 119
120 void TestURLLoaderClient::RunUntilCachedMetadataReceived() {
121 if (has_received_cached_metadata_)
122 return;
123 base::RunLoop run_loop;
124 quit_closure_for_on_receive_cached_metadata_ = run_loop.QuitClosure();
125 run_loop.Run();
126 quit_closure_for_on_receive_cached_metadata_.Reset();
127 }
128
106 void TestURLLoaderClient::RunUntilResponseBodyArrived() { 129 void TestURLLoaderClient::RunUntilResponseBodyArrived() {
107 if (response_body_.is_valid()) 130 if (response_body_.is_valid())
108 return; 131 return;
109 base::RunLoop run_loop; 132 base::RunLoop run_loop;
110 quit_closure_for_on_start_loading_response_body_ = run_loop.QuitClosure(); 133 quit_closure_for_on_start_loading_response_body_ = run_loop.QuitClosure();
111 run_loop.Run(); 134 run_loop.Run();
112 quit_closure_for_on_start_loading_response_body_.Reset(); 135 quit_closure_for_on_start_loading_response_body_.Reset();
113 } 136 }
114 137
115 void TestURLLoaderClient::RunUntilComplete() { 138 void TestURLLoaderClient::RunUntilComplete() {
116 if (has_received_completion_) 139 if (has_received_completion_)
117 return; 140 return;
118 base::RunLoop run_loop; 141 base::RunLoop run_loop;
119 quit_closure_for_on_complete_ = run_loop.QuitClosure(); 142 quit_closure_for_on_complete_ = run_loop.QuitClosure();
120 run_loop.Run(); 143 run_loop.Run();
121 quit_closure_for_on_complete_.Reset(); 144 quit_closure_for_on_complete_.Reset();
122 } 145 }
123 146
124 } // namespace content 147 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698