author Phil Ringnalda <>
Sat, 13 Sep 2014 09:59:06 -0700
changeset 205205 d070787de8f7b56e32bf5800b30f143c4d02d474
parent 130903 a609b0f445f88513a93d9431ce0813e48c8c8464
child 251495 1e9c005e679894b85e272f50d294efa55cdbc12f
permissions -rw-r--r--
Merge b-i to m-c

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#include "StartupTimeline.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
#include "nsXULAppAPI.h"

namespace mozilla {

TimeStamp StartupTimeline::sStartupTimeline[StartupTimeline::MAX_EVENT_ID];
const char *StartupTimeline::sStartupTimelineDesc[StartupTimeline::MAX_EVENT_ID] = {
#define mozilla_StartupTimeline_Event(ev, desc) desc,
#include "StartupTimeline.h"
#undef mozilla_StartupTimeline_Event

 * Implementation of XRE_StartupTimelineRecord()
 * @param aEvent Same as XRE_StartupTimelineRecord() equivalent argument
 * @param aWhen  Same as XRE_StartupTimelineRecord() equivalent argument
StartupTimelineRecordExternal(int aEvent, uint64_t aWhen)
#if XP_WIN
  TimeStamp ts = TimeStampValue(aWhen, 0, 0);
  TimeStamp ts = TimeStampValue(aWhen);
  bool error = false;

  // Since the timestamp comes from an external source validate it before
  // recording it and log a telemetry error if it appears inconsistent.
  if (ts < TimeStamp::ProcessCreation(error)) {
  } else {
    StartupTimeline::Record((StartupTimeline::Event)aEvent, ts);

} /* namespace mozilla */

 * The XRE_StartupTimeline_Record function is to be used by embedding
 * applications that can't use mozilla::StartupTimeline::Record() directly.
 * It can create timestamps from arbitrary time values and sanitizies them to
 * ensure that they are not inconsistent with those captured using monotonic
 * timers. The value of aWhen must have been captured using the same timer
 * used by the platform's mozilla::TimeStamp implementation. Erroneous values
 * will be flagged as telemetry errors.
 * @param aEvent The event to be recorded, must correspond to an element of the
 *               mozilla::StartupTimeline::Event enumartion
 * @param aWhen  The time at which the event happened, must have been recorded
 *               using the same timer as the platform's mozilla::TimeStamp
 *               implementation
XRE_StartupTimelineRecord(int aEvent, PRTime aWhen)
  mozilla::StartupTimelineRecordExternal(aEvent, aWhen);