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

Side by Side Diff: net/log/net_log_util.cc

Issue 1127133008: NetLog: Use TimeTicks::UnixEpoch() to calculate timeTickOffset. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 <vector> 9 #include <vector>
10 10
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 base::DictionaryValue* dict = new base::DictionaryValue(); 265 base::DictionaryValue* dict = new base::DictionaryValue();
266 266
267 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED); 267 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED);
268 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4); 268 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4);
269 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6); 269 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6);
270 270
271 constants_dict->Set("addressFamily", dict); 271 constants_dict->Set("addressFamily", dict);
272 } 272 }
273 273
274 // Information about how the "time ticks" values we have given it relate to 274 // Information about how the "time ticks" values we have given it relate to
275 // actual system times. (We used time ticks throughout since they are stable 275 // actual system times. Time ticks are used throughout since they are stable
276 // across system clock changes). 276 // across system clock changes.
277 { 277 {
278 int64 cur_time_ms = (base::Time::Now() - base::Time()).InMilliseconds(); 278 int64 tick_to_unix_time_ms =
279 279 (base::TimeTicks() - base::TimeTicks::UnixEpoch()).InMilliseconds();
280 int64 cur_time_ticks_ms =
281 (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds();
282
283 // If we add this number to a time tick value, it gives the timestamp.
284 int64 tick_to_time_ms = cur_time_ms - cur_time_ticks_ms;
285
286 // Chrome on all platforms stores times using the Windows epoch
287 // (Jan 1 1601), but the javascript wants a unix epoch.
288 // TODO(eroman): Getting the timestamp relative to the unix epoch should
289 // be part of the time library.
290 const int64 kUnixEpochMs = 11644473600000LL;
291 int64 tick_to_unix_time_ms = tick_to_time_ms - kUnixEpochMs;
292 280
293 // Pass it as a string, since it may be too large to fit in an integer. 281 // Pass it as a string, since it may be too large to fit in an integer.
294 constants_dict->SetString("timeTickOffset", 282 constants_dict->SetString("timeTickOffset",
295 base::Int64ToString(tick_to_unix_time_ms)); 283 base::Int64ToString(tick_to_unix_time_ms));
296 } 284 }
297 285
298 // "clientInfo" key is required for some NetLogLogger log readers. 286 // "clientInfo" key is required for some NetLogLogger log readers.
299 // Provide a default empty value for compatibility. 287 // Provide a default empty value for compatibility.
300 constants_dict->Set("clientInfo", new base::DictionaryValue()); 288 constants_dict->Set("clientInfo", new base::DictionaryValue());
301 289
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // fine, since GetRequestStateAsValue() ignores the capture mode. 513 // fine, since GetRequestStateAsValue() ignores the capture mode.
526 NetLog::EntryData entry_data( 514 NetLog::EntryData entry_data(
527 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), 515 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(),
528 NetLog::PHASE_BEGIN, request->creation_time(), &callback); 516 NetLog::PHASE_BEGIN, request->creation_time(), &callback);
529 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); 517 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default());
530 observer->OnAddEntry(entry); 518 observer->OnAddEntry(entry);
531 } 519 }
532 } 520 }
533 521
534 } // namespace net 522 } // 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