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/. */
7 #ifndef mozilla_dom_performancemark_h___
8 #define mozilla_dom_performancemark_h___
10 #include "mozilla/dom/PerformanceEntry.h"
11 #include "mozilla/ProfilerMarkers.h"
13 namespace mozilla::dom
{
15 struct PerformanceMarkOptions
;
17 // http://www.w3.org/TR/user-timing/#performancemark
18 class PerformanceMark final
: public PerformanceEntry
{
20 NS_DECL_ISUPPORTS_INHERITED
21 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMark
,
25 PerformanceMark(nsISupports
* aParent
, const nsAString
& aName
,
26 DOMHighResTimeStamp aStartTime
,
27 const JS::Handle
<JS::Value
>& aDetail
,
28 DOMHighResTimeStamp aUnclampedStartTime
);
31 static already_AddRefed
<PerformanceMark
> Constructor(
32 const GlobalObject
& aGlobal
, const nsAString
& aMarkName
,
33 const PerformanceMarkOptions
& aMarkOptions
, ErrorResult
& aRv
);
35 static already_AddRefed
<PerformanceMark
> Constructor(
36 JSContext
* aCx
, nsIGlobalObject
* aGlobal
, const nsAString
& aMarkName
,
37 const PerformanceMarkOptions
& aMarkOptions
, ErrorResult
& aRv
);
39 virtual JSObject
* WrapObject(JSContext
* aCx
,
40 JS::Handle
<JSObject
*> aGivenProto
) override
;
42 virtual DOMHighResTimeStamp
StartTime() const override
{ return mStartTime
; }
44 virtual DOMHighResTimeStamp
UnclampedStartTime() const override
{
45 MOZ_ASSERT(profiler_thread_is_being_profiled_for_markers(),
46 "This should only be called when the Gecko Profiler is active.");
47 return mUnclampedStartTime
;
50 void GetDetail(JSContext
* aCx
, JS::MutableHandle
<JS::Value
> aRetval
);
52 size_t SizeOfIncludingThis(
53 mozilla::MallocSizeOf aMallocSizeOf
) const override
;
56 virtual ~PerformanceMark();
57 DOMHighResTimeStamp mStartTime
;
60 JS::Heap
<JS::Value
> mDetail
;
61 // This is used by the Gecko Profiler only to be able to add precise markers.
62 // It's not exposed to JS
63 DOMHighResTimeStamp mUnclampedStartTime
;
66 } // namespace mozilla::dom
68 #endif /* mozilla_dom_performancemark_h___ */