Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/performance/PerformanceServerTiming.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 "PerformanceServerTiming.h"
8
9
#include "mozilla/dom/PerformanceServerTimingBinding.h"
10
#include "nsITimedChannel.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PerformanceServerTiming, mParent)
16
17
NS_IMPL_CYCLE_COLLECTING_ADDREF(PerformanceServerTiming)
18
NS_IMPL_CYCLE_COLLECTING_RELEASE(PerformanceServerTiming)
19
20
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformanceServerTiming)
21
0
  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
22
0
  NS_INTERFACE_MAP_ENTRY(nsISupports)
23
0
NS_INTERFACE_MAP_END
24
25
JSObject*
26
PerformanceServerTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
27
0
{
28
0
  return mozilla::dom::PerformanceServerTiming_Binding::Wrap(aCx, this, aGivenProto);
29
0
}
30
31
void
32
PerformanceServerTiming::GetName(nsAString& aName) const
33
0
{
34
0
  aName.Truncate();
35
0
36
0
  if (!mServerTiming) {
37
0
    return;
38
0
  }
39
0
40
0
  nsAutoCString name;
41
0
  if (NS_WARN_IF(NS_FAILED(mServerTiming->GetName(name)))) {
42
0
    return;
43
0
  }
44
0
45
0
  aName.Assign(NS_ConvertUTF8toUTF16(name));
46
0
}
47
48
DOMHighResTimeStamp
49
PerformanceServerTiming::Duration() const
50
0
{
51
0
  if (!mServerTiming) {
52
0
    return 0;
53
0
  }
54
0
55
0
  double duration = 0;
56
0
  if (NS_WARN_IF(NS_FAILED(mServerTiming->GetDuration(&duration)))) {
57
0
    return 0;
58
0
  }
59
0
60
0
  return duration;
61
0
}
62
63
void
64
PerformanceServerTiming::GetDescription(nsAString& aDescription) const
65
0
{
66
0
  if (!mServerTiming) {
67
0
    return;
68
0
  }
69
0
70
0
  nsAutoCString description;
71
0
  if (NS_WARN_IF(NS_FAILED(mServerTiming->GetDescription(description)))) {
72
0
    return;
73
0
  }
74
0
75
0
  aDescription.Assign(NS_ConvertUTF8toUTF16(description));
76
0
}
77
78
} // dom namespace
79
} // mozilla namespace