зеркало из https://github.com/mozilla/gecko-dev.git
Bug 940273 -Part 1 - Fetch changes from maple twig to support Service Worker Cache. r=nsm,ehsan
This commit is contained in:
Родитель
abdbbbdbee
Коммит
92807f390b
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
|
||||
|
||||
|
@ -28,7 +29,6 @@ namespace dom {
|
|||
class ArrayBufferOrArrayBufferViewOrBlobOrUSVStringOrURLSearchParams;
|
||||
class InternalRequest;
|
||||
class OwningArrayBufferOrArrayBufferViewOrBlobOrUSVStringOrURLSearchParams;
|
||||
class Promise;
|
||||
class RequestOrUSVString;
|
||||
|
||||
namespace workers {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- 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_FetchIPCUtils_h
|
||||
#define mozilla_dom_FetchIPCUtils_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/Request.h"
|
||||
#include "mozilla/dom/Response.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::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::ResponseType> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::ResponseType,
|
||||
mozilla::dom::ResponseType::Basic,
|
||||
mozilla::dom::ResponseType::EndGuard_> {};
|
||||
}
|
||||
|
||||
#endif // mozilla_dom_FetchIPCUtils_h
|
|
@ -7,6 +7,7 @@
|
|||
#include "mozilla/dom/InternalHeaders.h"
|
||||
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/PHeaders.h"
|
||||
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -16,6 +17,23 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
InternalHeaders::InternalHeaders(const nsTArray<PHeadersEntry>& aHeaders,
|
||||
HeadersGuardEnum aGuard)
|
||||
: mGuard(aGuard)
|
||||
{
|
||||
for (uint32_t i = 0; i < aHeaders.Length(); ++i) {
|
||||
mList.AppendElement(Entry(aHeaders[i].name(), aHeaders[i].value()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InternalHeaders::GetPHeaders(nsTArray<PHeadersEntry>& aPHeadersOut) const
|
||||
{
|
||||
for (uint32_t i = 0; i < mList.Length(); ++i) {
|
||||
aPHeadersOut.AppendElement(PHeadersEntry(mList[i].mName, mList[i].mValue));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InternalHeaders::Append(const nsACString& aName, const nsACString& aValue,
|
||||
ErrorResult& aRv)
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace dom {
|
|||
|
||||
template<typename T> class MozMap;
|
||||
class HeadersOrByteStringSequenceSequenceOrByteStringMozMap;
|
||||
class PHeadersEntry;
|
||||
|
||||
class InternalHeaders MOZ_FINAL
|
||||
{
|
||||
|
@ -61,6 +62,9 @@ public:
|
|||
MOZ_ASSERT(!result.Failed());
|
||||
}
|
||||
|
||||
explicit InternalHeaders(const nsTArray<PHeadersEntry>& aHeaders,
|
||||
HeadersGuardEnum aGuard = HeadersGuardEnum::None);
|
||||
|
||||
void Append(const nsACString& aName, const nsACString& aValue,
|
||||
ErrorResult& aRv);
|
||||
void Delete(const nsACString& aName, ErrorResult& aRv);
|
||||
|
@ -87,6 +91,9 @@ public:
|
|||
static already_AddRefed<InternalHeaders>
|
||||
CORSHeaders(InternalHeaders* aHeaders);
|
||||
|
||||
void
|
||||
GetPHeaders(nsTArray<PHeadersEntry>& aPHeadersOut) const;
|
||||
|
||||
void
|
||||
GetEntries(nsTArray<InternalHeaders::Entry>& aEntries) const;
|
||||
|
||||
|
|
|
@ -214,6 +214,12 @@ public:
|
|||
return mContentPolicyType;
|
||||
}
|
||||
|
||||
void
|
||||
SetContentPolicyType(nsContentPolicyType aContentPolicyType)
|
||||
{
|
||||
mContentPolicyType = aContentPolicyType;
|
||||
}
|
||||
|
||||
bool
|
||||
UnsafeRequest() const
|
||||
{
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/* 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/. */
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
struct PHeadersEntry
|
||||
{
|
||||
nsCString name;
|
||||
nsCString value;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -43,9 +43,9 @@ public:
|
|||
}
|
||||
|
||||
void
|
||||
GetUrl(DOMString& aUrl) const
|
||||
GetUrl(nsAString& aUrl) const
|
||||
{
|
||||
aUrl.AsAString() = NS_ConvertUTF8toUTF16(mRequest->mURL);
|
||||
CopyUTF8toUTF16(mRequest->mURL, aUrl);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -210,6 +210,13 @@ Response::SetBody(nsIInputStream* aBody)
|
|||
mInternalResponse->SetBody(aBody);
|
||||
}
|
||||
|
||||
already_AddRefed<InternalResponse>
|
||||
Response::GetInternalResponse() const
|
||||
{
|
||||
nsRefPtr<InternalResponse> ref = mInternalResponse;
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
Headers*
|
||||
Response::Headers_()
|
||||
{
|
||||
|
|
|
@ -116,6 +116,10 @@ public:
|
|||
|
||||
void
|
||||
SetBody(nsIInputStream* aBody);
|
||||
|
||||
already_AddRefed<InternalResponse>
|
||||
GetInternalResponse() const;
|
||||
|
||||
private:
|
||||
~Response();
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
EXPORTS.mozilla.dom += [
|
||||
'Fetch.h',
|
||||
'FetchDriver.h',
|
||||
'FetchIPCUtils.h',
|
||||
'Headers.h',
|
||||
'InternalHeaders.h',
|
||||
'InternalRequest.h',
|
||||
|
@ -26,6 +27,12 @@ UNIFIED_SOURCES += [
|
|||
'Response.cpp',
|
||||
]
|
||||
|
||||
IPDL_SOURCES += [
|
||||
'PHeaders.ipdlh',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'../workers',
|
||||
# For nsDataHandler.h
|
||||
|
|
Загрузка…
Ссылка в новой задаче