Bug 1708193 - Remove mozapps/extensions/internal/Content.js r=rpl
[gecko.git] / dom / performance / PerformanceEntry.cpp
blobf9337cc1cefe8c24f07e594e0cb88d831ba854d2
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 "PerformanceEntry.h"
8 #include "MainThreadUtils.h"
10 using namespace mozilla::dom;
12 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PerformanceEntry, mParent)
14 NS_IMPL_CYCLE_COLLECTING_ADDREF(PerformanceEntry)
15 NS_IMPL_CYCLE_COLLECTING_RELEASE(PerformanceEntry)
17 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformanceEntry)
18 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
19 NS_INTERFACE_MAP_ENTRY(nsISupports)
20 NS_INTERFACE_MAP_END
22 PerformanceEntry::PerformanceEntry(nsISupports* aParent, const nsAString& aName,
23 const nsAString& aEntryType)
24 : mParent(aParent),
25 mName(NS_Atomize(aName)),
26 mEntryType(NS_Atomize(aEntryType)) {}
28 PerformanceEntry::~PerformanceEntry() = default;
30 size_t PerformanceEntry::SizeOfExcludingThis(
31 mozilla::MallocSizeOf aMallocSizeOf) const {
32 // mName and mEntryType are considered to be owned by nsAtomTable.
33 return 0;
36 size_t PerformanceEntry::SizeOfIncludingThis(
37 mozilla::MallocSizeOf aMallocSizeOf) const {
38 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
41 bool PerformanceEntry::ShouldAddEntryToObserverBuffer(
42 PerformanceObserverInit& aOption) const {
43 if (aOption.mType.WasPassed()) {
44 if (GetEntryType()->Equals(aOption.mType.Value())) {
45 return true;
47 } else {
48 if (aOption.mEntryTypes.Value().Contains(
49 nsDependentAtomString(GetEntryType()))) {
50 return true;
53 return false;