Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/netwerk/protocol/res/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  MozSrcProtocolHandler.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 "mozilla/ModuleUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Omnijar.h"
#include "nsThreadUtils.h"

#include "MozSrcProtocolHandler.h"

#define MOZSRC_SCHEME "moz-src"

namespace mozilla {
namespace net {

NS_IMPL_QUERY_INTERFACE(MozSrcProtocolHandler, nsISubstitutingProtocolHandler,
                        nsIProtocolHandler, nsISupportsWeakReference)
NS_IMPL_ADDREF_INHERITED(MozSrcProtocolHandler, SubstitutingProtocolHandler)
NS_IMPL_RELEASE_INHERITED(MozSrcProtocolHandler, SubstitutingProtocolHandler)

mozilla::StaticMutex MozSrcProtocolHandler::sMutex;
mozilla::StaticRefPtr<MozSrcProtocolHandler> MozSrcProtocolHandler::sSingleton;

already_AddRefed<MozSrcProtocolHandler> MozSrcProtocolHandler::GetSingleton() {
  StaticMutexAutoLock lock(sMutex);
  if (!sSingleton) {
    RefPtr<MozSrcProtocolHandler> handler = new MozSrcProtocolHandler();
    if (NS_WARN_IF(NS_FAILED(handler->Init()))) {
      return nullptr;
    }
    sSingleton = handler;
    auto prevent_shutdown_race = [] {
      StaticMutexAutoLock lock(sMutex);
      sSingleton = nullptr;
    };
    if (NS_IsMainThread()) {
      RunOnShutdown(std::move(prevent_shutdown_race));
    } else {
      NS_DispatchToMainThread(NS_NewRunnableFunction(
          "MozSrcProtocolHandler::RunOnShutdown",
          [prevent_shutdown_race = std::move(prevent_shutdown_race)]() mutable {
            RunOnShutdown(std::move(prevent_shutdown_race));
          }));
    }
  }
  return do_AddRef(sSingleton);
}

MozSrcProtocolHandler::MozSrcProtocolHandler()
    : SubstitutingProtocolHandler(MOZSRC_SCHEME) {}

nsresult MozSrcProtocolHandler::Init() {
  nsresult rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::GRE, mGREURI);
  NS_ENSURE_SUCCESS(rv, rv);

  mGREURI.AppendLiteral(MOZSRC_SCHEME);

  return NS_OK;
}

bool MozSrcProtocolHandler::ResolveSpecialCases(const nsACString& aHost,
                                                const nsACString& aPath,
                                                const nsACString& aPathname,
                                                nsACString& aResult) {
  aResult = mGREURI;
  aResult.Append(aPathname);
  return true;
}

nsresult MozSrcProtocolHandler::GetSubstitutionInternal(const nsACString& aRoot,
                                                        nsIURI** aResult) {
  nsAutoCString uri;

  if (!ResolveSpecialCases(aRoot, "/"_ns, "/"_ns, uri)) {
    return NS_ERROR_NOT_AVAILABLE;
  }

  return NS_NewURI(aResult, uri);
}

}  // namespace net
}  // namespace mozilla

Messung V0.5 in Prozent
C=94 H=92 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.