Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/performance/PerformanceNavigationTiming.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 "mozilla/dom/PerformanceNavigationTiming.h"
8
#include "mozilla/dom/PerformanceNavigationTimingBinding.h"
9
10
using namespace mozilla::dom;
11
12
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformanceNavigationTiming)
13
0
NS_INTERFACE_MAP_END_INHERITING(PerformanceResourceTiming)
14
15
NS_IMPL_ADDREF_INHERITED(PerformanceNavigationTiming, PerformanceResourceTiming)
16
NS_IMPL_RELEASE_INHERITED(PerformanceNavigationTiming, PerformanceResourceTiming)
17
18
JSObject*
19
PerformanceNavigationTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
20
0
{
21
0
  return PerformanceNavigationTiming_Binding::Wrap(aCx, this, aGivenProto);
22
0
}
23
24
#define REDUCE_TIME_PRECISION                               \
25
0
  if (mPerformance->IsSystemPrincipal()) {                  \
26
0
    return rawValue;                                        \
27
0
  }                                                         \
28
0
  return nsRFPService::ReduceTimePrecisionAsMSecs(rawValue, \
29
0
    mPerformance->GetRandomTimelineSeed())
30
31
DOMHighResTimeStamp
32
PerformanceNavigationTiming::UnloadEventStart() const
33
0
{
34
0
  DOMHighResTimeStamp rawValue =
35
0
    mPerformance->GetDOMTiming()->GetUnloadEventStartHighRes();
36
0
37
0
  REDUCE_TIME_PRECISION;
38
0
}
39
40
DOMHighResTimeStamp
41
PerformanceNavigationTiming::UnloadEventEnd() const
42
0
{
43
0
  DOMHighResTimeStamp rawValue =
44
0
    mPerformance->GetDOMTiming()->GetUnloadEventEndHighRes();
45
0
46
0
  REDUCE_TIME_PRECISION;
47
0
}
48
49
DOMHighResTimeStamp
50
PerformanceNavigationTiming::DomInteractive() const
51
0
{
52
0
  DOMHighResTimeStamp rawValue =
53
0
    mPerformance->GetDOMTiming()->GetDomInteractiveHighRes();
54
0
55
0
  REDUCE_TIME_PRECISION;
56
0
}
57
58
DOMHighResTimeStamp
59
PerformanceNavigationTiming::DomContentLoadedEventStart() const
60
0
{
61
0
  DOMHighResTimeStamp rawValue =
62
0
    mPerformance->GetDOMTiming()->GetDomContentLoadedEventStartHighRes();
63
0
64
0
  REDUCE_TIME_PRECISION;
65
0
}
66
67
DOMHighResTimeStamp
68
PerformanceNavigationTiming::DomContentLoadedEventEnd() const
69
0
{
70
0
  DOMHighResTimeStamp rawValue =
71
0
    mPerformance->GetDOMTiming()->GetDomContentLoadedEventEndHighRes();
72
0
73
0
  REDUCE_TIME_PRECISION;
74
0
}
75
76
DOMHighResTimeStamp
77
PerformanceNavigationTiming::DomComplete() const
78
0
{
79
0
  DOMHighResTimeStamp rawValue =
80
0
    mPerformance->GetDOMTiming()->GetDomCompleteHighRes();
81
0
82
0
  REDUCE_TIME_PRECISION;
83
0
}
84
85
DOMHighResTimeStamp
86
PerformanceNavigationTiming::LoadEventStart() const
87
0
{
88
0
  DOMHighResTimeStamp rawValue =
89
0
    mPerformance->GetDOMTiming()->GetLoadEventStartHighRes();
90
0
91
0
  REDUCE_TIME_PRECISION;
92
0
}
93
94
DOMHighResTimeStamp
95
PerformanceNavigationTiming::LoadEventEnd() const
96
0
{
97
0
  DOMHighResTimeStamp rawValue =
98
0
    mPerformance->GetDOMTiming()->GetLoadEventEndHighRes();
99
0
100
0
  REDUCE_TIME_PRECISION;
101
0
}
102
103
NavigationType
104
PerformanceNavigationTiming::Type() const
105
0
{
106
0
  switch(mPerformance->GetDOMTiming()->GetType()) {
107
0
    case nsDOMNavigationTiming::TYPE_NAVIGATE:
108
0
      return NavigationType::Navigate;
109
0
      break;
110
0
    case nsDOMNavigationTiming::TYPE_RELOAD:
111
0
      return NavigationType::Reload;
112
0
      break;
113
0
    case nsDOMNavigationTiming::TYPE_BACK_FORWARD:
114
0
      return NavigationType::Back_forward;
115
0
      break;
116
0
    default:
117
0
      // The type is TYPE_RESERVED or some other value that was later added.
118
0
      // We fallback to the default of Navigate.
119
0
      return NavigationType::Navigate;
120
0
  }
121
0
}
122
123
uint16_t
124
PerformanceNavigationTiming::RedirectCount() const
125
0
{
126
0
  return mTimingData->GetRedirectCount();
127
0
}
128
129
void
130
PerformanceNavigationTiming::UpdatePropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel,
131
                                                             nsITimedChannel* aChannel)
132
0
{
133
0
  mTimingData->SetPropertiesFromHttpChannel(aHttpChannel, aChannel);
134
0
}