зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 5853ea69f6c4 (bug 1263991)
This commit is contained in:
Родитель
493f097700
Коммит
a62eba3cef
|
@ -9,13 +9,13 @@ include IPCStream;
|
|||
include ChannelInfo;
|
||||
include PBackgroundSharedTypes;
|
||||
|
||||
using HeadersGuardEnum from "mozilla/dom/FetchIPCTypes.h";
|
||||
using ReferrerPolicy from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestCredentials from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestMode from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestCache from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestRedirect from "mozilla/dom/FetchIPCTypes.h";
|
||||
using ResponseType from "mozilla/dom/FetchIPCTypes.h";
|
||||
using HeadersGuardEnum from "mozilla/dom/cache/IPCUtils.h";
|
||||
using ReferrerPolicy from "mozilla/dom/cache/IPCUtils.h";
|
||||
using RequestCredentials from "mozilla/dom/cache/IPCUtils.h";
|
||||
using RequestMode from "mozilla/dom/cache/IPCUtils.h";
|
||||
using RequestCache from "mozilla/dom/cache/IPCUtils.h";
|
||||
using RequestRedirect from "mozilla/dom/cache/IPCUtils.h";
|
||||
using ResponseType from "mozilla/dom/cache/IPCUtils.h";
|
||||
using mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
using struct nsID from "nsID.h";
|
||||
|
||||
|
|
|
@ -9,10 +9,51 @@
|
|||
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
|
||||
// Fix X11 header brain damage that conflicts with HeadersGuardEnum::None
|
||||
#undef None
|
||||
|
||||
#include "mozilla/dom/HeadersBinding.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/ResponseBinding.h"
|
||||
#include "mozilla/dom/cache/Types.h"
|
||||
|
||||
namespace IPC {
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::HeadersGuardEnum> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::HeadersGuardEnum,
|
||||
mozilla::dom::HeadersGuardEnum::None,
|
||||
mozilla::dom::HeadersGuardEnum::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::ReferrerPolicy> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::ReferrerPolicy,
|
||||
mozilla::dom::ReferrerPolicy::_empty,
|
||||
mozilla::dom::ReferrerPolicy::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestMode> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestMode,
|
||||
mozilla::dom::RequestMode::Same_origin,
|
||||
mozilla::dom::RequestMode::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestCredentials> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestCredentials,
|
||||
mozilla::dom::RequestCredentials::Omit,
|
||||
mozilla::dom::RequestCredentials::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestCache> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestCache,
|
||||
mozilla::dom::RequestCache::Default,
|
||||
mozilla::dom::RequestCache::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestRedirect> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestRedirect,
|
||||
mozilla::dom::RequestRedirect::Follow,
|
||||
mozilla::dom::RequestRedirect::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::ResponseType> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::ResponseType,
|
||||
mozilla::dom::ResponseType::Basic,
|
||||
mozilla::dom::ResponseType::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::cache::Namespace> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::cache::Namespace,
|
||||
mozilla::dom::cache::DEFAULT_NAMESPACE,
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_fetch_IPCUtils_h
|
||||
#define mozilla_dom_fetch_IPCUtils_h
|
||||
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
|
||||
// Fix X11 header brain damage that conflicts with HeadersGuardEnum::None
|
||||
#undef None
|
||||
|
||||
#include "mozilla/dom/HeadersBinding.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/ResponseBinding.h"
|
||||
|
||||
namespace IPC {
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::HeadersGuardEnum> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::HeadersGuardEnum,
|
||||
mozilla::dom::HeadersGuardEnum::None,
|
||||
mozilla::dom::HeadersGuardEnum::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::ReferrerPolicy> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::ReferrerPolicy,
|
||||
mozilla::dom::ReferrerPolicy::_empty,
|
||||
mozilla::dom::ReferrerPolicy::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestMode> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestMode,
|
||||
mozilla::dom::RequestMode::Same_origin,
|
||||
mozilla::dom::RequestMode::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestCredentials> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestCredentials,
|
||||
mozilla::dom::RequestCredentials::Omit,
|
||||
mozilla::dom::RequestCredentials::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestCache> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestCache,
|
||||
mozilla::dom::RequestCache::Default,
|
||||
mozilla::dom::RequestCache::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::RequestRedirect> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::RequestRedirect,
|
||||
mozilla::dom::RequestRedirect::Follow,
|
||||
mozilla::dom::RequestRedirect::EndGuard_> {};
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::ResponseType> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::ResponseType,
|
||||
mozilla::dom::ResponseType::Basic,
|
||||
mozilla::dom::ResponseType::EndGuard_> {};
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_dom_fetch_IPCUtils_h
|
|
@ -1,59 +0,0 @@
|
|||
/* 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 IPCStream;
|
||||
include ChannelInfo;
|
||||
include PBackgroundSharedTypes;
|
||||
|
||||
using HeadersGuardEnum from "mozilla/dom/FetchIPCTypes.h";
|
||||
using ReferrerPolicy from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestCredentials from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestMode from "mozilla/dom/FetchIPCTypes.h";
|
||||
using ResponseType from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestRedirect from "mozilla/dom/FetchIPCTypes.h";
|
||||
using RequestCache from "mozilla/dom/FetchIPCTypes.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
struct HeadersEntry
|
||||
{
|
||||
nsCString name;
|
||||
nsCString value;
|
||||
};
|
||||
|
||||
// Note, this does not yet serialize *all* of InternalRequest
|
||||
// Make sure that it contains the fields that you care about
|
||||
struct IPCInternalRequest
|
||||
{
|
||||
nsCString[] urls;
|
||||
nsCString method;
|
||||
HeadersEntry[] headers;
|
||||
HeadersGuardEnum headersGuard;
|
||||
nsString referrer;
|
||||
ReferrerPolicy referrerPolicy;
|
||||
RequestMode mode;
|
||||
RequestCredentials credentials;
|
||||
uint32_t contentPolicyType;
|
||||
RequestCache requestCache;
|
||||
RequestRedirect requestRedirect;
|
||||
};
|
||||
|
||||
// Note, this does not yet serialize *all* of InternalResponse
|
||||
// Make sure that it contains the fields that you care about
|
||||
struct IPCInternalResponse
|
||||
{
|
||||
ResponseType type;
|
||||
nsCString[] urlList;
|
||||
uint32_t status;
|
||||
nsCString statusText;
|
||||
HeadersEntry[] headers;
|
||||
HeadersGuardEnum headersGuard;
|
||||
IPCChannelInfo channelInfo;
|
||||
OptionalPrincipalInfo principalInfo;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "mozilla/dom/InternalHeaders.h"
|
||||
|
||||
#include "mozilla/dom/FetchTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
|
@ -24,27 +23,6 @@ InternalHeaders::InternalHeaders(const nsTArray<Entry>&& aHeaders,
|
|||
{
|
||||
}
|
||||
|
||||
InternalHeaders::InternalHeaders(const nsTArray<HeadersEntry>& aHeadersEntryList,
|
||||
HeadersGuardEnum aGuard)
|
||||
: mGuard(aGuard)
|
||||
{
|
||||
for (const HeadersEntry& headersEntry : aHeadersEntryList) {
|
||||
mList.AppendElement(Entry(headersEntry.name(), headersEntry.value()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InternalHeaders::ToIPC(nsTArray<HeadersEntry>& aIPCHeaders,
|
||||
HeadersGuardEnum& aGuard)
|
||||
{
|
||||
aGuard = mGuard;
|
||||
|
||||
aIPCHeaders.Clear();
|
||||
for (Entry& entry : mList) {
|
||||
aIPCHeaders.AppendElement(HeadersEntry(entry.mName, entry.mValue));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InternalHeaders::Append(const nsACString& aName, const nsACString& aValue,
|
||||
ErrorResult& aRv)
|
||||
|
|
|
@ -21,7 +21,6 @@ class ErrorResult;
|
|||
namespace dom {
|
||||
|
||||
template<typename T> class MozMap;
|
||||
class HeadersEntry;
|
||||
|
||||
class InternalHeaders final
|
||||
{
|
||||
|
@ -65,12 +64,6 @@ public:
|
|||
explicit InternalHeaders(const nsTArray<Entry>&& aHeaders,
|
||||
HeadersGuardEnum aGuard = HeadersGuardEnum::None);
|
||||
|
||||
InternalHeaders(const nsTArray<HeadersEntry>& aHeadersEntryList,
|
||||
HeadersGuardEnum aGuard);
|
||||
|
||||
void ToIPC(nsTArray<HeadersEntry>& aIPCHeaders,
|
||||
HeadersGuardEnum& aGuard);
|
||||
|
||||
void Append(const nsACString& aName, const nsACString& aValue,
|
||||
ErrorResult& aRv);
|
||||
void Delete(const nsACString& aName, ErrorResult& aRv);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "nsStreamUtils.h"
|
||||
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/FetchTypes.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
|
||||
|
@ -103,45 +102,10 @@ InternalRequest::InternalRequest(const InternalRequest& aOther)
|
|||
// NOTE: does not copy body stream... use the fallible Clone() for that
|
||||
}
|
||||
|
||||
InternalRequest::InternalRequest(const IPCInternalRequest& aIPCRequest)
|
||||
: mMethod(aIPCRequest.method())
|
||||
, mURLList(aIPCRequest.urls())
|
||||
, mHeaders(new InternalHeaders(aIPCRequest.headers(),
|
||||
aIPCRequest.headersGuard()))
|
||||
, mContentPolicyType(aIPCRequest.contentPolicyType())
|
||||
, mReferrer(aIPCRequest.referrer())
|
||||
, mReferrerPolicy(aIPCRequest.referrerPolicy())
|
||||
, mMode(aIPCRequest.mode())
|
||||
, mCredentialsMode(aIPCRequest.credentials())
|
||||
, mCacheMode(aIPCRequest.requestCache())
|
||||
, mRedirectMode(aIPCRequest.requestRedirect())
|
||||
{
|
||||
MOZ_ASSERT(!mURLList.IsEmpty());
|
||||
}
|
||||
|
||||
InternalRequest::~InternalRequest()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
InternalRequest::ToIPC(IPCInternalRequest* aIPCRequest)
|
||||
{
|
||||
MOZ_ASSERT(aIPCRequest);
|
||||
MOZ_ASSERT(!mURLList.IsEmpty());
|
||||
aIPCRequest->urls() = mURLList;
|
||||
aIPCRequest->method() = mMethod;
|
||||
|
||||
mHeaders->ToIPC(aIPCRequest->headers(), aIPCRequest->headersGuard());
|
||||
|
||||
aIPCRequest->referrer() = mReferrer;
|
||||
aIPCRequest->referrerPolicy() = mReferrerPolicy;
|
||||
aIPCRequest->mode() = mMode;
|
||||
aIPCRequest->credentials() = mCredentialsMode;
|
||||
aIPCRequest->contentPolicyType() = mContentPolicyType;
|
||||
aIPCRequest->requestCache() = mCacheMode;
|
||||
aIPCRequest->requestRedirect() = mRedirectMode;
|
||||
}
|
||||
|
||||
void
|
||||
InternalRequest::SetContentPolicyType(nsContentPolicyType aContentPolicyType)
|
||||
{
|
||||
|
|
|
@ -78,7 +78,6 @@ namespace dom {
|
|||
*/
|
||||
|
||||
class Request;
|
||||
class IPCInternalRequest;
|
||||
|
||||
#define kFETCH_CLIENT_REFERRER_STR "about:client"
|
||||
|
||||
|
@ -151,10 +150,6 @@ public:
|
|||
AddURL(aURL);
|
||||
}
|
||||
|
||||
InternalRequest(const IPCInternalRequest& aIPCRequest);
|
||||
|
||||
void ToIPC(IPCInternalRequest* aIPCRequest);
|
||||
|
||||
already_AddRefed<InternalRequest> Clone();
|
||||
|
||||
void
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "mozilla/dom/FetchTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -26,78 +25,10 @@ InternalResponse::InternalResponse(uint16_t aStatus, const nsACString& aStatusTe
|
|||
{
|
||||
}
|
||||
|
||||
already_AddRefed<InternalResponse>
|
||||
InternalResponse::FromIPC(const IPCInternalResponse& aIPCResponse)
|
||||
{
|
||||
MOZ_ASSERT(!aIPCResponse.urlList().IsEmpty());
|
||||
|
||||
if (aIPCResponse.type() == ResponseType::Error) {
|
||||
return InternalResponse::NetworkError();
|
||||
}
|
||||
|
||||
RefPtr<InternalResponse> response =
|
||||
new InternalResponse(aIPCResponse.status(),
|
||||
aIPCResponse.statusText());
|
||||
|
||||
response->SetURLList(aIPCResponse.urlList());
|
||||
|
||||
response->mHeaders = new InternalHeaders(aIPCResponse.headers(),
|
||||
aIPCResponse.headersGuard());
|
||||
|
||||
response->InitChannelInfo(aIPCResponse.channelInfo());
|
||||
if (aIPCResponse.principalInfo().type() == mozilla::ipc::OptionalPrincipalInfo::TPrincipalInfo) {
|
||||
UniquePtr<mozilla::ipc::PrincipalInfo> info(new mozilla::ipc::PrincipalInfo(aIPCResponse.principalInfo().get_PrincipalInfo()));
|
||||
response->SetPrincipalInfo(Move(info));
|
||||
}
|
||||
|
||||
switch (aIPCResponse.type())
|
||||
{
|
||||
case ResponseType::Basic:
|
||||
response = response->BasicResponse();
|
||||
break;
|
||||
case ResponseType::Cors:
|
||||
response = response->CORSResponse();
|
||||
break;
|
||||
case ResponseType::Default:
|
||||
break;
|
||||
case ResponseType::Opaque:
|
||||
response = response->OpaqueResponse();
|
||||
break;
|
||||
case ResponseType::Opaqueredirect:
|
||||
response = response->OpaqueRedirectResponse();
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Unexpected ResponseType!");
|
||||
}
|
||||
MOZ_ASSERT(response);
|
||||
|
||||
return response.forget();
|
||||
}
|
||||
|
||||
InternalResponse::~InternalResponse()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
InternalResponse::ToIPC(IPCInternalResponse* aIPCResponse)
|
||||
{
|
||||
MOZ_ASSERT(aIPCResponse);
|
||||
MOZ_ASSERT(!mURLList.IsEmpty());
|
||||
aIPCResponse->type() = mType;
|
||||
aIPCResponse->urlList() = mURLList;
|
||||
aIPCResponse->status() = GetUnfilteredStatus();
|
||||
aIPCResponse->statusText() = GetUnfilteredStatusText();
|
||||
|
||||
mHeaders->ToIPC(aIPCResponse->headers(), aIPCResponse->headersGuard());
|
||||
|
||||
aIPCResponse->channelInfo() = mChannelInfo.AsIPCChannelInfo();
|
||||
if (mPrincipalInfo) {
|
||||
aIPCResponse->principalInfo() = *mPrincipalInfo;
|
||||
} else {
|
||||
aIPCResponse->principalInfo() = void_t();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<InternalResponse>
|
||||
InternalResponse::Clone()
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@ class PrincipalInfo;
|
|||
namespace dom {
|
||||
|
||||
class InternalHeaders;
|
||||
class IPCInternalResponse;
|
||||
|
||||
class InternalResponse final
|
||||
{
|
||||
|
@ -33,11 +32,6 @@ public:
|
|||
|
||||
InternalResponse(uint16_t aStatus, const nsACString& aStatusText);
|
||||
|
||||
static already_AddRefed<InternalResponse>
|
||||
FromIPC(const IPCInternalResponse& aIPCResponse);
|
||||
|
||||
void ToIPC(IPCInternalResponse* aIPCResponse);
|
||||
|
||||
already_AddRefed<InternalResponse> Clone();
|
||||
|
||||
static already_AddRefed<InternalResponse>
|
||||
|
|
|
@ -8,7 +8,6 @@ EXPORTS.mozilla.dom += [
|
|||
'ChannelInfo.h',
|
||||
'Fetch.h',
|
||||
'FetchDriver.h',
|
||||
'FetchIPCTypes.h',
|
||||
'FetchUtil.h',
|
||||
'Headers.h',
|
||||
'InternalHeaders.h',
|
||||
|
@ -33,7 +32,6 @@ UNIFIED_SOURCES += [
|
|||
|
||||
IPDL_SOURCES += [
|
||||
'ChannelInfo.ipdlh',
|
||||
'FetchTypes.ipdlh',
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include "mozilla/dom/Request.h"
|
||||
#include "mozilla/dom/FlyWebServerEvents.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/InternalResponse.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
|
@ -263,19 +261,6 @@ FlyWebPublishedServerChild::RecvServerClose()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
FlyWebPublishedServerChild::RecvFetchRequest(const IPCInternalRequest& aRequest,
|
||||
const uint64_t& aRequestId)
|
||||
{
|
||||
LOG_I("FlyWebPublishedServerChild::RecvFetchRequest(%p)", this);
|
||||
|
||||
RefPtr<InternalRequest> request = new InternalRequest(aRequest);
|
||||
mPendingRequests.Put(request, aRequestId);
|
||||
FireFetchEvent(request);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
FlyWebPublishedServerChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
|
@ -288,20 +273,7 @@ void
|
|||
FlyWebPublishedServerChild::OnFetchResponse(InternalRequest* aRequest,
|
||||
InternalResponse* aResponse)
|
||||
{
|
||||
LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p)", this);
|
||||
|
||||
if (mActorDestroyed) {
|
||||
LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p) - No actor!", this);
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t id = mPendingRequests.Get(aRequest);
|
||||
MOZ_ASSERT(id);
|
||||
mPendingRequests.Remove(aRequest);
|
||||
|
||||
IPCInternalResponse ipcResp;
|
||||
aResponse->ToIPC(&ipcResp);
|
||||
Unused << SendFetchResponse(ipcResp, id);
|
||||
// Send ipdl message to parent
|
||||
}
|
||||
|
||||
already_AddRefed<WebSocket>
|
||||
|
@ -336,12 +308,9 @@ FlyWebPublishedServerChild::Close()
|
|||
|
||||
/******** FlyWebPublishedServerParent ********/
|
||||
|
||||
NS_IMPL_ISUPPORTS(FlyWebPublishedServerParent, nsIDOMEventListener)
|
||||
|
||||
FlyWebPublishedServerParent::FlyWebPublishedServerParent(const nsAString& aName,
|
||||
const FlyWebPublishOptions& aOptions)
|
||||
: mActorDestroyed(false)
|
||||
, mNextRequestId(1)
|
||||
{
|
||||
LOG_I("FlyWebPublishedServerParent::FlyWebPublishedServerParent(%p)", this);
|
||||
|
||||
|
@ -360,77 +329,19 @@ FlyWebPublishedServerParent::FlyWebPublishedServerParent(const nsAString& aName,
|
|||
|
||||
RefPtr<FlyWebPublishedServerParent> self = this;
|
||||
|
||||
mozPromise->Then(
|
||||
AbstractThread::MainThread(),
|
||||
__func__,
|
||||
[this, self] (FlyWebPublishedServer* aServer) {
|
||||
mPublishedServer = static_cast<FlyWebPublishedServerImpl*>(aServer);
|
||||
if (mActorDestroyed) {
|
||||
mPublishedServer->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
mPublishedServer->AddEventListener(NS_LITERAL_STRING("fetch"),
|
||||
this, false, false, 2);
|
||||
mPublishedServer->AddEventListener(NS_LITERAL_STRING("close"),
|
||||
this, false, false, 2);
|
||||
Unused << SendServerReady(NS_OK);
|
||||
},
|
||||
[this, self] (nsresult aStatus) {
|
||||
MOZ_ASSERT(NS_FAILED(aStatus));
|
||||
if (!mActorDestroyed) {
|
||||
Unused << SendServerReady(aStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FlyWebPublishedServerParent::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (mActorDestroyed) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString type;
|
||||
aEvent->GetType(type);
|
||||
if (type.EqualsLiteral("close")) {
|
||||
Unused << SendServerClose();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (type.EqualsLiteral("fetch")) {
|
||||
RefPtr<InternalRequest> request =
|
||||
static_cast<FlyWebFetchEvent*>(aEvent)->Request()->GetInternalRequest();
|
||||
uint64_t id = mNextRequestId++;
|
||||
mPendingRequests.Put(id, request);
|
||||
|
||||
IPCInternalRequest ipcReq;
|
||||
request->ToIPC(&ipcReq);
|
||||
Unused << SendFetchRequest(ipcReq, id);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
FlyWebPublishedServerParent::RecvFetchResponse(const IPCInternalResponse& aResponse,
|
||||
const uint64_t& aRequestId)
|
||||
{
|
||||
RefPtr<InternalRequest> request = mPendingRequests.GetWeak(aRequestId);
|
||||
mPendingRequests.Remove(aRequestId);
|
||||
if (!request) {
|
||||
static_cast<ContentParent*>(Manager())->KillHard("unknown request id");
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<InternalResponse> response = InternalResponse::FromIPC(aResponse);
|
||||
|
||||
mPublishedServer->OnFetchResponse(request, response);
|
||||
|
||||
return true;
|
||||
mozPromise->Then(AbstractThread::MainThread(),
|
||||
__func__,
|
||||
[this, self] (FlyWebPublishedServer* aServer) {
|
||||
mPublishedServer = static_cast<FlyWebPublishedServerImpl*>(aServer);
|
||||
if (!mActorDestroyed) {
|
||||
Unused << SendServerReady(NS_OK);
|
||||
}
|
||||
},
|
||||
[this, self] (nsresult aStatus) {
|
||||
if (!mActorDestroyed) {
|
||||
Unused << SendServerReady(aStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -447,10 +358,6 @@ FlyWebPublishedServerParent::Recv__delete__()
|
|||
LOG_I("FlyWebPublishedServerParent::Recv__delete__(%p)", this);
|
||||
|
||||
if (mPublishedServer) {
|
||||
mPublishedServer->RemoveEventListener(NS_LITERAL_STRING("fetch"),
|
||||
this, false);
|
||||
mPublishedServer->RemoveEventListener(NS_LITERAL_STRING("close"),
|
||||
this, false);
|
||||
mPublishedServer->Close();
|
||||
mPublishedServer = nullptr;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "mozilla/dom/PFlyWebPublishedServerParent.h"
|
||||
#include "mozilla/dom/PFlyWebPublishedServerChild.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
|
@ -176,8 +175,6 @@ public:
|
|||
|
||||
virtual bool RecvServerReady(const nsresult& aStatus) override;
|
||||
virtual bool RecvServerClose() override;
|
||||
virtual bool RecvFetchRequest(const IPCInternalRequest& aRequest,
|
||||
const uint64_t& aRequestId) override;
|
||||
|
||||
virtual void OnFetchResponse(InternalRequest* aRequest,
|
||||
InternalResponse* aResponse) override;
|
||||
|
@ -195,19 +192,16 @@ public:
|
|||
private:
|
||||
~FlyWebPublishedServerChild() {}
|
||||
|
||||
nsDataHashtable<nsRefPtrHashKey<InternalRequest>, uint64_t> mPendingRequests;
|
||||
bool mActorDestroyed;
|
||||
};
|
||||
|
||||
class FlyWebPublishedServerParent final : public PFlyWebPublishedServerParent
|
||||
, public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
FlyWebPublishedServerParent(const nsAString& aName,
|
||||
const FlyWebPublishOptions& aOptions);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
NS_INLINE_DECL_REFCOUNTING(FlyWebPublishedServerParent)
|
||||
|
||||
private:
|
||||
virtual void
|
||||
|
@ -216,15 +210,9 @@ private:
|
|||
virtual bool
|
||||
Recv__delete__() override;
|
||||
|
||||
virtual bool
|
||||
RecvFetchResponse(const IPCInternalResponse& aResponse,
|
||||
const uint64_t& aRequestId) override;
|
||||
|
||||
~FlyWebPublishedServerParent() {}
|
||||
|
||||
bool mActorDestroyed;
|
||||
uint64_t mNextRequestId;
|
||||
nsRefPtrHashtable<nsUint64HashKey, InternalRequest> mPendingRequests;
|
||||
RefPtr<FlyWebPublishedServerImpl> mPublishedServer;
|
||||
};
|
||||
|
||||
|
|
|
@ -912,7 +912,7 @@ HttpServer::Connection::QueueResponse(InternalResponse* aResponse)
|
|||
aResponse->GetStatusText() +
|
||||
NS_LITERAL_CSTRING("\r\n"));
|
||||
|
||||
AutoTArray<InternalHeaders::Entry, 16> entries;
|
||||
nsTArray<InternalHeaders::Entry> entries;
|
||||
headers->GetEntries(entries);
|
||||
|
||||
for (auto header : entries) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include protocol PContent;
|
||||
include FetchTypes;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -16,13 +15,10 @@ async protocol PFlyWebPublishedServer
|
|||
|
||||
child:
|
||||
async ServerReady(nsresult aStatus);
|
||||
async FetchRequest(IPCInternalRequest aRequest, uint64_t aRequestId);
|
||||
async ServerClose();
|
||||
|
||||
parent:
|
||||
async __delete__();
|
||||
|
||||
async FetchResponse(IPCInternalResponse aResponse, uint64_t aRequestId);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
Загрузка…
Ссылка в новой задаче