Backed out 12 changesets (bug 1843308, bug 1848406, bug 1888500, bug 1888504, bug...
[gecko.git] / toolkit / components / startup / StartupTimeline.h
blobf7d5ae5db4c76f48acb980363be82805aa8698be
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifdef mozilla_StartupTimeline_Event
6 // clang-format off
7 mozilla_StartupTimeline_Event(PROCESS_CREATION, "process")
8 mozilla_StartupTimeline_Event(START, "start")
9 mozilla_StartupTimeline_Event(MAIN, "main")
10 mozilla_StartupTimeline_Event(SELECT_PROFILE, "selectProfile")
11 mozilla_StartupTimeline_Event(AFTER_PROFILE_LOCKED, "afterProfileLocked")
13 // Record the beginning and end of startup crash detection to compare with
14 // crash stats to know whether detection should be improved to start or end
15 // sooner.
16 mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_BEGIN, "startupCrashDetectionBegin")
17 mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_END,"startupCrashDetectionEnd")
18 mozilla_StartupTimeline_Event(FIRST_PAINT, "firstPaint")
19 mozilla_StartupTimeline_Event(FIRST_PAINT2, "firstPaint2")
20 mozilla_StartupTimeline_Event(SESSION_RESTORE_INIT, "sessionRestoreInit")
21 mozilla_StartupTimeline_Event(SESSION_RESTORED, "sessionRestored")
22 mozilla_StartupTimeline_Event(CREATE_TOP_LEVEL_WINDOW, "createTopLevelWindow")
23 mozilla_StartupTimeline_Event(LINKER_INITIALIZED, "linkerInitialized")
24 mozilla_StartupTimeline_Event(LIBRARIES_LOADED, "librariesLoaded")
25 mozilla_StartupTimeline_Event(FIRST_LOAD_URI, "firstLoadURI")
27 // The following are actually shutdown events, used to monitor the duration
28 // of shutdown
29 mozilla_StartupTimeline_Event(QUIT_APPLICATION, "quitApplication")
30 mozilla_StartupTimeline_Event(PROFILE_BEFORE_CHANGE, "profileBeforeChange")
31 // clang-format on
32 #else
34 # ifndef mozilla_StartupTimeline
35 # define mozilla_StartupTimeline
37 # include "mozilla/TimeStamp.h"
38 # include "nscore.h"
40 # ifdef MOZILLA_INTERNAL_API
41 # include "mozilla/ProfilerMarkers.h"
42 # endif
44 namespace mozilla {
46 void RecordShutdownEndTimeStamp();
47 void RecordShutdownStartTimeStamp();
49 class StartupTimeline {
50 public:
51 enum Event {
52 # define mozilla_StartupTimeline_Event(ev, z) ev,
53 # include "StartupTimeline.h"
54 # undef mozilla_StartupTimeline_Event
55 MAX_EVENT_ID
58 static TimeStamp Get(Event ev) { return sStartupTimeline[ev]; }
60 static const char* Describe(Event ev) { return sStartupTimelineDesc[ev]; }
62 # ifdef MOZILLA_INTERNAL_API
63 static void Record(Event ev) {
64 PROFILER_MARKER_UNTYPED(
65 ProfilerString8View::WrapNullTerminatedString(Describe(ev)), OTHER);
66 Record(ev, TimeStamp::Now());
69 static void Record(Event ev, TimeStamp when) { sStartupTimeline[ev] = when; }
71 static void RecordOnce(Event ev, const TimeStamp& aWhen);
72 static void RecordOnce(Event ev);
73 # endif
75 static bool HasRecord(Event ev) { return !sStartupTimeline[ev].IsNull(); }
77 private:
78 static TimeStamp sStartupTimeline[MAX_EVENT_ID];
79 static const char* sStartupTimelineDesc[MAX_EVENT_ID];
82 } // namespace mozilla
84 # endif /* mozilla_StartupTimeline */
86 #endif /* mozilla_StartupTimeline_Event */