mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
d88565fb07
--HG-- extra : rebase_source : 2d2eb74428a28dac2cda779cc48dae1ed1367f26
87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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/. */
|
|
|
|
#ifndef mozilla_dom_FetchDriver_h
|
|
#define mozilla_dom_FetchDriver_h
|
|
|
|
#include "nsAutoPtr.h"
|
|
#include "nsIStreamListener.h"
|
|
#include "nsRefPtr.h"
|
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
class nsIOutputStream;
|
|
class nsILoadGroup;
|
|
class nsIPrincipal;
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
class BlobSet;
|
|
class InternalRequest;
|
|
class InternalResponse;
|
|
|
|
class FetchDriverObserver
|
|
{
|
|
public:
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FetchDriverObserver);
|
|
virtual void OnResponseAvailable(InternalResponse* aResponse) = 0;
|
|
virtual void OnResponseEnd() = 0;
|
|
|
|
protected:
|
|
virtual ~FetchDriverObserver()
|
|
{ };
|
|
};
|
|
|
|
class FetchDriver MOZ_FINAL : public nsIStreamListener
|
|
{
|
|
public:
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
explicit FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
|
|
nsILoadGroup* aLoadGroup);
|
|
NS_IMETHOD Fetch(FetchDriverObserver* aObserver);
|
|
|
|
private:
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
|
nsRefPtr<InternalRequest> mRequest;
|
|
nsRefPtr<InternalResponse> mResponse;
|
|
nsCOMPtr<nsIOutputStream> mPipeOutputStream;
|
|
nsRefPtr<FetchDriverObserver> mObserver;
|
|
uint32_t mFetchRecursionCount;
|
|
|
|
DebugOnly<bool> mResponseAvailableCalled;
|
|
|
|
FetchDriver() = delete;
|
|
FetchDriver(const FetchDriver&) = delete;
|
|
FetchDriver& operator=(const FetchDriver&) = delete;
|
|
~FetchDriver();
|
|
|
|
nsresult Fetch(bool aCORSFlag);
|
|
nsresult ContinueFetch(bool aCORSFlag);
|
|
nsresult BasicFetch();
|
|
nsresult HttpFetch(bool aCORSFlag = false, bool aPreflightCORSFlag = false, bool aAuthenticationFlag = false);
|
|
nsresult ContinueHttpFetchAfterServiceWorker();
|
|
nsresult ContinueHttpFetchAfterCORSPreflight();
|
|
nsresult HttpNetworkFetch();
|
|
nsresult ContinueHttpFetchAfterNetworkFetch();
|
|
// Returns the filtered response sent to the observer.
|
|
already_AddRefed<InternalResponse>
|
|
BeginAndGetFilteredResponse(InternalResponse* aResponse);
|
|
// Utility since not all cases need to do any post processing of the filtered
|
|
// response.
|
|
void BeginResponse(InternalResponse* aResponse);
|
|
nsresult FailWithNetworkError();
|
|
nsresult SucceedWithResponse();
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_dom_FetchDriver_h
|