summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/net_internals/time_util.js
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-17 16:44:35 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-17 16:44:35 +0000
commitcc25dba3d78ec1657aaa5ad9f286ac771b5c9bc4 (patch)
tree881a47061a1c9f1d172659534648ccf7f3bf4aed /chrome/browser/resources/net_internals/time_util.js
parent6529b0ec599e083d54f9031cc37150ae93b368a2 (diff)
downloadchromium_src-cc25dba3d78ec1657aaa5ad9f286ac771b5c9bc4.zip
chromium_src-cc25dba3d78ec1657aaa5ad9f286ac771b5c9bc4.tar.gz
chromium_src-cc25dba3d78ec1657aaa5ad9f286ac771b5c9bc4.tar.bz2
Split net-internals log dump code apart from main.js, update
tests so they can test tab and tab handle visibility, and add a pair of tests. BUG=89057 TEST=NetInternalsTest.NetInternalsTourTabs, NetInternalsTest.NetInternalsExportImportDump. Other NetInternalsTest.* tests modified. Review URL: http://codereview.chromium.org/7616020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/net_internals/time_util.js')
-rw-r--r--chrome/browser/resources/net_internals/time_util.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/chrome/browser/resources/net_internals/time_util.js b/chrome/browser/resources/net_internals/time_util.js
new file mode 100644
index 0000000..78cd379
--- /dev/null
+++ b/chrome/browser/resources/net_internals/time_util.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var timeutil = (function() {
+ /**
+ * Offset needed to convert event times to Date objects.
+ * Updated whenever constants are loaded.
+ */
+ var timeTickOffset = 0;
+
+ /**
+ * Sets the offset used to convert tick counts to dates.
+ */
+ function setTimeTickOffset(offset) {
+ // Note that the subtraction by 0 is to cast to a number (probably a float
+ // since the numbers are big).
+ timeTickOffset = offset - 0;
+ }
+
+ /**
+ * The browser gives us times in terms of "time ticks" in milliseconds.
+ * This function converts the tick count to a Date() object.
+ *
+ * @param {String} timeTicks.
+ * @returns {Date} The time that |timeTicks| represents.
+ */
+ function convertTimeTicksToDate(timeTicks) {
+ var timeStampMs = timeTickOffset + (timeTicks - 0);
+ return new Date(timeStampMs);
+ }
+
+ return {
+ setTimeTickOffset: setTimeTickOffset,
+ convertTimeTicksToDate: convertTimeTicksToDate
+ };
+})();