summaryrefslogtreecommitdiffstats
path: root/docshell/base/timeline/AbstractTimelineMarker.h
blob: 516b44eb0b6e6af7f387eca7d9d63e7cc657d42d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_AbstractTimelineMarker_h_
#define mozilla_AbstractTimelineMarker_h_

#include "TimelineMarkerEnums.h" // for MarkerTracingType
#include "nsDOMNavigationTiming.h" // for DOMHighResTimeStamp
#include "nsXULAppAPI.h" // for GeckoProcessType
#include "mozilla/UniquePtr.h"

struct JSContext;
class JSObject;

namespace mozilla {
class TimeStamp;

namespace dom {
struct ProfileTimelineMarker;
}

class AbstractTimelineMarker
{
private:
  AbstractTimelineMarker() = delete;
  AbstractTimelineMarker(const AbstractTimelineMarker& aOther) = delete;
  void operator=(const AbstractTimelineMarker& aOther) = delete;

public:
  AbstractTimelineMarker(const char* aName,
                         MarkerTracingType aTracingType);

  AbstractTimelineMarker(const char* aName,
                         const TimeStamp& aTime,
                         MarkerTracingType aTracingType);

  virtual ~AbstractTimelineMarker();

  virtual UniquePtr<AbstractTimelineMarker> Clone();
  virtual bool Equals(const AbstractTimelineMarker& aOther);

  virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) = 0;
  virtual JSObject* GetStack() = 0;

  const char* GetName() const { return mName; }
  DOMHighResTimeStamp GetTime() const { return mTime; }
  MarkerTracingType GetTracingType() const { return mTracingType; }

  uint8_t GetProcessType() const { return mProcessType; };
  bool IsOffMainThread() const { return mIsOffMainThread; };

private:
  const char* mName;
  DOMHighResTimeStamp mTime;
  MarkerTracingType mTracingType;

  uint8_t mProcessType; // @see `enum GeckoProcessType`.
  bool mIsOffMainThread;

protected:
  void SetCurrentTime();
  void SetCustomTime(const TimeStamp& aTime);
  void SetCustomTime(DOMHighResTimeStamp aTime);
  void SetProcessType(GeckoProcessType aProcessType);
  void SetOffMainThread(bool aIsOffMainThread);
};

} // namespace mozilla

#endif /* mozilla_AbstractTimelineMarker_h_ */