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

Side by Side Diff: chrome/browser/net/load_timing_observer.cc

Issue 5861008: DevTools: Network requests are timed with 1.6 days. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/net/load_timing_observer.h" 5 #include "chrome/browser/net/load_timing_observer.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "chrome/browser/browser_thread.h" 8 #include "chrome/browser/browser_thread.h"
9 #include "chrome/browser/net/chrome_net_log.h" 9 #include "chrome/browser/net/chrome_net_log.h"
10 #include "chrome/common/resource_response.h" 10 #include "chrome/common/resource_response.h"
11 #include "net/base/load_flags.h" 11 #include "net/base/load_flags.h"
12 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
13 #include "net/url_request/url_request_netlog_params.h" 13 #include "net/url_request/url_request_netlog_params.h"
14 14
15 using base::Time; 15 using base::Time;
16 using base::TimeTicks; 16 using base::TimeTicks;
17 using webkit_glue::ResourceLoaderBridge; 17 using webkit_glue::ResourceLoaderBridge;
18 using webkit_glue::ResourceLoadTimingInfo; 18 using webkit_glue::ResourceLoadTimingInfo;
19 19
20 const size_t kMaxNumEntries = 1000; 20 const size_t kMaxNumEntries = 1000;
21 21
22 namespace { 22 namespace {
23 23
24 const int64 kSyncPeriod = 1000 * 1000 * 10;
tonyg 2010/12/16 22:21:03 I'd recommend adding the units to the name: kSyncP
25
24 // We know that this conversion is not solid and suffers from world clock 26 // We know that this conversion is not solid and suffers from world clock
25 // changes, but it should be good enough for the load timing info. 27 // changes, but given that we sync clock every 10 seconds, it should be good
28 // enough for the load timing info.
26 static Time TimeTicksToTime(const TimeTicks& time_ticks) { 29 static Time TimeTicksToTime(const TimeTicks& time_ticks) {
27 static int64 tick_to_time_offset; 30 static int64 tick_to_time_offset;
28 static bool tick_to_time_offset_available = false; 31 static int64 last_sync_ticks = 0;
29 if (!tick_to_time_offset_available) { 32 if (time_ticks.ToInternalValue() - last_sync_ticks > kSyncPeriod) {
30 int64 cur_time = (Time::Now() - Time()).InMicroseconds(); 33 int64 cur_time = (Time::Now() - Time()).InMicroseconds();
31 int64 cur_time_ticks = (TimeTicks::Now() - TimeTicks()).InMicroseconds(); 34 int64 cur_time_ticks = (TimeTicks::Now() - TimeTicks()).InMicroseconds();
32 // If we add this number to a time tick value, it gives the timestamp. 35 // If we add this number to a time tick value, it gives the timestamp.
33 tick_to_time_offset = cur_time - cur_time_ticks; 36 tick_to_time_offset = cur_time - cur_time_ticks;
34 tick_to_time_offset_available = true; 37 last_sync_ticks = time_ticks.ToInternalValue();
35 } 38 }
36 return Time::FromInternalValue(time_ticks.ToInternalValue() + 39 return Time::FromInternalValue(time_ticks.ToInternalValue() +
37 tick_to_time_offset); 40 tick_to_time_offset);
38 } 41 }
39 42
40 static int32 TimeTicksToOffset( 43 static int32 TimeTicksToOffset(
41 const TimeTicks& time_ticks, 44 const TimeTicks& time_ticks,
42 LoadTimingObserver::URLRequestRecord* record) { 45 LoadTimingObserver::URLRequestRecord* record) {
43 return static_cast<int32>( 46 return static_cast<int32>(
44 (time_ticks - record->base_ticks).InMillisecondsRoundedUp()); 47 (time_ticks - record->base_ticks).InMillisecondsRoundedUp());
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (it == socket_to_record_.end()) 293 if (it == socket_to_record_.end())
291 return; 294 return;
292 295
293 if (type == net::NetLog::TYPE_SSL_CONNECT) { 296 if (type == net::NetLog::TYPE_SSL_CONNECT) {
294 if (is_begin) 297 if (is_begin)
295 it->second.ssl_start = time; 298 it->second.ssl_start = time;
296 else if (is_end) 299 else if (is_end)
297 it->second.ssl_end = time; 300 it->second.ssl_end = time;
298 } 301 }
299 } 302 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698