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

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

Issue 138513002: Plumb network stack information about existence of cached copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments from Matt & Ricardo. Created 6 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 | Annotate | Revision Log
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/strings/stringprintf.h" 8 #include "base/strings/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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 void SecurityFilterPeer::OnReceivedData(const char* data, 87 void SecurityFilterPeer::OnReceivedData(const char* data,
88 int data_length, 88 int data_length,
89 int encoded_data_length) { 89 int encoded_data_length) {
90 NOTREACHED(); 90 NOTREACHED();
91 } 91 }
92 92
93 void SecurityFilterPeer::OnCompletedRequest( 93 void SecurityFilterPeer::OnCompletedRequest(
94 int error_code, 94 int error_code,
95 bool was_ignored_by_handler, 95 bool was_ignored_by_handler,
96 bool stale_copy_in_cache,
96 const std::string& security_info, 97 const std::string& security_info,
97 const base::TimeTicks& completion_time) { 98 const base::TimeTicks& completion_time) {
98 NOTREACHED(); 99 NOTREACHED();
99 } 100 }
100 101
101 // static 102 // static
102 void ProcessResponseInfo( 103 void ProcessResponseInfo(
103 const webkit_glue::ResourceResponseInfo& info_in, 104 const webkit_glue::ResourceResponseInfo& info_in,
104 webkit_glue::ResourceResponseInfo* info_out, 105 webkit_glue::ResourceResponseInfo* info_out,
105 const std::string& mime_type) { 106 const std::string& mime_type) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 148 }
148 149
149 void BufferedPeer::OnReceivedData(const char* data, 150 void BufferedPeer::OnReceivedData(const char* data,
150 int data_length, 151 int data_length,
151 int encoded_data_length) { 152 int encoded_data_length) {
152 data_.append(data, data_length); 153 data_.append(data, data_length);
153 } 154 }
154 155
155 void BufferedPeer::OnCompletedRequest(int error_code, 156 void BufferedPeer::OnCompletedRequest(int error_code,
156 bool was_ignored_by_handler, 157 bool was_ignored_by_handler,
158 bool stale_copy_in_cache,
157 const std::string& security_info, 159 const std::string& security_info,
158 const base::TimeTicks& completion_time) { 160 const base::TimeTicks& completion_time) {
159 // Make sure we delete ourselves at the end of this call. 161 // Make sure we delete ourselves at the end of this call.
160 scoped_ptr<BufferedPeer> this_deleter(this); 162 scoped_ptr<BufferedPeer> this_deleter(this);
161 163
162 // Give sub-classes a chance at altering the data. 164 // Give sub-classes a chance at altering the data.
163 if (error_code != net::OK || !DataReady()) { 165 if (error_code != net::OK || !DataReady()) {
164 // Pretend we failed to load the resource. 166 // Pretend we failed to load the resource.
165 original_peer_->OnReceivedResponse(response_info_); 167 original_peer_->OnReceivedResponse(response_info_);
166 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, security_info, 168 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false,
167 completion_time); 169 stale_copy_in_cache,
170 security_info, completion_time);
168 return; 171 return;
169 } 172 }
170 173
171 original_peer_->OnReceivedResponse(response_info_); 174 original_peer_->OnReceivedResponse(response_info_);
172 if (!data_.empty()) 175 if (!data_.empty())
173 original_peer_->OnReceivedData(data_.data(), 176 original_peer_->OnReceivedData(data_.data(),
174 static_cast<int>(data_.size()), 177 static_cast<int>(data_.size()),
175 -1); 178 -1);
176 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, 179 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler,
177 security_info, completion_time); 180 stale_copy_in_cache, security_info,
181 completion_time);
178 } 182 }
179 183
180 //////////////////////////////////////////////////////////////////////////////// 184 ////////////////////////////////////////////////////////////////////////////////
181 // ReplaceContentPeer 185 // ReplaceContentPeer
182 186
183 ReplaceContentPeer::ReplaceContentPeer( 187 ReplaceContentPeer::ReplaceContentPeer(
184 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 188 webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
185 webkit_glue::ResourceLoaderBridge::Peer* peer, 189 webkit_glue::ResourceLoaderBridge::Peer* peer,
186 const std::string& mime_type, 190 const std::string& mime_type,
187 const std::string& data) 191 const std::string& data)
(...skipping 12 matching lines...) Expand all
200 204
201 void ReplaceContentPeer::OnReceivedData(const char* data, 205 void ReplaceContentPeer::OnReceivedData(const char* data,
202 int data_length, 206 int data_length,
203 int encoded_data_length) { 207 int encoded_data_length) {
204 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 208 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
205 } 209 }
206 210
207 void ReplaceContentPeer::OnCompletedRequest( 211 void ReplaceContentPeer::OnCompletedRequest(
208 int error_code, 212 int error_code,
209 bool was_ignored_by_handler, 213 bool was_ignored_by_handler,
214 bool stale_copy_in_cache,
210 const std::string& security_info, 215 const std::string& security_info,
211 const base::TimeTicks& completion_time) { 216 const base::TimeTicks& completion_time) {
212 webkit_glue::ResourceResponseInfo info; 217 webkit_glue::ResourceResponseInfo info;
213 ProcessResponseInfo(info, &info, mime_type_); 218 ProcessResponseInfo(info, &info, mime_type_);
214 info.security_info = security_info; 219 info.security_info = security_info;
215 info.content_length = static_cast<int>(data_.size()); 220 info.content_length = static_cast<int>(data_.size());
216 original_peer_->OnReceivedResponse(info); 221 original_peer_->OnReceivedResponse(info);
217 if (!data_.empty()) 222 if (!data_.empty())
218 original_peer_->OnReceivedData(data_.data(), 223 original_peer_->OnReceivedData(data_.data(),
219 static_cast<int>(data_.size()), 224 static_cast<int>(data_.size()),
220 -1); 225 -1);
221 original_peer_->OnCompletedRequest(net::OK, 226 original_peer_->OnCompletedRequest(net::OK,
222 false, 227 false,
228 stale_copy_in_cache,
223 security_info, 229 security_info,
224 completion_time); 230 completion_time);
225 231
226 // The request processing is complete, we must delete ourselves. 232 // The request processing is complete, we must delete ourselves.
227 delete this; 233 delete this;
228 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698