OLD | NEW |
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 "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "grit/generated_resources.h" | 8 #include "grit/generated_resources.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const webkit_glue::ResourceResponseInfo& info) { | 80 const webkit_glue::ResourceResponseInfo& info) { |
81 NOTREACHED(); | 81 NOTREACHED(); |
82 } | 82 } |
83 | 83 |
84 void SecurityFilterPeer::OnReceivedData(const char* data, | 84 void SecurityFilterPeer::OnReceivedData(const char* data, |
85 int data_length, | 85 int data_length, |
86 int encoded_data_length) { | 86 int encoded_data_length) { |
87 NOTREACHED(); | 87 NOTREACHED(); |
88 } | 88 } |
89 | 89 |
90 void SecurityFilterPeer::OnCompletedRequest(const net::URLRequestStatus& status, | 90 void SecurityFilterPeer::OnCompletedRequest( |
91 const std::string& security_info, | 91 const net::URLRequestStatus& status, |
92 const base::Time& completion_time) { | 92 const std::string& security_info, |
| 93 const base::TimeTicks& completion_time) { |
93 NOTREACHED(); | 94 NOTREACHED(); |
94 } | 95 } |
95 | 96 |
96 // static | 97 // static |
97 void ProcessResponseInfo( | 98 void ProcessResponseInfo( |
98 const webkit_glue::ResourceResponseInfo& info_in, | 99 const webkit_glue::ResourceResponseInfo& info_in, |
99 webkit_glue::ResourceResponseInfo* info_out, | 100 webkit_glue::ResourceResponseInfo* info_out, |
100 const std::string& mime_type) { | 101 const std::string& mime_type) { |
101 DCHECK(info_out); | 102 DCHECK(info_out); |
102 *info_out = info_in; | 103 *info_out = info_in; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 143 } |
143 | 144 |
144 void BufferedPeer::OnReceivedData(const char* data, | 145 void BufferedPeer::OnReceivedData(const char* data, |
145 int data_length, | 146 int data_length, |
146 int encoded_data_length) { | 147 int encoded_data_length) { |
147 data_.append(data, data_length); | 148 data_.append(data, data_length); |
148 } | 149 } |
149 | 150 |
150 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, | 151 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, |
151 const std::string& security_info, | 152 const std::string& security_info, |
152 const base::Time& completion_time) { | 153 const base::TimeTicks& completion_time) { |
153 // Make sure we delete ourselves at the end of this call. | 154 // Make sure we delete ourselves at the end of this call. |
154 scoped_ptr<BufferedPeer> this_deleter(this); | 155 scoped_ptr<BufferedPeer> this_deleter(this); |
155 | 156 |
156 // Give sub-classes a chance at altering the data. | 157 // Give sub-classes a chance at altering the data. |
157 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { | 158 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { |
158 // Pretend we failed to load the resource. | 159 // Pretend we failed to load the resource. |
159 original_peer_->OnReceivedResponse(response_info_); | 160 original_peer_->OnReceivedResponse(response_info_); |
160 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, | 161 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, |
161 net::ERR_ABORTED); | 162 net::ERR_ABORTED); |
162 original_peer_->OnCompletedRequest(status, security_info, completion_time); | 163 original_peer_->OnCompletedRequest(status, security_info, completion_time); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 195 |
195 void ReplaceContentPeer::OnReceivedData(const char* data, | 196 void ReplaceContentPeer::OnReceivedData(const char* data, |
196 int data_length, | 197 int data_length, |
197 int encoded_data_length) { | 198 int encoded_data_length) { |
198 // Ignore this, we'll serve some alternate content in OnCompletedRequest. | 199 // Ignore this, we'll serve some alternate content in OnCompletedRequest. |
199 } | 200 } |
200 | 201 |
201 void ReplaceContentPeer::OnCompletedRequest( | 202 void ReplaceContentPeer::OnCompletedRequest( |
202 const net::URLRequestStatus& status, | 203 const net::URLRequestStatus& status, |
203 const std::string& security_info, | 204 const std::string& security_info, |
204 const base::Time& completion_time) { | 205 const base::TimeTicks& completion_time) { |
205 webkit_glue::ResourceResponseInfo info; | 206 webkit_glue::ResourceResponseInfo info; |
206 ProcessResponseInfo(info, &info, mime_type_); | 207 ProcessResponseInfo(info, &info, mime_type_); |
207 info.security_info = security_info; | 208 info.security_info = security_info; |
208 info.content_length = static_cast<int>(data_.size()); | 209 info.content_length = static_cast<int>(data_.size()); |
209 original_peer_->OnReceivedResponse(info); | 210 original_peer_->OnReceivedResponse(info); |
210 if (!data_.empty()) | 211 if (!data_.empty()) |
211 original_peer_->OnReceivedData(data_.data(), | 212 original_peer_->OnReceivedData(data_.data(), |
212 static_cast<int>(data_.size()), | 213 static_cast<int>(data_.size()), |
213 -1); | 214 -1); |
214 original_peer_->OnCompletedRequest(net::URLRequestStatus(), | 215 original_peer_->OnCompletedRequest(net::URLRequestStatus(), |
215 security_info, | 216 security_info, |
216 completion_time); | 217 completion_time); |
217 | 218 |
218 // The request processing is complete, we must delete ourselves. | 219 // The request processing is complete, we must delete ourselves. |
219 delete this; | 220 delete this; |
220 } | 221 } |
OLD | NEW |