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

Side by Side Diff: content/browser/renderer_host/async_resource_handler.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: Fix skew in webkit_glue. Created 9 years, 2 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 "content/browser/renderer_host/async_resource_handler.h" 5 #include "content/browser/renderer_host/async_resource_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
13 #include "content/browser/debugger/devtools_netlog_observer.h" 13 #include "content/browser/debugger/devtools_netlog_observer.h"
14 #include "content/browser/host_zoom_map.h" 14 #include "content/browser/host_zoom_map.h"
15 #include "content/browser/renderer_host/global_request_id.h" 15 #include "content/browser/renderer_host/global_request_id.h"
16 #include "content/browser/renderer_host/resource_dispatcher_host.h" 16 #include "content/browser/renderer_host/resource_dispatcher_host.h"
17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" 17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h"
18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
19 #include "content/browser/renderer_host/resource_message_filter.h" 19 #include "content/browser/renderer_host/resource_message_filter.h"
20 #include "content/browser/resource_context.h" 20 #include "content/browser/resource_context.h"
21 #include "content/common/resource_response.h" 21 #include "content/common/resource_response.h"
22 #include "content/common/resource_messages.h" 22 #include "content/common/resource_messages.h"
23 #include "content/common/view_messages.h" 23 #include "content/common/view_messages.h"
24 #include "net/base/io_buffer.h" 24 #include "net/base/io_buffer.h"
25 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
26 #include "net/base/net_log.h" 26 #include "net/base/net_log.h"
27 #include "webkit/glue/resource_loader_bridge.h" 27 #include "webkit/glue/resource_loader_bridge.h"
28 28
29 using base::Time;
30 using base::TimeTicks; 29 using base::TimeTicks;
31 30
32 namespace { 31 namespace {
33 32
34 // When reading, we don't know if we are going to get EOF (0 bytes read), so 33 // When reading, we don't know if we are going to get EOF (0 bytes read), so
35 // we typically have a buffer that we allocated but did not use. We keep 34 // we typically have a buffer that we allocated but did not use. We keep
36 // this buffer around for the next read as a small optimization. 35 // this buffer around for the next read as a small optimization.
37 SharedIOBuffer* g_spare_read_buffer = NULL; 36 SharedIOBuffer* g_spare_read_buffer = NULL;
38 37
39 // The initial size of the shared memory buffer. (32 kilobytes). 38 // The initial size of the shared memory buffer. (32 kilobytes).
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ResourceResponse* response, 102 ResourceResponse* response,
104 bool* defer) { 103 bool* defer) {
105 *defer = true; 104 *defer = true;
106 net::URLRequest* request = rdh_->GetURLRequest( 105 net::URLRequest* request = rdh_->GetURLRequest(
107 GlobalRequestID(filter_->child_id(), request_id)); 106 GlobalRequestID(filter_->child_id(), request_id));
108 if (rdh_->delegate()) 107 if (rdh_->delegate())
109 rdh_->delegate()->OnRequestRedirected(request, response, filter_); 108 rdh_->delegate()->OnRequestRedirected(request, response, filter_);
110 109
111 DevToolsNetLogObserver::PopulateResponseInfo(request, response); 110 DevToolsNetLogObserver::PopulateResponseInfo(request, response);
112 return filter_->Send(new ResourceMsg_ReceivedRedirect( 111 return filter_->Send(new ResourceMsg_ReceivedRedirect(
113 routing_id_, request_id, new_url, response->response_head)); 112 routing_id_, request_id, new_url, response->response_head,
113 request->start_time(), TimeTicks::Now()));
114 } 114 }
115 115
116 bool AsyncResourceHandler::OnResponseStarted(int request_id, 116 bool AsyncResourceHandler::OnResponseStarted(int request_id,
117 ResourceResponse* response) { 117 ResourceResponse* response) {
118 // For changes to the main frame, inform the renderer of the new URL's 118 // For changes to the main frame, inform the renderer of the new URL's
119 // per-host settings before the request actually commits. This way the 119 // per-host settings before the request actually commits. This way the
120 // renderer will be able to set these precisely at the time the 120 // renderer will be able to set these precisely at the time the
121 // request commits, avoiding the possibility of e.g. zooming the old content 121 // request commits, avoiding the possibility of e.g. zooming the old content
122 // or of having to layout the new content twice. 122 // or of having to layout the new content twice.
123 net::URLRequest* request = rdh_->GetURLRequest( 123 net::URLRequest* request = rdh_->GetURLRequest(
(...skipping 11 matching lines...) Expand all
135 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); 135 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request);
136 if (info->resource_type() == ResourceType::MAIN_FRAME && host_zoom_map) { 136 if (info->resource_type() == ResourceType::MAIN_FRAME && host_zoom_map) {
137 GURL request_url(request->url()); 137 GURL request_url(request->url());
138 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( 138 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL(
139 info->route_id(), 139 info->route_id(),
140 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( 140 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(
141 request_url)))); 141 request_url))));
142 } 142 }
143 143
144 filter_->Send(new ResourceMsg_ReceivedResponse( 144 filter_->Send(new ResourceMsg_ReceivedResponse(
145 routing_id_, request_id, response->response_head)); 145 routing_id_, request_id, response->response_head, request->start_time(),
146 TimeTicks::Now()));
146 147
147 if (request->response_info().metadata) { 148 if (request->response_info().metadata) {
148 std::vector<char> copy(request->response_info().metadata->data(), 149 std::vector<char> copy(request->response_info().metadata->data(),
149 request->response_info().metadata->data() + 150 request->response_info().metadata->data() +
150 request->response_info().metadata->size()); 151 request->response_info().metadata->size());
151 filter_->Send(new ResourceMsg_ReceivedCachedMetadata( 152 filter_->Send(new ResourceMsg_ReceivedCachedMetadata(
152 routing_id_, request_id, copy)); 153 routing_id_, request_id, copy));
153 } 154 }
154 155
155 return true; 156 return true;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void AsyncResourceHandler::OnDataDownloaded( 233 void AsyncResourceHandler::OnDataDownloaded(
233 int request_id, int bytes_downloaded) { 234 int request_id, int bytes_downloaded) {
234 filter_->Send(new ResourceMsg_DataDownloaded( 235 filter_->Send(new ResourceMsg_DataDownloaded(
235 routing_id_, request_id, bytes_downloaded)); 236 routing_id_, request_id, bytes_downloaded));
236 } 237 }
237 238
238 bool AsyncResourceHandler::OnResponseCompleted( 239 bool AsyncResourceHandler::OnResponseCompleted(
239 int request_id, 240 int request_id,
240 const net::URLRequestStatus& status, 241 const net::URLRequestStatus& status,
241 const std::string& security_info) { 242 const std::string& security_info) {
242 Time completion_time = Time::Now(); 243 TimeTicks completion_time = TimeTicks::Now();
243 filter_->Send(new ResourceMsg_RequestComplete(routing_id_, 244 filter_->Send(new ResourceMsg_RequestComplete(routing_id_,
244 request_id, 245 request_id,
245 status, 246 status,
246 security_info, 247 security_info,
247 completion_time)); 248 completion_time));
248 249
249 // If we still have a read buffer, then see about caching it for later... 250 // If we still have a read buffer, then see about caching it for later...
250 // Note that we have to make sure the buffer is not still being used, so we 251 // Note that we have to make sure the buffer is not still being used, so we
251 // have to perform an explicit check on the status code. 252 // have to perform an explicit check on the status code.
252 if (g_spare_read_buffer || 253 if (g_spare_read_buffer ||
(...skipping 11 matching lines...) Expand all
264 265
265 // static 266 // static
266 void AsyncResourceHandler::GlobalCleanup() { 267 void AsyncResourceHandler::GlobalCleanup() {
267 if (g_spare_read_buffer) { 268 if (g_spare_read_buffer) {
268 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). 269 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer().
269 SharedIOBuffer* tmp = g_spare_read_buffer; 270 SharedIOBuffer* tmp = g_spare_read_buffer;
270 g_spare_read_buffer = NULL; 271 g_spare_read_buffer = NULL;
271 tmp->Release(); 272 tmp->Release();
272 } 273 }
273 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698