Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / performance / PerformanceServerTiming.cpp
blobe5f056652db6b34f8ba58fc25caa58dfb66ba43b
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/. */
7 #include "PerformanceServerTiming.h"
8 #include "nsITimedChannel.h"
10 #include "mozilla/dom/PerformanceServerTimingBinding.h"
12 namespace mozilla::dom {
14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PerformanceServerTiming, mParent)
16 NS_IMPL_CYCLE_COLLECTING_ADDREF(PerformanceServerTiming)
17 NS_IMPL_CYCLE_COLLECTING_RELEASE(PerformanceServerTiming)
19 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformanceServerTiming)
20 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
21 NS_INTERFACE_MAP_ENTRY(nsISupports)
22 NS_INTERFACE_MAP_END
24 JSObject* PerformanceServerTiming::WrapObject(
25 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
26 return mozilla::dom::PerformanceServerTiming_Binding::Wrap(aCx, this,
27 aGivenProto);
30 void PerformanceServerTiming::GetName(nsAString& aName) const {
31 aName.Truncate();
33 if (!mServerTiming) {
34 return;
37 nsAutoCString name;
38 if (NS_WARN_IF(NS_FAILED(mServerTiming->GetName(name)))) {
39 return;
42 aName.Assign(NS_ConvertUTF8toUTF16(name));
45 DOMHighResTimeStamp PerformanceServerTiming::Duration() const {
46 if (!mServerTiming) {
47 return 0;
50 double duration = 0;
51 if (NS_WARN_IF(NS_FAILED(mServerTiming->GetDuration(&duration)))) {
52 return 0;
55 return duration;
58 void PerformanceServerTiming::GetDescription(nsAString& aDescription) const {
59 if (!mServerTiming) {
60 return;
63 nsAutoCString description;
64 if (NS_WARN_IF(NS_FAILED(mServerTiming->GetDescription(description)))) {
65 return;
68 aDescription.Assign(NS_ConvertUTF8toUTF16(description));
71 } // namespace mozilla::dom