From 27b9a7bc7c3fa815addefde784d6093a6b1fb437 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Wed, 15 Apr 2015 09:54:45 +0200 Subject: [PATCH] Backed out changeset 1bbb1ec38652 (bug 1110485) --- dom/cache/CacheOpChild.cpp | 3 --- dom/cache/CacheTypes.ipdlh | 23 +++++++--------- dom/cache/DBSchema.cpp | 17 +++++------- dom/cache/FetchPut.cpp | 6 ++--- dom/cache/IPCUtils.h | 37 ------------------------- dom/cache/TypeUtils.cpp | 41 +++------------------------- dom/cache/TypeUtils.h | 7 ----- dom/fetch/FetchIPCUtils.h | 51 +++++++++++++++++++++++++++++++++++ dom/fetch/InternalHeaders.cpp | 15 +++++++++-- dom/fetch/InternalHeaders.h | 6 ++++- dom/fetch/PHeaders.ipdlh | 15 +++++++++++ dom/fetch/moz.build | 7 +++++ 12 files changed, 114 insertions(+), 114 deletions(-) create mode 100644 dom/fetch/FetchIPCUtils.h create mode 100644 dom/fetch/PHeaders.ipdlh diff --git a/dom/cache/CacheOpChild.cpp b/dom/cache/CacheOpChild.cpp index 797e41af5229..c80c6c47e09b 100644 --- a/dom/cache/CacheOpChild.cpp +++ b/dom/cache/CacheOpChild.cpp @@ -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" diff --git a/dom/cache/CacheTypes.ipdlh b/dom/cache/CacheTypes.ipdlh index 4947389a464d..5750e4b40487 100644 --- a/dom/cache/CacheTypes.ipdlh +++ b/dom/cache/CacheTypes.ipdlh @@ -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; diff --git a/dom/cache/DBSchema.cpp b/dom/cache/DBSchema.cpp index e0a94c7e3db3..73865b6e21a3 100644 --- a/dom/cache/DBSchema.cpp +++ b/dom/cache/DBSchema.cpp @@ -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 cachedHeaders = - new InternalHeaders(HeadersGuardEnum::None); + nsRefPtr 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 queryHeaders = - TypeUtils::ToInternalHeaders(aRequest.headers()); + nsRefPtr 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& requestHeaders = aRequest.headers(); + const nsTArray& 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& responseHeaders = aResponse.headers(); + const nsTArray& 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; } diff --git a/dom/cache/FetchPut.cpp b/dom/cache/FetchPut.cpp index 06c90cafda7b..2634f3abc6c0 100644 --- a/dom/cache/FetchPut.cpp +++ b/dom/cache/FetchPut.cpp @@ -339,7 +339,7 @@ FetchPut::MatchInPutList(const CacheRequest& aRequest, } nsRefPtr 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 cachedRequestHeaders = - ToInternalHeaders(cachedRequest.headers()); + new InternalHeaders(cachedRequest.headers()); nsRefPtr cachedResponseHeaders = - ToInternalHeaders(cachedResponse.headers()); + new InternalHeaders(cachedResponse.headers()); nsAutoTArray varyHeaders; ErrorResult rv; diff --git a/dom/cache/IPCUtils.h b/dom/cache/IPCUtils.h index fb843748bf53..48498e0f43c7 100644 --- a/dom/cache/IPCUtils.h +++ b/dom/cache/IPCUtils.h @@ -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 : - public ContiguousEnumSerializer {}; - template<> - struct ParamTraits : - public ContiguousEnumSerializer {}; - template<> - struct ParamTraits : - public ContiguousEnumSerializer {}; - template<> - struct ParamTraits : - public ContiguousEnumSerializer {}; - template<> - struct ParamTraits : - public ContiguousEnumSerializer {}; - template<> - struct ParamTraits : - public ContiguousEnumSerializer {}; - template<> struct ParamTraits : public ContiguousEnumSerializer& aOut, InternalHeaders* aHeaders) -{ - MOZ_ASSERT(aHeaders); - - nsAutoTArray 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 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 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 = - 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 = - 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 -TypeUtils::ToInternalHeaders(const nsTArray& aHeadersEntryList, - HeadersGuardEnum aGuard) -{ - nsTArray 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 ref = new InternalHeaders(Move(entryList), aGuard); - return ref.forget(); -} - void TypeUtils::CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction, ErrorResult& aRv) diff --git a/dom/cache/TypeUtils.h b/dom/cache/TypeUtils.h index ea2f971394e9..069fa4cd3afa 100644 --- a/dom/cache/TypeUtils.h +++ b/dom/cache/TypeUtils.h @@ -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 ToRequest(const CacheRequest& aIn); - // static methods - static already_AddRefed - ToInternalHeaders(const nsTArray& aHeadersEntryList, - HeadersGuardEnum aGuard = HeadersGuardEnum::None); - private: void CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction, diff --git a/dom/fetch/FetchIPCUtils.h b/dom/fetch/FetchIPCUtils.h new file mode 100644 index 000000000000..830b7d3bde68 --- /dev/null +++ b/dom/fetch/FetchIPCUtils.h @@ -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 : + public ContiguousEnumSerializer {}; + template<> + struct ParamTraits : + public ContiguousEnumSerializer {}; + template<> + struct ParamTraits : + public ContiguousEnumSerializer {}; + template<> + struct ParamTraits : + public ContiguousEnumSerializer {}; + template<> + struct ParamTraits : + public ContiguousEnumSerializer {}; + template<> + struct ParamTraits : + public ContiguousEnumSerializer {}; +} + +#endif // mozilla_dom_FetchIPCUtils_h diff --git a/dom/fetch/InternalHeaders.cpp b/dom/fetch/InternalHeaders.cpp index 244e6621c862..208ea832c1a3 100644 --- a/dom/fetch/InternalHeaders.cpp +++ b/dom/fetch/InternalHeaders.cpp @@ -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&& aHeaders, +InternalHeaders::InternalHeaders(const nsTArray& 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& aPHeadersOut) const +{ + for (uint32_t i = 0; i < mList.Length(); ++i) { + aPHeadersOut.AppendElement(PHeadersEntry(mList[i].mName, mList[i].mValue)); + } } void diff --git a/dom/fetch/InternalHeaders.h b/dom/fetch/InternalHeaders.h index 5d632dcb981c..297715751251 100644 --- a/dom/fetch/InternalHeaders.h +++ b/dom/fetch/InternalHeaders.h @@ -24,6 +24,7 @@ namespace dom { template class MozMap; class HeadersOrByteStringSequenceSequenceOrByteStringMozMap; +class PHeadersEntry; class InternalHeaders final { @@ -61,7 +62,7 @@ public: MOZ_ASSERT(!result.Failed()); } - explicit InternalHeaders(const nsTArray&& aHeaders, + explicit InternalHeaders(const nsTArray& aHeaders, HeadersGuardEnum aGuard = HeadersGuardEnum::None); void Append(const nsACString& aName, const nsACString& aValue, @@ -90,6 +91,9 @@ public: static already_AddRefed CORSHeaders(InternalHeaders* aHeaders); + void + GetPHeaders(nsTArray& aPHeadersOut) const; + void GetEntries(nsTArray& aEntries) const; diff --git a/dom/fetch/PHeaders.ipdlh b/dom/fetch/PHeaders.ipdlh new file mode 100644 index 000000000000..e7fa0beb9511 --- /dev/null +++ b/dom/fetch/PHeaders.ipdlh @@ -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 diff --git a/dom/fetch/moz.build b/dom/fetch/moz.build index 92c25148d6f1..c63b3344ebf2 100644 --- a/dom/fetch/moz.build +++ b/dom/fetch/moz.build @@ -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