Line data Source code
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/. */
4 :
5 : #ifdef mozilla_StartupTimeline_Event
6 : mozilla_StartupTimeline_Event(PROCESS_CREATION, "process")
7 : mozilla_StartupTimeline_Event(START, "start")
8 : mozilla_StartupTimeline_Event(MAIN, "main")
9 : mozilla_StartupTimeline_Event(SELECT_PROFILE, "selectProfile")
10 : mozilla_StartupTimeline_Event(AFTER_PROFILE_LOCKED, "afterProfileLocked")
11 : // Record the beginning and end of startup crash detection to compare with crash stats to know whether
12 : // detection should be improved to start or end sooner.
13 : mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_BEGIN, "startupCrashDetectionBegin")
14 : mozilla_StartupTimeline_Event(STARTUP_CRASH_DETECTION_END, "startupCrashDetectionEnd")
15 : mozilla_StartupTimeline_Event(FIRST_PAINT, "firstPaint")
16 : mozilla_StartupTimeline_Event(SESSION_RESTORE_INIT, "sessionRestoreInit")
17 : mozilla_StartupTimeline_Event(SESSION_RESTORED, "sessionRestored")
18 : mozilla_StartupTimeline_Event(CREATE_TOP_LEVEL_WINDOW, "createTopLevelWindow")
19 : mozilla_StartupTimeline_Event(LINKER_INITIALIZED, "linkerInitialized")
20 : mozilla_StartupTimeline_Event(LIBRARIES_LOADED, "librariesLoaded")
21 : mozilla_StartupTimeline_Event(FIRST_LOAD_URI, "firstLoadURI")
22 :
23 : // The following are actually shutdown events, used to monitor the duration of shutdown
24 : mozilla_StartupTimeline_Event(QUIT_APPLICATION, "quitApplication")
25 : mozilla_StartupTimeline_Event(PROFILE_BEFORE_CHANGE, "profileBeforeChange")
26 : #else
27 :
28 : #ifndef mozilla_StartupTimeline
29 : #define mozilla_StartupTimeline
30 :
31 : #include "mozilla/TimeStamp.h"
32 : #include "nscore.h"
33 :
34 : #ifdef MOZILLA_INTERNAL_API
35 : #include "GeckoProfiler.h"
36 : #endif
37 :
38 : namespace mozilla {
39 :
40 : void RecordShutdownEndTimeStamp();
41 : void RecordShutdownStartTimeStamp();
42 :
43 : class StartupTimeline {
44 : public:
45 : enum Event {
46 : #define mozilla_StartupTimeline_Event(ev, z) ev,
47 : #include "StartupTimeline.h"
48 : #undef mozilla_StartupTimeline_Event
49 : MAX_EVENT_ID
50 : };
51 :
52 51 : static TimeStamp Get(Event ev) {
53 51 : return sStartupTimeline[ev];
54 : }
55 :
56 29 : static const char *Describe(Event ev) {
57 29 : return sStartupTimelineDesc[ev];
58 : }
59 :
60 : #ifdef MOZILLA_INTERNAL_API
61 7 : static void Record(Event ev) {
62 7 : profiler_add_marker(Describe(ev));
63 7 : Record(ev, TimeStamp::Now());
64 7 : }
65 :
66 9 : static void Record(Event ev, TimeStamp when) {
67 9 : sStartupTimeline[ev] = when;
68 9 : }
69 :
70 3 : static void RecordOnce(Event ev) {
71 3 : if (!HasRecord(ev))
72 3 : Record(ev);
73 3 : }
74 : #endif
75 :
76 9 : static bool HasRecord(Event ev) {
77 9 : return !sStartupTimeline[ev].IsNull();
78 : }
79 :
80 : private:
81 : static TimeStamp sStartupTimeline[MAX_EVENT_ID];
82 : static const char* sStartupTimelineDesc[MAX_EVENT_ID];
83 : };
84 :
85 : } // namespace mozilla
86 :
87 : #endif /* mozilla_StartupTimeline */
88 :
89 : #endif /* mozilla_StartupTimeline_Event */
|