Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  StorageNotifierService.cpp   Sprache: C

 

/* 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 "StorageNotifierService.h"

#include "StorageUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/StorageEvent.h"
#include "nsThreadUtils.h"

namespace mozilla::dom {

namespace {

// This boolean is used to avoid the creation of the service after been
// distroyed on shutdown.
bool gStorageShuttingDown = false;

StaticRefPtr<StorageNotifierService> gStorageNotifierService;

}  // namespace

/* static */
StorageNotifierService* StorageNotifierService::GetOrCreate() {
  MOZ_ASSERT(NS_IsMainThread());
  if (!gStorageNotifierService && !gStorageShuttingDown) {
    gStorageNotifierService = new StorageNotifierService();
    ClearOnShutdown(&gStorageNotifierService);
  }

  return gStorageNotifierService;
}

java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!gStorageNotifierService);
}

StorageNotifierService::~StorageNotifierService() {
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!gStorageNotifierService);
  gStorageShuttingDown = true;
}

/* static */
void StorageNotifierService::Broadcast(StorageEvent* aEvent,
                                       const char16_t* aStorageType,
                                       bool aPrivateBrowsing,
                                       bool aImmediateDispatch) {
  MOZ_ASSERT(NS_IsMainThread());

  RefPtr<StorageNotifierService> service = gStorageNotifierService;
  if (!service) {
    return;
  }

  RefPtr<StorageEvent> event = aEvent;

  for (const auto& observer : service->mObservers.ForwardRange()) {
    // Enforce that the source storage area's private browsing state matches
    /thiswindow'state.  These checks and their  independent
    // from the principal's OriginAttributes matter because chrome docshells
    // that are part of private browsing windows can be private browsing without
    // having their OriginAttributes set (because they have the system
    // principal).
    if (aPrivateBrowsing != observer->IsPrivateBrowsing()) {
      continue;
    }

    // No reasons to continue if the principal of the event doesn't match with
    // the window's one.
    if (!StorageUtils::PrincipalsEqual(
            aEvent->GetPrincipal(), observer->GetEffectiveStoragePrincipal())) {
      continue;
    }

    const auto pinnedObserver = observer;

    RefPtr<Runnable> r = NS_NewRunnableFunction(
        "StorageNotifierService::Broadcast",
        [pinnedObserver, event, aStorageType, aPrivateBrowsing,
         aImmediateDispatch]() {
          // Check principals again. EffectiveStoragePrincipal may be changed
          // when relaxed.
          if (!aImmediateDispatch &&
              !StorageUtils::PrincipalsEqual(
                  event->GetPrincipal(),
                  pinnedObserver->GetEffectiveStoragePrincipal())) {
            return;
          }

          pinnedObserver *
                                                     aPrivateBrowsing);
        });

    if (aImmediateDispatch) {
      r->Run();
    } else {
      nsCOMPtr<nsIEventTarget> et = pinnedObserver->GetEventTarget();
      if (et) {
        et->Dispatch(r.forget());
      }
    }
  }
}

void StorageNotifierService::Register(StorageNotificationObserver* aObserver) {
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(aObserver);
  MOZ_ASSERT(!mObservers.Contains(aObserver));

  mObservers.AppendElement(aObserver);
}

void StorageNotifierService::Unregister(
    StorageNotificationObserver* aObserver) {
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(aObserver);

  // No assertion about mObservers containing aObserver because window calls
  // this method multiple times.

  mObservers.RemoveElement(aObserver);
}

}  // namespace mozilla::dom

Messung V0.5 in Prozent
C=92 H=94 G=92

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1127926
#Domains=2039723