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_TimelineMarker_h_
8 : #define mozilla_TimelineMarker_h_
9 :
10 : #include "AbstractTimelineMarker.h"
11 : #include "js/RootingAPI.h"
12 :
13 : namespace mozilla {
14 :
15 : // Objects of this type can be added to the timeline if there is an interested
16 : // consumer. The class can also be subclassed to let a given marker creator
17 : // provide custom details.
18 0 : class TimelineMarker : public AbstractTimelineMarker
19 : {
20 : public:
21 : TimelineMarker(const char* aName,
22 : MarkerTracingType aTracingType,
23 : MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
24 :
25 : TimelineMarker(const char* aName,
26 : const TimeStamp& aTime,
27 : MarkerTracingType aTracingType,
28 : MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
29 :
30 : virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override;
31 : virtual JSObject* GetStack() override;
32 :
33 : protected:
34 : void CaptureStack();
35 :
36 : private:
37 : // While normally it is not a good idea to make a persistent root,
38 : // in this case changing nsDocShell to participate in cycle
39 : // collection was deemed too invasive, and the markers are only held
40 : // here temporarily to boot.
41 : JS::PersistentRooted<JSObject*> mStackTrace;
42 :
43 : void CaptureStackIfNecessary(MarkerTracingType aTracingType,
44 : MarkerStackRequest aStackRequest);
45 : };
46 :
47 : } // namespace mozilla
48 :
49 : #endif /* mozilla_TimelineMarker_h_ */
|