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

Unified Diff: net/log/net_log_util.cc

Issue 1775663002: Replace TimeTicks::UnixEpoch with Time::UnixEpoch for the net log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comment to be scarier and reference crbug Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/net_log_util.cc
diff --git a/net/log/net_log_util.cc b/net/log/net_log_util.cc
index 4d4dfa66f644ffad9a5756cae6ed2ef03d6f13d5..a088420740848c4dc6d02850ef701844c064537d 100644
--- a/net/log/net_log_util.cc
+++ b/net/log/net_log_util.cc
@@ -274,10 +274,21 @@ scoped_ptr<base::DictionaryValue> GetNetConstants() {
// Information about how the "time ticks" values we have given it relate to
// actual system times. Time ticks are used throughout since they are stable
- // across system clock changes.
+ // across system clock changes. Note: |timeTickOffset| is only comparable to
+ // TimeTicks values in milliseconds.
+ // TODO(csharrison): This is an imprecise way to convert TimeTicks to unix
+ // time. In fact, there isn't really a good way to do this unless we log Time
+ // and TimeTicks values side by side for every event. crbug.com/593157 tracks
+ // a change where the user will be notified if a timing anomaly occured that
+ // would skew the conversion (i.e. the machine entered suspend mode while
+ // logging).
{
+ base::TimeDelta time_since_epoch =
+ base::Time::Now() - base::Time::UnixEpoch();
+ base::TimeDelta reference_time_ticks =
+ base::TimeTicks::Now() - base::TimeTicks();
mmenke 2016/03/10 22:19:35 This seems to completely defeat the purpose of usi
Charlie Harrison 2016/03/10 22:22:25 You have a point, but I assumed that we needed Tim
eroman 2016/03/10 23:18:08 I disagree that using Time everywhere is equivalen
int64_t tick_to_unix_time_ms =
- (base::TimeTicks() - base::TimeTicks::UnixEpoch()).InMilliseconds();
+ (time_since_epoch - reference_time_ticks).InMilliseconds();
// Pass it as a string, since it may be too large to fit in an integer.
constants_dict->SetString("timeTickOffset",
« 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