Coverage Report

Created: 2018-09-25 14:53

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