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

Side by Side 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 unified diff | Download patch
« 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "net/log/net_log_util.h" 5 #include "net/log/net_log_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED); 268 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED);
269 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4); 269 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4);
270 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6); 270 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6);
271 271
272 constants_dict->Set("addressFamily", std::move(dict)); 272 constants_dict->Set("addressFamily", std::move(dict));
273 } 273 }
274 274
275 // Information about how the "time ticks" values we have given it relate to 275 // Information about how the "time ticks" values we have given it relate to
276 // actual system times. Time ticks are used throughout since they are stable 276 // actual system times. Time ticks are used throughout since they are stable
277 // across system clock changes. 277 // across system clock changes. Note: |timeTickOffset| is only comparable to
278 // TimeTicks values in milliseconds.
279 // TODO(csharrison): This is an imprecise way to convert TimeTicks to unix
280 // time. In fact, there isn't really a good way to do this unless we log Time
281 // and TimeTicks values side by side for every event. crbug.com/593157 tracks
282 // a change where the user will be notified if a timing anomaly occured that
283 // would skew the conversion (i.e. the machine entered suspend mode while
284 // logging).
278 { 285 {
286 base::TimeDelta time_since_epoch =
287 base::Time::Now() - base::Time::UnixEpoch();
288 base::TimeDelta reference_time_ticks =
289 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
279 int64_t tick_to_unix_time_ms = 290 int64_t tick_to_unix_time_ms =
280 (base::TimeTicks() - base::TimeTicks::UnixEpoch()).InMilliseconds(); 291 (time_since_epoch - reference_time_ticks).InMilliseconds();
281 292
282 // Pass it as a string, since it may be too large to fit in an integer. 293 // Pass it as a string, since it may be too large to fit in an integer.
283 constants_dict->SetString("timeTickOffset", 294 constants_dict->SetString("timeTickOffset",
284 base::Int64ToString(tick_to_unix_time_ms)); 295 base::Int64ToString(tick_to_unix_time_ms));
285 } 296 }
286 297
287 // "clientInfo" key is required for some WriteToFileNetLogObserver log 298 // "clientInfo" key is required for some WriteToFileNetLogObserver log
288 // readers. Provide a default empty value for compatibility. 299 // readers. Provide a default empty value for compatibility.
289 constants_dict->Set("clientInfo", new base::DictionaryValue()); 300 constants_dict->Set("clientInfo", new base::DictionaryValue());
290 301
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // fine, since GetRequestStateAsValue() ignores the capture mode. 540 // fine, since GetRequestStateAsValue() ignores the capture mode.
530 NetLog::EntryData entry_data( 541 NetLog::EntryData entry_data(
531 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), 542 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(),
532 NetLog::PHASE_BEGIN, request->creation_time(), &callback); 543 NetLog::PHASE_BEGIN, request->creation_time(), &callback);
533 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); 544 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default());
534 observer->OnAddEntry(entry); 545 observer->OnAddEntry(entry);
535 } 546 }
536 } 547 }
537 548
538 } // namespace net 549 } // namespace net
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