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

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

Issue 7602023: Use a monotonic clock (TimeTicks) to report network times to WebCore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use strong typing Created 9 years, 1 month 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 "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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return new ReplaceContentPeer(NULL, peer, "text/html", html); 63 return new ReplaceContentPeer(NULL, peer, "text/html", html);
64 } 64 }
65 65
66 void SecurityFilterPeer::OnUploadProgress(uint64 position, uint64 size) { 66 void SecurityFilterPeer::OnUploadProgress(uint64 position, uint64 size) {
67 original_peer_->OnUploadProgress(position, size); 67 original_peer_->OnUploadProgress(position, size);
68 } 68 }
69 69
70 bool SecurityFilterPeer::OnReceivedRedirect( 70 bool SecurityFilterPeer::OnReceivedRedirect(
71 const GURL& new_url, 71 const GURL& new_url,
72 const webkit_glue::ResourceResponseInfo& info, 72 const webkit_glue::ResourceResponseInfo& info,
73 const base::TimeTicks& start_time,
74 const base::TimeTicks& end_time,
73 bool* has_new_first_party_for_cookies, 75 bool* has_new_first_party_for_cookies,
74 GURL* new_first_party_for_cookies) { 76 GURL* new_first_party_for_cookies) {
75 NOTREACHED(); 77 NOTREACHED();
76 return false; 78 return false;
77 } 79 }
78 80
79 void SecurityFilterPeer::OnReceivedResponse( 81 void SecurityFilterPeer::OnReceivedResponse(
80 const webkit_glue::ResourceResponseInfo& info) { 82 const webkit_glue::ResourceResponseInfo& info,
83 const base::TimeTicks& start_time,
84 const base::TimeTicks& end_time) {
81 NOTREACHED(); 85 NOTREACHED();
82 } 86 }
83 87
84 void SecurityFilterPeer::OnReceivedData(const char* data, 88 void SecurityFilterPeer::OnReceivedData(const char* data,
85 int data_length, 89 int data_length,
86 int encoded_data_length) { 90 int encoded_data_length) {
87 NOTREACHED(); 91 NOTREACHED();
88 } 92 }
89 93
90 void SecurityFilterPeer::OnCompletedRequest(const net::URLRequestStatus& status, 94 void SecurityFilterPeer::OnCompletedRequest(
91 const std::string& security_info, 95 const net::URLRequestStatus& status,
92 const base::Time& completion_time) { 96 const std::string& security_info,
97 const base::TimeTicks& completion_time) {
93 NOTREACHED(); 98 NOTREACHED();
94 } 99 }
95 100
96 // static 101 // static
97 void ProcessResponseInfo( 102 void ProcessResponseInfo(
98 const webkit_glue::ResourceResponseInfo& info_in, 103 const webkit_glue::ResourceResponseInfo& info_in,
99 webkit_glue::ResourceResponseInfo* info_out, 104 webkit_glue::ResourceResponseInfo* info_out,
100 const std::string& mime_type) { 105 const std::string& mime_type) {
101 DCHECK(info_out); 106 DCHECK(info_out);
102 *info_out = info_in; 107 *info_out = info_in;
(...skipping 27 matching lines...) Expand all
130 webkit_glue::ResourceLoaderBridge::Peer* peer, 135 webkit_glue::ResourceLoaderBridge::Peer* peer,
131 const std::string& mime_type) 136 const std::string& mime_type)
132 : SecurityFilterPeer(resource_loader_bridge, peer), 137 : SecurityFilterPeer(resource_loader_bridge, peer),
133 mime_type_(mime_type) { 138 mime_type_(mime_type) {
134 } 139 }
135 140
136 BufferedPeer::~BufferedPeer() { 141 BufferedPeer::~BufferedPeer() {
137 } 142 }
138 143
139 void BufferedPeer::OnReceivedResponse( 144 void BufferedPeer::OnReceivedResponse(
140 const webkit_glue::ResourceResponseInfo& info) { 145 const webkit_glue::ResourceResponseInfo& info,
146 const base::TimeTicks& start_time,
147 const base::TimeTicks& end_time) {
141 ProcessResponseInfo(info, &response_info_, mime_type_); 148 ProcessResponseInfo(info, &response_info_, mime_type_);
149 start_time_ = start_time;
150 end_time_ = end_time;
142 } 151 }
143 152
144 void BufferedPeer::OnReceivedData(const char* data, 153 void BufferedPeer::OnReceivedData(const char* data,
145 int data_length, 154 int data_length,
146 int encoded_data_length) { 155 int encoded_data_length) {
147 data_.append(data, data_length); 156 data_.append(data, data_length);
148 } 157 }
149 158
150 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, 159 void BufferedPeer::OnCompletedRequest(
151 const std::string& security_info, 160 const net::URLRequestStatus& status,
152 const base::Time& completion_time) { 161 const std::string& security_info,
162 const base::TimeTicks& completion_time) {
153 // Make sure we delete ourselves at the end of this call. 163 // Make sure we delete ourselves at the end of this call.
154 scoped_ptr<BufferedPeer> this_deleter(this); 164 scoped_ptr<BufferedPeer> this_deleter(this);
155 165
156 // Give sub-classes a chance at altering the data. 166 // Give sub-classes a chance at altering the data.
157 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { 167 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) {
158 // Pretend we failed to load the resource. 168 // Pretend we failed to load the resource.
159 original_peer_->OnReceivedResponse(response_info_); 169 original_peer_->OnReceivedResponse(response_info_, start_time_, end_time_);
160 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, 170 net::URLRequestStatus status(net::URLRequestStatus::CANCELED,
161 net::ERR_ABORTED); 171 net::ERR_ABORTED);
162 original_peer_->OnCompletedRequest(status, security_info, completion_time); 172 original_peer_->OnCompletedRequest(status, security_info, completion_time);
163 return; 173 return;
164 } 174 }
165 175
166 original_peer_->OnReceivedResponse(response_info_); 176 original_peer_->OnReceivedResponse(response_info_, start_time_, end_time_);
167 if (!data_.empty()) 177 if (!data_.empty())
168 original_peer_->OnReceivedData(data_.data(), 178 original_peer_->OnReceivedData(data_.data(),
169 static_cast<int>(data_.size()), 179 static_cast<int>(data_.size()),
170 -1); 180 -1);
171 original_peer_->OnCompletedRequest(status, security_info, completion_time); 181 original_peer_->OnCompletedRequest(status, security_info, completion_time);
172 } 182 }
173 183
174 //////////////////////////////////////////////////////////////////////////////// 184 ////////////////////////////////////////////////////////////////////////////////
175 // ReplaceContentPeer 185 // ReplaceContentPeer
176 186
177 ReplaceContentPeer::ReplaceContentPeer( 187 ReplaceContentPeer::ReplaceContentPeer(
178 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 188 webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
179 webkit_glue::ResourceLoaderBridge::Peer* peer, 189 webkit_glue::ResourceLoaderBridge::Peer* peer,
180 const std::string& mime_type, 190 const std::string& mime_type,
181 const std::string& data) 191 const std::string& data)
182 : SecurityFilterPeer(resource_loader_bridge, peer), 192 : SecurityFilterPeer(resource_loader_bridge, peer),
183 mime_type_(mime_type), 193 mime_type_(mime_type),
184 data_(data) { 194 data_(data) {
185 } 195 }
186 196
187 ReplaceContentPeer::~ReplaceContentPeer() { 197 ReplaceContentPeer::~ReplaceContentPeer() {
188 } 198 }
189 199
190 void ReplaceContentPeer::OnReceivedResponse( 200 void ReplaceContentPeer::OnReceivedResponse(
191 const webkit_glue::ResourceResponseInfo& info) { 201 const webkit_glue::ResourceResponseInfo& info,
202 const base::TimeTicks& start_time,
203 const base::TimeTicks& end_time) {
204 start_time_ = start_time;
205 end_time_ = end_time;
192 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 206 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
193 } 207 }
194 208
195 void ReplaceContentPeer::OnReceivedData(const char* data, 209 void ReplaceContentPeer::OnReceivedData(const char* data,
196 int data_length, 210 int data_length,
197 int encoded_data_length) { 211 int encoded_data_length) {
198 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 212 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
199 } 213 }
200 214
201 void ReplaceContentPeer::OnCompletedRequest( 215 void ReplaceContentPeer::OnCompletedRequest(
202 const net::URLRequestStatus& status, 216 const net::URLRequestStatus& status,
203 const std::string& security_info, 217 const std::string& security_info,
204 const base::Time& completion_time) { 218 const base::TimeTicks& completion_time) {
205 webkit_glue::ResourceResponseInfo info; 219 webkit_glue::ResourceResponseInfo info;
206 ProcessResponseInfo(info, &info, mime_type_); 220 ProcessResponseInfo(info, &info, mime_type_);
207 info.security_info = security_info; 221 info.security_info = security_info;
208 info.content_length = static_cast<int>(data_.size()); 222 info.content_length = static_cast<int>(data_.size());
209 original_peer_->OnReceivedResponse(info); 223 original_peer_->OnReceivedResponse(info, start_time_, end_time_);
210 if (!data_.empty()) 224 if (!data_.empty())
211 original_peer_->OnReceivedData(data_.data(), 225 original_peer_->OnReceivedData(data_.data(),
212 static_cast<int>(data_.size()), 226 static_cast<int>(data_.size()),
213 -1); 227 -1);
214 original_peer_->OnCompletedRequest(net::URLRequestStatus(), 228 original_peer_->OnCompletedRequest(net::URLRequestStatus(),
215 security_info, 229 security_info,
216 completion_time); 230 completion_time);
217 231
218 // The request processing is complete, we must delete ourselves. 232 // The request processing is complete, we must delete ourselves.
219 delete this; 233 delete this;
220 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698