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

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

Issue 10640019: Remove the HANDLED_EXTERNALLY status code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed some minor issues Created 8 years, 6 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 (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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 NOTREACHED(); 83 NOTREACHED();
84 } 84 }
85 85
86 void SecurityFilterPeer::OnReceivedData(const char* data, 86 void SecurityFilterPeer::OnReceivedData(const char* data,
87 int data_length, 87 int data_length,
88 int encoded_data_length) { 88 int encoded_data_length) {
89 NOTREACHED(); 89 NOTREACHED();
90 } 90 }
91 91
92 void SecurityFilterPeer::OnCompletedRequest( 92 void SecurityFilterPeer::OnCompletedRequest(
93 const net::URLRequestStatus& status, 93 int error_code,
94 const std::string& security_info, 94 const std::string& security_info,
95 const base::TimeTicks& completion_time) { 95 const base::TimeTicks& completion_time) {
96 NOTREACHED(); 96 NOTREACHED();
97 } 97 }
98 98
99 // static 99 // static
100 void ProcessResponseInfo( 100 void ProcessResponseInfo(
101 const webkit_glue::ResourceResponseInfo& info_in, 101 const webkit_glue::ResourceResponseInfo& info_in,
102 webkit_glue::ResourceResponseInfo* info_out, 102 webkit_glue::ResourceResponseInfo* info_out,
103 const std::string& mime_type) { 103 const std::string& mime_type) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const webkit_glue::ResourceResponseInfo& info) { 143 const webkit_glue::ResourceResponseInfo& info) {
144 ProcessResponseInfo(info, &response_info_, mime_type_); 144 ProcessResponseInfo(info, &response_info_, mime_type_);
145 } 145 }
146 146
147 void BufferedPeer::OnReceivedData(const char* data, 147 void BufferedPeer::OnReceivedData(const char* data,
148 int data_length, 148 int data_length,
149 int encoded_data_length) { 149 int encoded_data_length) {
150 data_.append(data, data_length); 150 data_.append(data, data_length);
151 } 151 }
152 152
153 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, 153 void BufferedPeer::OnCompletedRequest(int error_code,
154 const std::string& security_info, 154 const std::string& security_info,
155 const base::TimeTicks& completion_time) { 155 const base::TimeTicks& completion_time) {
156 // Make sure we delete ourselves at the end of this call. 156 // Make sure we delete ourselves at the end of this call.
157 scoped_ptr<BufferedPeer> this_deleter(this); 157 scoped_ptr<BufferedPeer> this_deleter(this);
158 158
159 // Give sub-classes a chance at altering the data. 159 // Give sub-classes a chance at altering the data.
160 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { 160 if (!net::IsSuccess(error_code) || !DataReady()) {
161 // Pretend we failed to load the resource. 161 // Pretend we failed to load the resource.
162 original_peer_->OnReceivedResponse(response_info_); 162 original_peer_->OnReceivedResponse(response_info_);
163 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, 163 original_peer_->OnCompletedRequest(net::ERR_ABORTED, security_info,
164 net::ERR_ABORTED); 164 completion_time);
165 original_peer_->OnCompletedRequest(status, security_info, completion_time);
166 return; 165 return;
167 } 166 }
168 167
169 original_peer_->OnReceivedResponse(response_info_); 168 original_peer_->OnReceivedResponse(response_info_);
170 if (!data_.empty()) 169 if (!data_.empty())
171 original_peer_->OnReceivedData(data_.data(), 170 original_peer_->OnReceivedData(data_.data(),
172 static_cast<int>(data_.size()), 171 static_cast<int>(data_.size()),
173 -1); 172 -1);
174 original_peer_->OnCompletedRequest(status, security_info, completion_time); 173 original_peer_->OnCompletedRequest(error_code, security_info,
174 completion_time);
175 } 175 }
176 176
177 //////////////////////////////////////////////////////////////////////////////// 177 ////////////////////////////////////////////////////////////////////////////////
178 // ReplaceContentPeer 178 // ReplaceContentPeer
179 179
180 ReplaceContentPeer::ReplaceContentPeer( 180 ReplaceContentPeer::ReplaceContentPeer(
181 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 181 webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
182 webkit_glue::ResourceLoaderBridge::Peer* peer, 182 webkit_glue::ResourceLoaderBridge::Peer* peer,
183 const std::string& mime_type, 183 const std::string& mime_type,
184 const std::string& data) 184 const std::string& data)
(...skipping 10 matching lines...) Expand all
195 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 195 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
196 } 196 }
197 197
198 void ReplaceContentPeer::OnReceivedData(const char* data, 198 void ReplaceContentPeer::OnReceivedData(const char* data,
199 int data_length, 199 int data_length,
200 int encoded_data_length) { 200 int encoded_data_length) {
201 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 201 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
202 } 202 }
203 203
204 void ReplaceContentPeer::OnCompletedRequest( 204 void ReplaceContentPeer::OnCompletedRequest(
205 const net::URLRequestStatus& status, 205 int error_code,
206 const std::string& security_info, 206 const std::string& security_info,
207 const base::TimeTicks& completion_time) { 207 const base::TimeTicks& completion_time) {
208 webkit_glue::ResourceResponseInfo info; 208 webkit_glue::ResourceResponseInfo info;
209 ProcessResponseInfo(info, &info, mime_type_); 209 ProcessResponseInfo(info, &info, mime_type_);
210 info.security_info = security_info; 210 info.security_info = security_info;
211 info.content_length = static_cast<int>(data_.size()); 211 info.content_length = static_cast<int>(data_.size());
212 original_peer_->OnReceivedResponse(info); 212 original_peer_->OnReceivedResponse(info);
213 if (!data_.empty()) 213 if (!data_.empty())
214 original_peer_->OnReceivedData(data_.data(), 214 original_peer_->OnReceivedData(data_.data(),
215 static_cast<int>(data_.size()), 215 static_cast<int>(data_.size()),
216 -1); 216 -1);
217 original_peer_->OnCompletedRequest(net::URLRequestStatus(), 217 original_peer_->OnCompletedRequest(net::OK,
218 security_info, 218 security_info,
219 completion_time); 219 completion_time);
220 220
221 // The request processing is complete, we must delete ourselves. 221 // The request processing is complete, we must delete ourselves.
222 delete this; 222 delete this;
223 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698