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 : #include "AbstractTimelineMarker.h"
8 :
9 : #include "mozilla/TimeStamp.h"
10 : #include "MainThreadUtils.h"
11 : #include "nsAppRunner.h"
12 :
13 : namespace mozilla {
14 :
15 0 : AbstractTimelineMarker::AbstractTimelineMarker(const char* aName,
16 0 : MarkerTracingType aTracingType)
17 : : mName(aName)
18 : , mTracingType(aTracingType)
19 0 : , mProcessType(XRE_GetProcessType())
20 0 : , mIsOffMainThread(!NS_IsMainThread())
21 : {
22 0 : MOZ_COUNT_CTOR(AbstractTimelineMarker);
23 0 : SetCurrentTime();
24 0 : }
25 :
26 0 : AbstractTimelineMarker::AbstractTimelineMarker(const char* aName,
27 : const TimeStamp& aTime,
28 0 : MarkerTracingType aTracingType)
29 : : mName(aName)
30 : , mTracingType(aTracingType)
31 0 : , mProcessType(XRE_GetProcessType())
32 0 : , mIsOffMainThread(!NS_IsMainThread())
33 : {
34 0 : MOZ_COUNT_CTOR(AbstractTimelineMarker);
35 0 : SetCustomTime(aTime);
36 0 : }
37 :
38 : UniquePtr<AbstractTimelineMarker>
39 0 : AbstractTimelineMarker::Clone()
40 : {
41 0 : MOZ_ASSERT(false, "Clone method not yet implemented on this marker type.");
42 : return nullptr;
43 : }
44 :
45 : bool
46 0 : AbstractTimelineMarker::Equals(const AbstractTimelineMarker& aOther)
47 : {
48 : // Check whether two markers should be considered the same, for the purpose
49 : // of pairing start and end markers. Normally this definition suffices.
50 0 : return strcmp(mName, aOther.mName) == 0;
51 : }
52 :
53 0 : AbstractTimelineMarker::~AbstractTimelineMarker()
54 : {
55 0 : MOZ_COUNT_DTOR(AbstractTimelineMarker);
56 0 : }
57 :
58 : void
59 0 : AbstractTimelineMarker::SetCurrentTime()
60 : {
61 0 : TimeStamp now = TimeStamp::Now();
62 0 : SetCustomTime(now);
63 0 : }
64 :
65 : void
66 0 : AbstractTimelineMarker::SetCustomTime(const TimeStamp& aTime)
67 : {
68 0 : mTime = (aTime - TimeStamp::ProcessCreation()).ToMilliseconds();
69 0 : }
70 :
71 : void
72 0 : AbstractTimelineMarker::SetCustomTime(DOMHighResTimeStamp aTime)
73 : {
74 0 : mTime = aTime;
75 0 : }
76 :
77 : void
78 0 : AbstractTimelineMarker::SetProcessType(GeckoProcessType aProcessType)
79 : {
80 0 : mProcessType = aProcessType;
81 0 : }
82 :
83 : void
84 0 : AbstractTimelineMarker::SetOffMainThread(bool aIsOffMainThread)
85 : {
86 0 : mIsOffMainThread = aIsOffMainThread;
87 0 : }
88 :
89 : } // namespace mozilla
|