Backed out changeset 1bbb1ec38652 (bug 1110485)

This commit is contained in:
Carsten "Tomcat" Book 2015-04-15 09:54:45 +02:00
parent 0e0743f2c7
commit 0e646e32dd
12 changed files with 114 additions and 114 deletions

View File

@ -6,9 +6,6 @@
#include "mozilla/dom/cache/CacheOpChild.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/Request.h"
#include "mozilla/dom/Response.h"
#include "mozilla/dom/cache/Cache.h"
#include "mozilla/dom/cache/CacheChild.h"

View File

@ -5,14 +5,15 @@
include protocol PCache;
include protocol PCachePushStream;
include protocol PCacheStreamControl;
include PHeaders;
include InputStreamParams;
using HeadersGuardEnum 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 RequestContext from "mozilla/dom/cache/IPCUtils.h";
using ResponseType from "mozilla/dom/cache/IPCUtils.h";
using HeadersGuardEnum from "mozilla/dom/FetchIPCUtils.h";
using RequestCredentials from "mozilla/dom/FetchIPCUtils.h";
using RequestMode from "mozilla/dom/FetchIPCUtils.h";
using RequestCache from "mozilla/dom/FetchIPCUtils.h";
using RequestContext from "mozilla/dom/FetchIPCUtils.h";
using mozilla::dom::ResponseType from "mozilla/dom/FetchIPCUtils.h";
using mozilla::void_t from "ipc/IPCMessageUtils.h";
using struct nsID from "nsID.h";
@ -44,18 +45,12 @@ union CacheReadStreamOrVoid
CacheReadStream;
};
struct HeadersEntry
{
nsCString name;
nsCString value;
};
struct CacheRequest
{
nsCString method;
nsString url;
nsString urlWithoutQuery;
HeadersEntry[] headers;
PHeadersEntry[] headers;
HeadersGuardEnum headersGuard;
nsString referrer;
RequestMode mode;
@ -78,7 +73,7 @@ struct CacheResponse
nsString url;
uint32_t status;
nsCString statusText;
HeadersEntry[] headers;
PHeadersEntry[] headers;
HeadersGuardEnum headersGuard;
CacheReadStreamOrVoid body;
nsCString securityInfo;

View File

@ -10,8 +10,6 @@
#include "mozilla/dom/InternalHeaders.h"
#include "mozilla/dom/cache/CacheTypes.h"
#include "mozilla/dom/cache/SavedTypes.h"
#include "mozilla/dom/cache/Types.h"
#include "mozilla/dom/cache/TypeUtils.h"
#include "mozIStorageConnection.h"
#include "mozIStorageStatement.h"
#include "nsCOMPtr.h"
@ -21,6 +19,7 @@
#include "mozilla/dom/HeadersBinding.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/ResponseBinding.h"
#include "Types.h"
#include "nsIContentPolicy.h"
namespace mozilla {
@ -914,8 +913,7 @@ DBSchema::MatchByVaryHeader(mozIStorageConnection* aConn,
rv = state->BindInt32Parameter(0, entryId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
nsRefPtr<InternalHeaders> cachedHeaders =
new InternalHeaders(HeadersGuardEnum::None);
nsRefPtr<InternalHeaders> cachedHeaders = new InternalHeaders(HeadersGuardEnum::None);
while (NS_SUCCEEDED(state->ExecuteStep(&hasMoreData)) && hasMoreData) {
nsAutoCString name;
@ -932,8 +930,7 @@ DBSchema::MatchByVaryHeader(mozIStorageConnection* aConn,
}
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
nsRefPtr<InternalHeaders> queryHeaders =
TypeUtils::ToInternalHeaders(aRequest.headers());
nsRefPtr<InternalHeaders> queryHeaders = new InternalHeaders(aRequest.headers());
// Assume the vary headers match until we find a conflict
bool varyHeadersMatch = true;
@ -1198,7 +1195,7 @@ DBSchema::InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
), getter_AddRefs(state));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
const nsTArray<HeadersEntry>& requestHeaders = aRequest.headers();
const nsTArray<PHeadersEntry>& requestHeaders = aRequest.headers();
for (uint32_t i = 0; i < requestHeaders.Length(); ++i) {
rv = state->BindUTF8StringParameter(0, requestHeaders[i].name());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
@ -1222,7 +1219,7 @@ DBSchema::InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
), getter_AddRefs(state));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
const nsTArray<HeadersEntry>& responseHeaders = aResponse.headers();
const nsTArray<PHeadersEntry>& responseHeaders = aResponse.headers();
for (uint32_t i = 0; i < responseHeaders.Length(); ++i) {
rv = state->BindUTF8StringParameter(0, responseHeaders[i].name());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
@ -1323,7 +1320,7 @@ DBSchema::ReadResponse(mozIStorageConnection* aConn, EntryId aEntryId,
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
while (NS_SUCCEEDED(state->ExecuteStep(&hasMoreData)) && hasMoreData) {
HeadersEntry header;
PHeadersEntry header;
rv = state->GetUTF8String(0, header.name());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
@ -1442,7 +1439,7 @@ DBSchema::ReadRequest(mozIStorageConnection* aConn, EntryId aEntryId,
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
while (NS_SUCCEEDED(state->ExecuteStep(&hasMoreData)) && hasMoreData) {
HeadersEntry header;
PHeadersEntry header;
rv = state->GetUTF8String(0, header.name());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }

View File

@ -339,7 +339,7 @@ FetchPut::MatchInPutList(const CacheRequest& aRequest,
}
nsRefPtr<InternalHeaders> requestHeaders =
ToInternalHeaders(aRequest.headers());
new InternalHeaders(aRequest.headers());
for (uint32_t i = 0; i < aPutList.Length(); ++i) {
const CacheRequest& cachedRequest = aPutList[i].request();
@ -351,10 +351,10 @@ FetchPut::MatchInPutList(const CacheRequest& aRequest,
}
nsRefPtr<InternalHeaders> cachedRequestHeaders =
ToInternalHeaders(cachedRequest.headers());
new InternalHeaders(cachedRequest.headers());
nsRefPtr<InternalHeaders> cachedResponseHeaders =
ToInternalHeaders(cachedResponse.headers());
new InternalHeaders(cachedResponse.headers());
nsAutoTArray<nsCString, 16> varyHeaders;
ErrorResult rv;

37
dom/cache/IPCUtils.h vendored
View File

@ -8,47 +8,10 @@
#define mozilla_dom_cache_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"
#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::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::RequestContext> :
public ContiguousEnumSerializer<mozilla::dom::RequestContext,
mozilla::dom::RequestContext::Audio,
mozilla::dom::RequestContext::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,

View File

@ -32,9 +32,7 @@ namespace {
using mozilla::ErrorResult;
using mozilla::unused;
using mozilla::void_t;
using mozilla::dom::InternalHeaders;
using mozilla::dom::cache::CacheReadStream;
using mozilla::dom::cache::HeadersEntry;
using mozilla::ipc::BackgroundChild;
using mozilla::ipc::FileDescriptor;
using mozilla::ipc::PBackgroundChild;
@ -131,20 +129,6 @@ SerializeNormalStream(nsIInputStream* aStream, CacheReadStream& aReadStreamOut)
}
}
void
ToHeadersEntryList(nsTArray<HeadersEntry>& aOut, InternalHeaders* aHeaders)
{
MOZ_ASSERT(aHeaders);
nsAutoTArray<InternalHeaders::Entry, 16> entryList;
aHeaders->GetEntries(entryList);
for (uint32_t i = 0; i < entryList.Length(); ++i) {
InternalHeaders::Entry& entry = entryList[i];
aOut.AppendElement(HeadersEntry(entry.mName, entry.mValue));
}
}
} // anonymous namespace
namespace mozilla {
@ -236,7 +220,7 @@ TypeUtils::ToCacheRequest(CacheRequest& aOut, InternalRequest* aIn,
nsRefPtr<InternalHeaders> headers = aIn->Headers();
MOZ_ASSERT(headers);
ToHeadersEntryList(aOut.headers(), headers);
headers->GetPHeaders(aOut.headers());
aOut.headersGuard() = headers->Guard();
aOut.mode() = aIn->Mode();
aOut.credentials() = aIn->GetCredentialsMode();
@ -282,7 +266,7 @@ TypeUtils::ToCacheResponseWithoutBody(CacheResponse& aOut,
aOut.statusText() = aIn.GetStatusText();
nsRefPtr<InternalHeaders> headers = aIn.UnfilteredHeaders();
MOZ_ASSERT(headers);
ToHeadersEntryList(aOut.headers(), headers);
headers->GetPHeaders(aOut.headers());
aOut.headersGuard() = headers->Guard();
aOut.securityInfo() = aIn.GetSecurityInfo();
}
@ -340,7 +324,7 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
ir->SetUrl(NS_ConvertUTF16toUTF8(aIn.url()));
nsRefPtr<InternalHeaders> internalHeaders =
ToInternalHeaders(aIn.headers(), aIn.headersGuard());
new InternalHeaders(aIn.headers(), aIn.headersGuard());
ErrorResult result;
ir->Headers()->SetGuard(aIn.headersGuard(), result);
MOZ_ASSERT(!result.Failed());
@ -392,7 +376,7 @@ TypeUtils::ToInternalRequest(const CacheRequest& aIn)
internalRequest->SetCacheMode(aIn.requestCache());
nsRefPtr<InternalHeaders> internalHeaders =
ToInternalHeaders(aIn.headers(), aIn.headersGuard());
new InternalHeaders(aIn.headers(), aIn.headersGuard());
ErrorResult result;
internalRequest->Headers()->SetGuard(aIn.headersGuard(), result);
MOZ_ASSERT(!result.Failed());
@ -414,23 +398,6 @@ TypeUtils::ToRequest(const CacheRequest& aIn)
return request.forget();
}
// static
already_AddRefed<InternalHeaders>
TypeUtils::ToInternalHeaders(const nsTArray<HeadersEntry>& aHeadersEntryList,
HeadersGuardEnum aGuard)
{
nsTArray<InternalHeaders::Entry> entryList(aHeadersEntryList.Length());
for (uint32_t i = 0; i < aHeadersEntryList.Length(); ++i) {
const HeadersEntry& headersEntry = aHeadersEntryList[i];
entryList.AppendElement(InternalHeaders::Entry(headersEntry.name(),
headersEntry.value()));
}
nsRefPtr<InternalHeaders> ref = new InternalHeaders(Move(entryList), aGuard);
return ref.forget();
}
void
TypeUtils::CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,
ErrorResult& aRv)

View File

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/InternalHeaders.h"
#include "nsError.h"
class nsIGlobalObject;
@ -35,7 +34,6 @@ class CacheReadStream;
class CacheReadStreamOrVoid;
class CacheRequest;
class CacheResponse;
class HeadersEntry;
class TypeUtils
{
@ -102,11 +100,6 @@ public:
already_AddRefed<Request>
ToRequest(const CacheRequest& aIn);
// static methods
static already_AddRefed<InternalHeaders>
ToInternalHeaders(const nsTArray<HeadersEntry>& aHeadersEntryList,
HeadersGuardEnum aGuard = HeadersGuardEnum::None);
private:
void
CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,

51
dom/fetch/FetchIPCUtils.h Normal file
View File

@ -0,0 +1,51 @@
/* -*- 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::RequestCache> :
public ContiguousEnumSerializer<mozilla::dom::RequestCache,
mozilla::dom::RequestCache::Default,
mozilla::dom::RequestCache::EndGuard_> {};
template<>
struct ParamTraits<mozilla::dom::RequestContext> :
public ContiguousEnumSerializer<mozilla::dom::RequestContext,
mozilla::dom::RequestContext::Audio,
mozilla::dom::RequestContext::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

View File

@ -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,11 +17,21 @@
namespace mozilla {
namespace dom {
InternalHeaders::InternalHeaders(const nsTArray<Entry>&& aHeaders,
InternalHeaders::InternalHeaders(const nsTArray<PHeadersEntry>& aHeaders,
HeadersGuardEnum aGuard)
: mGuard(aGuard)
, mList(aHeaders)
{
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

View File

@ -24,6 +24,7 @@ namespace dom {
template<typename T> class MozMap;
class HeadersOrByteStringSequenceSequenceOrByteStringMozMap;
class PHeadersEntry;
class InternalHeaders final
{
@ -61,7 +62,7 @@ public:
MOZ_ASSERT(!result.Failed());
}
explicit InternalHeaders(const nsTArray<Entry>&& aHeaders,
explicit InternalHeaders(const nsTArray<PHeadersEntry>& aHeaders,
HeadersGuardEnum aGuard = HeadersGuardEnum::None);
void Append(const nsACString& aName, const nsACString& aValue,
@ -90,6 +91,9 @@ public:
static already_AddRefed<InternalHeaders>
CORSHeaders(InternalHeaders* aHeaders);
void
GetPHeaders(nsTArray<PHeadersEntry>& aPHeadersOut) const;
void
GetEntries(nsTArray<InternalHeaders::Entry>& aEntries) const;

15
dom/fetch/PHeaders.ipdlh Normal file
View File

@ -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

View File

@ -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