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

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

Issue 6771043: Enabled actual transfer size in chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment added Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "grit/generated_resources.h" 7 #include "grit/generated_resources.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/http/http_response_headers.h" 9 #include "net/http/http_response_headers.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 GURL* new_first_party_for_cookies) { 72 GURL* new_first_party_for_cookies) {
73 NOTREACHED(); 73 NOTREACHED();
74 return false; 74 return false;
75 } 75 }
76 76
77 void SecurityFilterPeer::OnReceivedResponse( 77 void SecurityFilterPeer::OnReceivedResponse(
78 const webkit_glue::ResourceResponseInfo& info) { 78 const webkit_glue::ResourceResponseInfo& info) {
79 NOTREACHED(); 79 NOTREACHED();
80 } 80 }
81 81
82 void SecurityFilterPeer::OnReceivedData(const char* data, int len) { 82 void SecurityFilterPeer::OnReceivedData(const char* data,
83 int data_length,
84 int raw_data_length) {
83 NOTREACHED(); 85 NOTREACHED();
84 } 86 }
85 87
86 void SecurityFilterPeer::OnCompletedRequest(const net::URLRequestStatus& status, 88 void SecurityFilterPeer::OnCompletedRequest(const net::URLRequestStatus& status,
87 const std::string& security_info, 89 const std::string& security_info,
88 const base::Time& completion_time) { 90 const base::Time& completion_time) {
89 NOTREACHED(); 91 NOTREACHED();
90 } 92 }
91 93
92 // static 94 // static
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 132 }
131 133
132 BufferedPeer::~BufferedPeer() { 134 BufferedPeer::~BufferedPeer() {
133 } 135 }
134 136
135 void BufferedPeer::OnReceivedResponse( 137 void BufferedPeer::OnReceivedResponse(
136 const webkit_glue::ResourceResponseInfo& info) { 138 const webkit_glue::ResourceResponseInfo& info) {
137 ProcessResponseInfo(info, &response_info_, mime_type_); 139 ProcessResponseInfo(info, &response_info_, mime_type_);
138 } 140 }
139 141
140 void BufferedPeer::OnReceivedData(const char* data, int len) { 142 void BufferedPeer::OnReceivedData(const char* data,
141 data_.append(data, len); 143 int data_length,
144 int raw_data_length) {
145 data_.append(data, data_length);
142 } 146 }
143 147
144 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, 148 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status,
145 const std::string& security_info, 149 const std::string& security_info,
146 const base::Time& completion_time) { 150 const base::Time& completion_time) {
147 // Make sure we delete ourselves at the end of this call. 151 // Make sure we delete ourselves at the end of this call.
148 scoped_ptr<BufferedPeer> this_deleter(this); 152 scoped_ptr<BufferedPeer> this_deleter(this);
149 153
150 // Give sub-classes a chance at altering the data. 154 // Give sub-classes a chance at altering the data.
151 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { 155 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) {
152 // Pretend we failed to load the resource. 156 // Pretend we failed to load the resource.
153 original_peer_->OnReceivedResponse(response_info_); 157 original_peer_->OnReceivedResponse(response_info_);
154 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, 158 net::URLRequestStatus status(net::URLRequestStatus::CANCELED,
155 net::ERR_ABORTED); 159 net::ERR_ABORTED);
156 original_peer_->OnCompletedRequest(status, security_info, completion_time); 160 original_peer_->OnCompletedRequest(status, security_info, completion_time);
157 return; 161 return;
158 } 162 }
159 163
160 original_peer_->OnReceivedResponse(response_info_); 164 original_peer_->OnReceivedResponse(response_info_);
161 if (!data_.empty()) 165 if (!data_.empty())
162 original_peer_->OnReceivedData(data_.data(), 166 original_peer_->OnReceivedData(data_.data(),
163 static_cast<int>(data_.size())); 167 static_cast<int>(data_.size()),
168 -1);
164 original_peer_->OnCompletedRequest(status, security_info, completion_time); 169 original_peer_->OnCompletedRequest(status, security_info, completion_time);
165 } 170 }
166 171
167 //////////////////////////////////////////////////////////////////////////////// 172 ////////////////////////////////////////////////////////////////////////////////
168 // ReplaceContentPeer 173 // ReplaceContentPeer
169 174
170 ReplaceContentPeer::ReplaceContentPeer( 175 ReplaceContentPeer::ReplaceContentPeer(
171 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 176 webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
172 webkit_glue::ResourceLoaderBridge::Peer* peer, 177 webkit_glue::ResourceLoaderBridge::Peer* peer,
173 const std::string& mime_type, 178 const std::string& mime_type,
174 const std::string& data) 179 const std::string& data)
175 : SecurityFilterPeer(resource_loader_bridge, peer), 180 : SecurityFilterPeer(resource_loader_bridge, peer),
176 mime_type_(mime_type), 181 mime_type_(mime_type),
177 data_(data) { 182 data_(data) {
178 } 183 }
179 184
180 ReplaceContentPeer::~ReplaceContentPeer() { 185 ReplaceContentPeer::~ReplaceContentPeer() {
181 } 186 }
182 187
183 void ReplaceContentPeer::OnReceivedResponse( 188 void ReplaceContentPeer::OnReceivedResponse(
184 const webkit_glue::ResourceResponseInfo& info) { 189 const webkit_glue::ResourceResponseInfo& info) {
185 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 190 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
186 } 191 }
187 192
188 void ReplaceContentPeer::OnReceivedData(const char* data, int len) { 193 void ReplaceContentPeer::OnReceivedData(const char* data,
194 int data_length,
195 int raw_data_length) {
189 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 196 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
190 } 197 }
191 198
192 void ReplaceContentPeer::OnCompletedRequest( 199 void ReplaceContentPeer::OnCompletedRequest(
193 const net::URLRequestStatus& status, 200 const net::URLRequestStatus& status,
194 const std::string& security_info, 201 const std::string& security_info,
195 const base::Time& completion_time) { 202 const base::Time& completion_time) {
196 webkit_glue::ResourceResponseInfo info; 203 webkit_glue::ResourceResponseInfo info;
197 ProcessResponseInfo(info, &info, mime_type_); 204 ProcessResponseInfo(info, &info, mime_type_);
198 info.security_info = security_info; 205 info.security_info = security_info;
199 info.content_length = static_cast<int>(data_.size()); 206 info.content_length = static_cast<int>(data_.size());
200 original_peer_->OnReceivedResponse(info); 207 original_peer_->OnReceivedResponse(info);
201 if (!data_.empty()) 208 if (!data_.empty())
202 original_peer_->OnReceivedData(data_.data(), 209 original_peer_->OnReceivedData(data_.data(),
203 static_cast<int>(data_.size())); 210 static_cast<int>(data_.size()),
211 -1);
204 original_peer_->OnCompletedRequest(net::URLRequestStatus(), 212 original_peer_->OnCompletedRequest(net::URLRequestStatus(),
205 security_info, 213 security_info,
206 completion_time); 214 completion_time);
207 215
208 // The request processing is complete, we must delete ourselves. 216 // The request processing is complete, we must delete ourselves.
209 delete this; 217 delete this;
210 } 218 }
OLDNEW
« no previous file with comments | « chrome/renderer/security_filter_peer.h ('k') | content/browser/renderer_host/async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698