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

Side by Side Diff: chrome/renderer/security_filter_peer.cc

Issue 2510333002: Send encoded_body_length to renderer when response completed (2/3) (Closed)
Patch Set: rebase Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/security_filter_peer.h" 5 #include "chrome/renderer/security_filter_peer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 void BufferedPeer::OnReceivedData(std::unique_ptr<ReceivedData> data) { 129 void BufferedPeer::OnReceivedData(std::unique_ptr<ReceivedData> data) {
130 data_.append(data->payload(), data->length()); 130 data_.append(data->payload(), data->length());
131 } 131 }
132 132
133 void BufferedPeer::OnCompletedRequest(int error_code, 133 void BufferedPeer::OnCompletedRequest(int error_code,
134 bool was_ignored_by_handler, 134 bool was_ignored_by_handler,
135 bool stale_copy_in_cache, 135 bool stale_copy_in_cache,
136 const base::TimeTicks& completion_time, 136 const base::TimeTicks& completion_time,
137 int64_t total_transfer_size) { 137 int64_t total_transfer_size,
138 int64_t encoded_body_size) {
138 // Give sub-classes a chance at altering the data. 139 // Give sub-classes a chance at altering the data.
139 if (error_code != net::OK || !DataReady()) { 140 if (error_code != net::OK || !DataReady()) {
140 // Pretend we failed to load the resource. 141 // Pretend we failed to load the resource.
141 original_peer_->OnReceivedResponse(response_info_); 142 original_peer_->OnReceivedResponse(response_info_);
142 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, 143 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false,
143 stale_copy_in_cache, completion_time, 144 stale_copy_in_cache, completion_time,
144 total_transfer_size); 145 total_transfer_size, encoded_body_size);
145 return; 146 return;
146 } 147 }
147 148
148 original_peer_->OnReceivedResponse(response_info_); 149 original_peer_->OnReceivedResponse(response_info_);
149 if (!data_.empty()) { 150 if (!data_.empty()) {
150 original_peer_->OnReceivedData(base::MakeUnique<content::FixedReceivedData>( 151 original_peer_->OnReceivedData(base::MakeUnique<content::FixedReceivedData>(
151 data_.data(), data_.size(), -1, 0)); 152 data_.data(), data_.size(), -1));
152 } 153 }
153 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, 154 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler,
154 stale_copy_in_cache, completion_time, 155 stale_copy_in_cache, completion_time,
155 total_transfer_size); 156 total_transfer_size, encoded_body_size);
156 } 157 }
157 158
158 //////////////////////////////////////////////////////////////////////////////// 159 ////////////////////////////////////////////////////////////////////////////////
159 // ReplaceContentPeer 160 // ReplaceContentPeer
160 161
161 ReplaceContentPeer::ReplaceContentPeer( 162 ReplaceContentPeer::ReplaceContentPeer(
162 std::unique_ptr<content::RequestPeer> peer, 163 std::unique_ptr<content::RequestPeer> peer,
163 const std::string& mime_type, 164 const std::string& mime_type,
164 const std::string& data) 165 const std::string& data)
165 : SecurityFilterPeer(std::move(peer)), mime_type_(mime_type), data_(data) {} 166 : SecurityFilterPeer(std::move(peer)), mime_type_(mime_type), data_(data) {}
166 167
167 ReplaceContentPeer::~ReplaceContentPeer() { 168 ReplaceContentPeer::~ReplaceContentPeer() {
168 } 169 }
169 170
170 void ReplaceContentPeer::OnReceivedResponse( 171 void ReplaceContentPeer::OnReceivedResponse(
171 const content::ResourceResponseInfo& info) { 172 const content::ResourceResponseInfo& info) {
172 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 173 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
173 } 174 }
174 175
175 void ReplaceContentPeer::OnReceivedData(std::unique_ptr<ReceivedData> data) { 176 void ReplaceContentPeer::OnReceivedData(std::unique_ptr<ReceivedData> data) {
176 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 177 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
177 } 178 }
178 179
179 void ReplaceContentPeer::OnCompletedRequest( 180 void ReplaceContentPeer::OnCompletedRequest(
180 int error_code, 181 int error_code,
181 bool was_ignored_by_handler, 182 bool was_ignored_by_handler,
182 bool stale_copy_in_cache, 183 bool stale_copy_in_cache,
183 const base::TimeTicks& completion_time, 184 const base::TimeTicks& completion_time,
184 int64_t total_transfer_size) { 185 int64_t total_transfer_size,
186 int64_t encoded_body_size) {
185 content::ResourceResponseInfo info; 187 content::ResourceResponseInfo info;
186 ProcessResponseInfo(info, &info, mime_type_); 188 ProcessResponseInfo(info, &info, mime_type_);
187 info.content_length = static_cast<int>(data_.size()); 189 info.content_length = static_cast<int>(data_.size());
188 original_peer_->OnReceivedResponse(info); 190 original_peer_->OnReceivedResponse(info);
189 if (!data_.empty()) { 191 if (!data_.empty()) {
190 original_peer_->OnReceivedData(base::MakeUnique<content::FixedReceivedData>( 192 original_peer_->OnReceivedData(base::MakeUnique<content::FixedReceivedData>(
191 data_.data(), data_.size(), -1, 0)); 193 data_.data(), data_.size(), -1));
192 } 194 }
193 original_peer_->OnCompletedRequest(net::OK, false, stale_copy_in_cache, 195 original_peer_->OnCompletedRequest(net::OK, false, stale_copy_in_cache,
194 completion_time, total_transfer_size); 196 completion_time, total_transfer_size,
197 encoded_body_size);
195 } 198 }
OLDNEW
« no previous file with comments | « chrome/renderer/security_filter_peer.h ('k') | content/child/ftp_directory_listing_response_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698