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_ConsoleTimelineMarker_h_
8 : #define mozilla_ConsoleTimelineMarker_h_
9 :
10 : #include "TimelineMarker.h"
11 : #include "mozilla/dom/ProfileTimelineMarkerBinding.h"
12 :
13 : namespace mozilla {
14 :
15 0 : class ConsoleTimelineMarker : public TimelineMarker
16 : {
17 : public:
18 0 : ConsoleTimelineMarker(const nsAString& aCause,
19 : MarkerTracingType aTracingType)
20 0 : : TimelineMarker("ConsoleTime", aTracingType)
21 0 : , mCause(aCause)
22 : {
23 : // Stack is captured by default on the "start" marker. Explicitly also
24 : // capture stack on the "end" marker.
25 0 : if (aTracingType == MarkerTracingType::END) {
26 0 : CaptureStack();
27 : }
28 0 : }
29 :
30 0 : virtual bool Equals(const AbstractTimelineMarker& aOther) override
31 : {
32 0 : if (!TimelineMarker::Equals(aOther)) {
33 0 : return false;
34 : }
35 : // Console markers must have matching causes as well. It is safe to perform
36 : // a static_cast here as the previous equality check ensures that this is
37 : // a console marker instance.
38 0 : return mCause == static_cast<const ConsoleTimelineMarker*>(&aOther)->mCause;
39 : }
40 :
41 0 : virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override
42 : {
43 0 : TimelineMarker::AddDetails(aCx, aMarker);
44 :
45 0 : if (GetTracingType() == MarkerTracingType::START) {
46 0 : aMarker.mCauseName.Construct(mCause);
47 : } else {
48 0 : aMarker.mEndStack = GetStack();
49 : }
50 0 : }
51 :
52 : private:
53 : nsString mCause;
54 : };
55 :
56 : } // namespace mozilla
57 :
58 : #endif // mozilla_ConsoleTimelineMarker_h_
|