michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifdef mozilla_StartupTimeline_Event michael@0: mozilla_StartupTimeline_Event(PROCESS_CREATION, "process") michael@0: mozilla_StartupTimeline_Event(START, "start") michael@0: mozilla_StartupTimeline_Event(MAIN, "main") michael@0: mozilla_StartupTimeline_Event(SELECT_PROFILE, "selectProfile") michael@0: mozilla_StartupTimeline_Event(AFTER_PROFILE_LOCKED, "afterProfileLocked") michael@0: // Record the beginning and end of startup crash detection to compare with crash stats to know whether michael@0: // detection should be improved to start or end sooner. michael@0: mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_BEGIN, "startupCrashDetectionBegin") michael@0: mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_END, "startupCrashDetectionEnd") michael@0: mozilla_StartupTimeline_Event(FIRST_PAINT, "firstPaint") michael@0: mozilla_StartupTimeline_Event(SESSION_RESTORE_INIT, "sessionRestoreInit") michael@0: mozilla_StartupTimeline_Event(SESSION_RESTORED, "sessionRestored") michael@0: mozilla_StartupTimeline_Event(CREATE_TOP_LEVEL_WINDOW, "createTopLevelWindow") michael@0: mozilla_StartupTimeline_Event(LINKER_INITIALIZED, "linkerInitialized") michael@0: mozilla_StartupTimeline_Event(LIBRARIES_LOADED, "librariesLoaded") michael@0: mozilla_StartupTimeline_Event(FIRST_LOAD_URI, "firstLoadURI") michael@0: #else michael@0: michael@0: #ifndef mozilla_StartupTimeline michael@0: #define mozilla_StartupTimeline michael@0: michael@0: #include "mozilla/TimeStamp.h" michael@0: #include "nscore.h" michael@0: #include "GeckoProfiler.h" michael@0: michael@0: #ifdef MOZ_LINKER michael@0: extern "C" { michael@0: /* This symbol is resolved by the custom linker. The function it resolves michael@0: * to dumps some statistics about the linker at the key events recorded michael@0: * by the startup timeline. */ michael@0: extern void __moz_linker_stats(const char *str) michael@0: NS_VISIBILITY_DEFAULT __attribute__((weak)); michael@0: } /* extern "C" */ michael@0: #else michael@0: michael@0: #endif michael@0: michael@0: namespace mozilla { michael@0: michael@0: void RecordShutdownEndTimeStamp(); michael@0: void RecordShutdownStartTimeStamp(); michael@0: void StartupTimelineRecordExternal(int, uint64_t); michael@0: michael@0: class StartupTimeline { michael@0: public: michael@0: enum Event { michael@0: #define mozilla_StartupTimeline_Event(ev, z) ev, michael@0: #include "StartupTimeline.h" michael@0: #undef mozilla_StartupTimeline_Event michael@0: MAX_EVENT_ID michael@0: }; michael@0: michael@0: static TimeStamp Get(Event ev) { michael@0: return sStartupTimeline[ev]; michael@0: } michael@0: michael@0: static const char *Describe(Event ev) { michael@0: return sStartupTimelineDesc[ev]; michael@0: } michael@0: michael@0: static void Record(Event ev) { michael@0: PROFILER_MARKER(Describe(ev)); michael@0: Record(ev, TimeStamp::Now()); michael@0: } michael@0: michael@0: static void Record(Event ev, TimeStamp when) { michael@0: sStartupTimeline[ev] = when; michael@0: #ifdef MOZ_LINKER michael@0: if (__moz_linker_stats) michael@0: __moz_linker_stats(Describe(ev)); michael@0: #endif michael@0: } michael@0: michael@0: static void RecordOnce(Event ev) { michael@0: if (!HasRecord(ev)) michael@0: Record(ev); michael@0: } michael@0: michael@0: static bool HasRecord(Event ev) { michael@0: return !sStartupTimeline[ev].IsNull(); michael@0: } michael@0: michael@0: private: michael@0: static NS_EXTERNAL_VIS_(TimeStamp) sStartupTimeline[MAX_EVENT_ID]; michael@0: static NS_EXTERNAL_VIS_(const char *) sStartupTimelineDesc[MAX_EVENT_ID]; michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif /* mozilla_StartupTimeline */ michael@0: michael@0: #endif /* mozilla_StartupTimeline_Event */