/src/mozilla-central/toolkit/components/startup/StartupTimeline.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "StartupTimeline.h" |
6 | | #include "mozilla/Telemetry.h" |
7 | | #include "mozilla/TimeStamp.h" |
8 | | #include "nsXULAppAPI.h" |
9 | | |
10 | | namespace mozilla { |
11 | | |
12 | | TimeStamp StartupTimeline::sStartupTimeline[StartupTimeline::MAX_EVENT_ID]; |
13 | | const char *StartupTimeline::sStartupTimelineDesc[StartupTimeline::MAX_EVENT_ID] = { |
14 | | #define mozilla_StartupTimeline_Event(ev, desc) desc, |
15 | | #include "StartupTimeline.h" |
16 | | #undef mozilla_StartupTimeline_Event |
17 | | }; |
18 | | |
19 | | } /* namespace mozilla */ |
20 | | |
21 | | using mozilla::StartupTimeline; |
22 | | using mozilla::TimeStamp; |
23 | | |
24 | | /** |
25 | | * The XRE_StartupTimeline_Record function is to be used by embedding |
26 | | * applications that can't use mozilla::StartupTimeline::Record() directly. |
27 | | * |
28 | | * @param aEvent The event to be recorded, must correspond to an element of the |
29 | | * mozilla::StartupTimeline::Event enumartion |
30 | | * @param aWhen The time at which the event happened |
31 | | */ |
32 | | void |
33 | | XRE_StartupTimelineRecord(int aEvent, TimeStamp aWhen) |
34 | 3 | { |
35 | 3 | StartupTimeline::Record((StartupTimeline::Event)aEvent, aWhen); |
36 | 3 | } |
37 | | |
38 | 0 | void StartupTimeline::RecordOnce(Event ev) { |
39 | 0 |
|
40 | 0 | if (HasRecord(ev)) { |
41 | 0 | return; |
42 | 0 | } |
43 | 0 | |
44 | 0 | Record(ev); |
45 | 0 |
|
46 | 0 | // Record first paint timestamp as a scalar. |
47 | 0 | if (ev == FIRST_PAINT) { |
48 | 0 | bool error = false; |
49 | 0 | uint32_t firstPaintTime = (uint32_t) (Get(ev) - TimeStamp::ProcessCreation(&error)).ToMilliseconds(); |
50 | 0 | if (!error) { |
51 | 0 | Telemetry::ScalarSet(Telemetry::ScalarID::TIMESTAMPS_FIRST_PAINT, firstPaintTime); |
52 | 0 | } |
53 | 0 | } |
54 | 0 | } |