summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/ntp4/logging.js
blob: 9177608407447ff25da5166a76a5d95d3a2ef443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2012 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.

/**
 * @fileoverview
 * Logging info for benchmarking purposes. Should be the first js file included.
 */

/* Stack of events that has been logged. */
const eventLog = [];

/**
 * Logs an event.
 * @param {string} name The name of the event (can be any string).
 * @param {boolean=} opt_shouldLogTime If true, the event is used for
 *     benchmarking and the time is logged. Otherwise, just push the event on
 *     the event stack.
 */
function logEvent(name, opt_shouldLogTime) {
  if (opt_shouldLogTime) {
    chrome.send('metricsHandler:logEventTime', [name]);
  }
  eventLog.push([name, Date.now()]);
}

logEvent('Tab.NewTabScriptStart', true);
window.addEventListener('load', function(e) {
  logEvent('Tab.NewTabOnload', true);
});
document.addEventListener('DOMContentLoaded', function(e) {
  logEvent('Tab.NewTabDOMContentLoaded', true);
});