Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_DocLoadingTimelineMarker_h_
8 : #define mozilla_DocLoadingTimelineMarker_h_
9 :
10 : #include "TimelineMarker.h"
11 : #include "mozilla/dom/ProfileTimelineMarkerBinding.h"
12 :
13 : namespace mozilla {
14 :
15 0 : class DocLoadingTimelineMarker : public TimelineMarker
16 : {
17 : public:
18 0 : explicit DocLoadingTimelineMarker(const char* aName)
19 0 : : TimelineMarker(aName, MarkerTracingType::TIMESTAMP)
20 0 : , mUnixTime(PR_Now())
21 0 : {}
22 :
23 0 : virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override
24 : {
25 0 : TimelineMarker::AddDetails(aCx, aMarker);
26 0 : aMarker.mUnixTime.Construct(mUnixTime);
27 0 : }
28 :
29 : private:
30 : // Certain consumers might use Date.now() or similar for tracing time.
31 : // However, TimelineMarkers use process creation as an epoch, which provides
32 : // more precision. To allow syncing, attach an additional unix timestamp.
33 : // Using this instead of `AbstractTimelineMarker::GetTime()'s` timestamp
34 : // is strongly discouraged.
35 : PRTime mUnixTime;
36 : };
37 :
38 : } // namespace mozilla
39 :
40 : #endif // mozilla_DocLoadingTimelineMarker_h_
|