/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
class nsIConsoleReportCollector; class nsICookieJarSettings; class nsICSPEventListener; class nsIEventTarget; class nsIOutputStream; class nsILoadGroup; class nsIPrincipal;
namespace mozilla { class PreloaderBase;
namespace dom {
class Document; class InternalRequest; class InternalResponse; class PerformanceStorage; class PerformanceTimingData;
/** * Provides callbacks to be called when response is available or on error. * Implemenations usually resolve or reject the promise returned from fetch(). * The callbacks can be called synchronously or asynchronously from * FetchDriver::Fetch.
*/ class FetchDriverObserver { public:
FetchDriverObserver()
: mReporter(new ConsoleReportCollector()), mGotResponseAvailable(false) {}
// Called in OnStartRequest() to determine if the OnDataAvailable() method // needs to be called. Invoking that method may generate additional main // thread runnables. virtualbool NeedOnDataAvailable() = 0;
// Called once when the first byte of data is received iff // NeedOnDataAvailable() returned true when called in OnStartRequest(). virtualvoid OnDataAvailable() = 0;
class FetchDriver final : public nsIChannelEventSink, public nsIInterfaceRequestor, public nsINetworkInterceptController, public nsIThreadRetargetableStreamListener, public AbortFollower { public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSICHANNELEVENTSINK
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSINETWORKINTERCEPTCONTROLLER
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
// This is written once in OnStartRequest on the main thread and then // written/read in OnDataAvailable() on any thread. Necko guarantees // that these do not overlap. bool mNeedToObserveOnDataAvailable;
bool mIsTrackingFetch;
// Indicates whether the fetch request is from a third-party context.
Maybe<bool> mIsThirdPartyContext;
// Indicates whether the fetch request is on the 3PCB exception list. bool mIsOn3PCBExceptionList;
// This flag is true when this fetch has found a matching preload and is being // satisfied by a its response. bool mFromPreload = false; // This flag is set in call to Abort() and spans the possible window this // fetch doesn't have mChannel (to be cancelled) between reuse of the matching // preload, that has already finished and dropped reference to its channel, // and OnStartRequest notification. It let's us cancel the load when we get // the channel in OnStartRequest. bool mAborted = false;
nsresult HttpFetch(const nsACString& aPreferredAlternativeDataType = ""_ns); // Returns the filtered response sent to the observer.
SafeRefPtr<InternalResponse> BeginAndGetFilteredResponse(
SafeRefPtr<InternalResponse> aResponse, bool aFoundOpaqueRedirect); // Utility since not all cases need to do any post processing of the filtered // response. void FailWithNetworkError(nsresult rv);
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 ist noch experimentell.