Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/dom/media/doctor/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  DDLifetimes.cpp   Sprache: C

 
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "DDLifetimes.h"

#include "DDLogUtils.h"

namespace mozilla {

DDLifetime* DDLifetimes::FindLifetime(const DDLogObject& aObject,
                                      const DDMessageIndex& aIndex) {
  LifetimesForObject* lifetimes = mLifetimes.Get(aObject);
  if (lifetimes) {
    for (DDLifetime& lifetime : *lifetimes) {
      if (lifetime.mObject == aObject && lifetime.IsAliveAt(aIndex)) {
        return &lifetime;
      }
    }
  }
  return nullptr;
}

const DDLifetime* DDLifetimes::FindLifetime(
    const DDLogObject& aObject, const DDMessageIndex& aIndex) const {
  const LifetimesForObject* lifetimes = mLifetimes.Get(aObject);
  if (lifetimes) {
    for (const DDLifetime& lifetime : *lifetimes) {
      if (lifetime.mObject == aObject && lifetime.IsAliveAt(aIndex)) {
        return &lifetime;
      }
    }
  }
  return nullptr;
}

DDLifetime& DDLifetimes::CreateLifetime(
    const DDLogObject& aObject, DDMessageIndex aIndex,
    const DDTimeStamp& aConstructionTimeStamp) {
  // Use negative tags for yet-unclassified messages.
  static int32_t sTag = 0;
  if (--sTag > 0) {
    sTag = -1;
  }
  LifetimesForObject* lifetimes = mLifetimes.GetOrInsertNew(aObject, 1);
  DDLifetime& lifetime = *lifetimes->AppendElement(
      DDLifetime(aObject, aIndex, aConstructionTimeStamp, sTag));
  return lifetime;
}

void DDLifetimes::RemoveLifetime(const DDLifetime* aLifetime) {
  LifetimesForObject* lifetimes = mLifetimes.Get(aLifetime->mObject);
  MOZ_ASSERT(lifetimes);
  DDL_LOG(aLifetime->mMediaElement ? mozilla::LogLevel::Debug
                                   : mozilla::LogLevel::Warning,
          "Remove lifetime %s", aLifetime->Printf().get());
  // We should have been given a pointer inside this lifetimes array.
  auto arrayIndex = aLifetime - lifetimes->Elements();
  MOZ_ASSERT(static_cast<size_t>(arrayIndex) < lifetimes->Length());
  lifetimes->RemoveElementAt(arrayIndex);
}

void DDLifetimes::RemoveLifetimesFor(
    const dom::HTMLMediaElement* aMediaElement) {
  for (const auto& lifetimes : mLifetimes.Values()) {
    lifetimes->RemoveElementsBy([aMediaElement](const DDLifetime& lifetime) {
      return lifetime.mMediaElement == aMediaElement;
    });
  }
}

void DDLifetimes::Clear() { mLifetimes.Clear(); }

size_t DDLifetimes::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
  size_t size = mLifetimes.ShallowSizeOfExcludingThis(aMallocSizeOf);
  for (const auto& lifetimes : mLifetimes.Values()) {
    size += lifetimes->ShallowSizeOfExcludingThis(aMallocSizeOf);
  }
  return size;
}

}  // namespace mozilla

Messung V0.5
C=93 H=81 G=86

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.