tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PerformanceEntry.cpp (1738B)


      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 "PerformanceEntry.h"
      8 
      9 #include "MainThreadUtils.h"
     10 
     11 using namespace mozilla::dom;
     12 
     13 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PerformanceEntry, mParent)
     14 
     15 NS_IMPL_CYCLE_COLLECTING_ADDREF(PerformanceEntry)
     16 NS_IMPL_CYCLE_COLLECTING_RELEASE(PerformanceEntry)
     17 
     18 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformanceEntry)
     19  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
     20  NS_INTERFACE_MAP_ENTRY(nsISupports)
     21 NS_INTERFACE_MAP_END
     22 
     23 PerformanceEntry::PerformanceEntry(nsISupports* aParent, const nsAString& aName,
     24                                   const nsStaticAtom* aEntryType)
     25    : mParent(aParent), mName(NS_Atomize(aName)), mEntryType(aEntryType) {}
     26 
     27 PerformanceEntry::~PerformanceEntry() = default;
     28 
     29 size_t PerformanceEntry::SizeOfExcludingThis(
     30    mozilla::MallocSizeOf aMallocSizeOf) const {
     31  // mName and mEntryType are considered to be owned by nsAtomTable.
     32  return 0;
     33 }
     34 
     35 size_t PerformanceEntry::SizeOfIncludingThis(
     36    mozilla::MallocSizeOf aMallocSizeOf) const {
     37  return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
     38 }
     39 
     40 bool PerformanceEntry::ShouldAddEntryToObserverBuffer(
     41    PerformanceObserverInit& aOption) const {
     42  if (aOption.mType.WasPassed()) {
     43    if (GetEntryType()->Equals(aOption.mType.Value())) {
     44      return true;
     45    }
     46  } else {
     47    if (aOption.mEntryTypes.Value().Contains(
     48            nsDependentAtomString(GetEntryType()))) {
     49      return true;
     50    }
     51  }
     52  return false;
     53 }