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

Side by Side Diff: chrome/browser/resources/net_internals/time_util.js

Issue 10825116: net-internals: Display time log dump was created at end of printed logs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to comments - inline expectations Created 8 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 var timeutil = (function() { 5 var timeutil = (function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Offset needed to convert event times to Date objects. 9 * Offset needed to convert event times to Date objects.
10 * Updated whenever constants are loaded. 10 * Updated whenever constants are loaded.
11 */ 11 */
12 var timeTickOffset = 0; 12 var timeTickOffset = 0;
13 13
14 /** 14 /**
15 * Sets the offset used to convert tick counts to dates. 15 * Sets the offset used to convert tick counts to dates.
16 */ 16 */
17 function setTimeTickOffset(offset) { 17 function setTimeTickOffset(offset) {
18 // Note that the subtraction by 0 is to cast to a number (probably a float 18 // Note that the subtraction by 0 is to cast to a number (probably a float
19 // since the numbers are big). 19 // since the numbers are big).
20 timeTickOffset = offset - 0; 20 timeTickOffset = offset - 0;
21 } 21 }
22 22
23 /** 23 /**
24 * The browser gives us times in terms of "time ticks" in milliseconds. 24 * The browser gives us times in terms of "time ticks" in milliseconds.
25 * This function converts the tick count to a Javascript "time", which is
26 * the UTC time in milliseconds.
27 *
28 * @param {String} timeTicks A time represented in "time ticks".
29 * @return {number} The Javascript time that |timeTicks| represents.
30 */
31 function convertTimeTicksToTime(timeTicks) {
32 return timeTickOffset + (timeTicks - 0);
33 }
34
35 /**
36 * The browser gives us times in terms of "time ticks" in milliseconds.
25 * This function converts the tick count to a Date() object. 37 * This function converts the tick count to a Date() object.
26 * 38 *
27 * @param {String} timeTicks A time represented in "time ticks". 39 * @param {String} timeTicks A time represented in "time ticks".
28 * @return {Date} The time that |timeTicks| represents. 40 * @return {Date} The time that |timeTicks| represents.
29 */ 41 */
30 function convertTimeTicksToDate(timeTicks) { 42 function convertTimeTicksToDate(timeTicks) {
31 var timeStampMs = timeTickOffset + (timeTicks - 0); 43 return new Date(convertTimeTicksToTime(timeTicks));
32 return new Date(timeStampMs);
33 } 44 }
34 45
35 /** 46 /**
36 * Returns the current time. 47 * Returns the current time.
37 * 48 *
38 * @return {number} Milliseconds since the Unix epoch. 49 * @return {number} Milliseconds since the Unix epoch.
39 */ 50 */
40 function getCurrentTime() { 51 function getCurrentTime() {
41 return (new Date()).getTime(); 52 return (new Date()).getTime();
42 } 53 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 */ 92 */
82 function zeroPad_(num, len) { 93 function zeroPad_(num, len) {
83 var str = num + ''; 94 var str = num + '';
84 while (str.length < len) 95 while (str.length < len)
85 str = '0' + str; 96 str = '0' + str;
86 return str; 97 return str;
87 } 98 }
88 99
89 return { 100 return {
90 setTimeTickOffset: setTimeTickOffset, 101 setTimeTickOffset: setTimeTickOffset,
102 convertTimeTicksToTime: convertTimeTicksToTime,
91 convertTimeTicksToDate: convertTimeTicksToDate, 103 convertTimeTicksToDate: convertTimeTicksToDate,
92 getCurrentTime: getCurrentTime, 104 getCurrentTime: getCurrentTime,
93 addNodeWithDate: addNodeWithDate, 105 addNodeWithDate: addNodeWithDate,
94 dateToString: dateToString 106 dateToString: dateToString
95 }; 107 };
96 })(); 108 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/source_entry.js ('k') | chrome/test/data/webui/net_internals/log_view_painter.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698