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

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: Added comment Created 9 years, 3 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void AsyncResourceHandler::OnDataDownloaded( 231 void AsyncResourceHandler::OnDataDownloaded(
233 int request_id, int bytes_downloaded) { 232 int request_id, int bytes_downloaded) {
234 filter_->Send(new ResourceMsg_DataDownloaded( 233 filter_->Send(new ResourceMsg_DataDownloaded(
235 routing_id_, request_id, bytes_downloaded)); 234 routing_id_, request_id, bytes_downloaded));
236 } 235 }
237 236
238 bool AsyncResourceHandler::OnResponseCompleted( 237 bool AsyncResourceHandler::OnResponseCompleted(
239 int request_id, 238 int request_id,
240 const net::URLRequestStatus& status, 239 const net::URLRequestStatus& status,
241 const std::string& security_info) { 240 const std::string& security_info) {
242 Time completion_time = Time::Now(); 241 TimeTicks completion_time = TimeTicks::Now();
243 filter_->Send(new ResourceMsg_RequestComplete(routing_id_, 242 filter_->Send(new ResourceMsg_RequestComplete(routing_id_,
244 request_id, 243 request_id,
245 status, 244 status,
246 security_info, 245 security_info,
247 completion_time)); 246 completion_time));
248 247
249 // If we still have a read buffer, then see about caching it for later... 248 // 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 249 // 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. 250 // have to perform an explicit check on the status code.
252 if (g_spare_read_buffer || 251 if (g_spare_read_buffer ||
(...skipping 11 matching lines...) Expand all
264 263
265 // static 264 // static
266 void AsyncResourceHandler::GlobalCleanup() { 265 void AsyncResourceHandler::GlobalCleanup() {
267 if (g_spare_read_buffer) { 266 if (g_spare_read_buffer) {
268 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). 267 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer().
269 SharedIOBuffer* tmp = g_spare_read_buffer; 268 SharedIOBuffer* tmp = g_spare_read_buffer;
270 g_spare_read_buffer = NULL; 269 g_spare_read_buffer = NULL;
271 tmp->Release(); 270 tmp->Release();
272 } 271 }
273 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698