Backed out changeset ae9c77fa58d1 (bug 1168208) for bustage on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book
2015-05-27 14:50:43 +02:00
parent 6b7bbc5e1e
commit c58dbca945
22 changed files with 140 additions and 327 deletions

View File

@@ -6,7 +6,6 @@ include protocol PCache;
include protocol PCachePushStream;
include protocol PCacheStreamControl;
include InputStreamParams;
include ChannelInfo;
using HeadersGuardEnum from "mozilla/dom/cache/IPCUtils.h";
using RequestCredentials from "mozilla/dom/cache/IPCUtils.h";
@@ -82,7 +81,7 @@ struct CacheResponse
HeadersEntry[] headers;
HeadersGuardEnum headersGuard;
CacheReadStreamOrVoid body;
IPCChannelInfo channelInfo;
nsCString securityInfo;
};
union CacheResponseOrVoid

View File

@@ -175,8 +175,8 @@ static nsresult DeleteEntries(mozIStorageConnection* aConn,
nsTArray<nsID>& aDeletedBodyIdListOut,
nsTArray<IdCount>& aDeletedSecurityIdListOut,
uint32_t aPos=0, int32_t aLen=-1);
static nsresult InsertSecurityInfo(mozIStorageConnection* aConn,
const nsACString& aData, int32_t *aIdOut);
static nsresult InsertSecurity(mozIStorageConnection* aConn,
const nsACString& aData, int32_t *aIdOut);
static nsresult DeleteSecurityInfo(mozIStorageConnection* aConn, int32_t aId,
int32_t aCount);
static nsresult DeleteSecurityInfoList(mozIStorageConnection* aConn,
@@ -1194,8 +1194,8 @@ DeleteEntries(mozIStorageConnection* aConn,
}
nsresult
InsertSecurityInfo(mozIStorageConnection* aConn, const nsACString& aData,
int32_t *aIdOut)
InsertSecurity(mozIStorageConnection* aConn, const nsACString& aData,
int32_t *aIdOut)
{
MOZ_ASSERT(aConn);
MOZ_ASSERT(aIdOut);
@@ -1394,10 +1394,8 @@ InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
nsresult rv = NS_OK;
int32_t securityId = -1;
if (!aResponse.channelInfo().securityInfo().IsEmpty()) {
rv = InsertSecurityInfo(aConn,
aResponse.channelInfo().securityInfo(),
&securityId);
if (!aResponse.securityInfo().IsEmpty()) {
rv = InsertSecurity(aConn, aResponse.securityInfo(), &securityId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
}
@@ -1513,7 +1511,7 @@ InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
rv = BindId(state, NS_LITERAL_CSTRING("response_body_id"), aResponseBodyId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
if (aResponse.channelInfo().securityInfo().IsEmpty()) {
if (aResponse.securityInfo().IsEmpty()) {
rv = state->BindNullByName(NS_LITERAL_CSTRING("response_security_info_id"));
} else {
rv = state->BindInt32ByName(NS_LITERAL_CSTRING("response_security_info_id"),
@@ -1659,7 +1657,7 @@ ReadResponse(mozIStorageConnection* aConn, EntryId aEntryId,
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
}
rv = state->GetBlobAsUTF8String(6, aSavedResponseOut->mValue.channelInfo().securityInfo());
rv = state->GetBlobAsUTF8String(6, aSavedResponseOut->mValue.securityInfo());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = aConn->CreateStatement(NS_LITERAL_CSTRING(

View File

@@ -224,7 +224,7 @@ TypeUtils::ToCacheResponseWithoutBody(CacheResponse& aOut,
}
ToHeadersEntryList(aOut.headers(), headers);
aOut.headersGuard() = headers->Guard();
aOut.channelInfo() = aIn.GetChannelInfo().AsIPCChannelInfo();
aOut.securityInfo() = aIn.GetSecurityInfo();
}
void
@@ -290,7 +290,7 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
ir->Headers()->Fill(*internalHeaders, result);
MOZ_ASSERT(!result.Failed());
ir->InitChannelInfo(aIn.channelInfo());
ir->SetSecurityInfo(aIn.securityInfo());
nsCOMPtr<nsIInputStream> stream = ReadStream::Create(aIn.body());
ir->SetBody(stream);

View File

@@ -1,94 +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/. */
#include "mozilla/dom/ChannelInfo.h"
#include "nsCOMPtr.h"
#include "nsIChannel.h"
#include "nsIHttpChannel.h"
#include "nsSerializationHelper.h"
#include "mozilla/net/HttpBaseChannel.h"
#include "mozilla/ipc/ChannelInfo.h"
using namespace mozilla;
using namespace mozilla::dom;
void
ChannelInfo::InitFromChannel(nsIChannel* aChannel)
{
MOZ_ASSERT(!mInited, "Cannot initialize the object twice");
nsCOMPtr<nsISupports> securityInfo;
aChannel->GetSecurityInfo(getter_AddRefs(securityInfo));
if (securityInfo) {
SetSecurityInfo(securityInfo);
}
mInited = true;
}
void
ChannelInfo::InitFromIPCChannelInfo(const ipc::IPCChannelInfo& aChannelInfo)
{
MOZ_ASSERT(!mInited, "Cannot initialize the object twice");
mSecurityInfo = aChannelInfo.securityInfo();
mInited = true;
}
void
ChannelInfo::SetSecurityInfo(nsISupports* aSecurityInfo)
{
MOZ_ASSERT(mSecurityInfo.IsEmpty(), "security info should only be set once");
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(aSecurityInfo);
if (!serializable) {
NS_WARNING("A non-serializable object was passed to InternalResponse::SetSecurityInfo");
return;
}
NS_SerializeToString(serializable, mSecurityInfo);
}
nsresult
ChannelInfo::ResurrectInfoOnChannel(nsIChannel* aChannel)
{
MOZ_ASSERT(mInited);
if (!mSecurityInfo.IsEmpty()) {
nsCOMPtr<nsISupports> infoObj;
nsresult rv = NS_DeserializeObject(mSecurityInfo, getter_AddRefs(infoObj));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsCOMPtr<nsIHttpChannel> httpChannel =
do_QueryInterface(aChannel);
if (NS_WARN_IF(!httpChannel)) {
return NS_ERROR_FAILURE;
}
net::HttpBaseChannel* httpBaseChannel =
static_cast<net::HttpBaseChannel*>(httpChannel.get());
rv = httpBaseChannel->OverrideSecurityInfo(infoObj);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
return NS_OK;
}
ipc::IPCChannelInfo
ChannelInfo::AsIPCChannelInfo() const
{
// This may be called when mInited is false, for example if we try to store
// a synthesized Response object into the Cache. Uninitialized and empty
// ChannelInfo objects are indistinguishable at the IPC level, so this is
// fine.
IPCChannelInfo ipcInfo;
ipcInfo.securityInfo() = mSecurityInfo;
return ipcInfo;
}

View File

@@ -1,87 +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_ChannelInfo_h
#define mozilla_dom_ChannelInfo_h
#include "nsString.h"
class nsIChannel;
namespace mozilla {
namespace ipc {
class IPCChannelInfo;
} // namespace ipc
namespace dom {
// This class represents the information related to a Response that we
// retrieve from the corresponding channel that is used to perform the fetch.
//
// When adding new members to this object, the following code needs to be
// updated:
// * IPCChannelInfo
// * InitFromChannel and InitFromIPCChannelInfo members
// * ResurrectInfoOnChannel member
// * AsIPCChannelInfo member
// * constructors and assignment operators for this class.
// * DOM Cache schema code (in dom/cache/DBSchema.cpp) to ensure that the newly
// added member is saved into the DB and loaded from it properly.
//
// Care must be taken when initializing this object, or when calling
// ResurrectInfoOnChannel(). This object cannot be initialized twice, and
// ResurrectInfoOnChannel() cannot be called on it before it has been
// initialized. There are assertions ensuring these invariants.
class ChannelInfo final
{
public:
typedef mozilla::ipc::IPCChannelInfo IPCChannelInfo;
ChannelInfo()
: mInited(false)
{
}
ChannelInfo(const ChannelInfo& aRHS)
: mSecurityInfo(aRHS.mSecurityInfo)
, mInited(aRHS.mInited)
{
}
ChannelInfo&
operator=(const ChannelInfo& aRHS)
{
mSecurityInfo = aRHS.mSecurityInfo;
mInited = aRHS.mInited;
return *this;
}
void InitFromChannel(nsIChannel* aChannel);
void InitFromIPCChannelInfo(const IPCChannelInfo& aChannelInfo);
// This restores every possible information stored from a previous channel
// object on a new one.
nsresult ResurrectInfoOnChannel(nsIChannel* aChannel);
bool IsInitialized() const
{
return mInited;
}
IPCChannelInfo AsIPCChannelInfo() const;
private:
void SetSecurityInfo(nsISupports* aSecurityInfo);
private:
nsCString mSecurityInfo;
bool mInited;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ChannelInfo_h

View File

@@ -1,14 +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/. */
namespace mozilla {
namespace ipc {
struct IPCChannelInfo
{
nsCString securityInfo;
};
} // namespace ipc
} // namespace mozilla

View File

@@ -706,8 +706,12 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
}
response->SetBody(pipeInputStream);
nsCOMPtr<nsISupports> securityInfo;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
response->InitChannelInfo(channel);
rv = channel->GetSecurityInfo(getter_AddRefs(securityInfo));
if (securityInfo) {
response->SetSecurityInfo(securityInfo);
}
// Resolves fetch() promise which may trigger code running in a worker. Make
// sure the Response is fully initialized before calling this.

View File

@@ -8,6 +8,7 @@
#include "mozilla/dom/InternalHeaders.h"
#include "nsStreamUtils.h"
#include "nsSerializationHelper.h"
namespace mozilla {
namespace dom {
@@ -74,5 +75,24 @@ InternalResponse::CORSResponse()
return cors.forget();
}
void
InternalResponse::SetSecurityInfo(nsISupports* aSecurityInfo)
{
MOZ_ASSERT(mSecurityInfo.IsEmpty(), "security info should only be set once");
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(aSecurityInfo);
if (!serializable) {
NS_WARNING("A non-serializable object was passed to InternalResponse::SetSecurityInfo");
return;
}
NS_SerializeToString(serializable, mSecurityInfo);
}
void
InternalResponse::SetSecurityInfo(const nsCString& aSecurityInfo)
{
MOZ_ASSERT(mSecurityInfo.IsEmpty(), "security info should only be set once");
mSecurityInfo = aSecurityInfo;
}
} // namespace dom
} // namespace mozilla

View File

@@ -11,7 +11,6 @@
#include "nsISupportsImpl.h"
#include "mozilla/dom/ResponseBinding.h"
#include "mozilla/dom/ChannelInfo.h"
namespace mozilla {
namespace dom {
@@ -49,7 +48,7 @@ public:
response->mTerminationReason = mTerminationReason;
response->mURL = mURL;
response->mFinalURL = mFinalURL;
response->mChannelInfo = mChannelInfo;
response->mSecurityInfo = mSecurityInfo;
response->mWrappedResponse = this;
return response.forget();
}
@@ -157,29 +156,17 @@ public:
mBody = aBody;
}
void
InitChannelInfo(nsIChannel* aChannel)
const nsCString&
GetSecurityInfo() const
{
mChannelInfo.InitFromChannel(aChannel);
return mSecurityInfo;
}
void
InitChannelInfo(const mozilla::ipc::IPCChannelInfo& aChannelInfo)
{
mChannelInfo.InitFromIPCChannelInfo(aChannelInfo);
}
SetSecurityInfo(nsISupports* aSecurityInfo);
void
InitChannelInfo(const ChannelInfo& aChannelInfo)
{
mChannelInfo = aChannelInfo;
}
const ChannelInfo&
GetChannelInfo() const
{
return mChannelInfo;
}
SetSecurityInfo(const nsCString& aSecurityInfo);
private:
~InternalResponse()
@@ -198,7 +185,7 @@ private:
copy->mTerminationReason = mTerminationReason;
copy->mURL = mURL;
copy->mFinalURL = mFinalURL;
copy->mChannelInfo = mChannelInfo;
copy->mSecurityInfo = mSecurityInfo;
return copy.forget();
}
@@ -210,7 +197,7 @@ private:
const nsCString mStatusText;
nsRefPtr<InternalHeaders> mHeaders;
nsCOMPtr<nsIInputStream> mBody;
ChannelInfo mChannelInfo;
nsCString mSecurityInfo;
// For filtered responses.
// Cache, and SW interception should always serialize/access the underlying

View File

@@ -78,16 +78,10 @@ public:
return mInternalResponse->Headers();
}
void
InitChannelInfo(nsIChannel* aChannel)
const nsCString&
GetSecurityInfo() const
{
mInternalResponse->InitChannelInfo(aChannel);
}
const ChannelInfo&
GetChannelInfo() const
{
return mInternalResponse->GetChannelInfo();
return mInternalResponse->GetSecurityInfo();
}
Headers* Headers_();

View File

@@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
'ChannelInfo.h',
'Fetch.h',
'FetchDriver.h',
'Headers.h',
@@ -17,7 +16,6 @@ EXPORTS.mozilla.dom += [
]
UNIFIED_SOURCES += [
'ChannelInfo.cpp',
'Fetch.cpp',
'FetchDriver.cpp',
'Headers.cpp',
@@ -28,21 +26,11 @@ UNIFIED_SOURCES += [
'Response.cpp',
]
IPDL_SOURCES += [
'ChannelInfo.ipdlh',
]
LOCAL_INCLUDES += [
'../workers',
# For HttpBaseChannel.h dependencies
'/netwerk/base',
# For nsDataHandler.h
'/netwerk/protocol/data',
# For HttpBaseChannel.h
'/netwerk/protocol/http',
]
FAIL_ON_WARNINGS = True
FINAL_LIBRARY = 'xul'
include('/ipc/chromium/chromium-config.mozbuild')

View File

@@ -14,6 +14,7 @@
#include "nsIIOService.h"
#include "nsIProtocolHandler.h"
#include "nsIScriptSecurityManager.h"
#include "nsISerializable.h"
#include "nsIStreamLoader.h"
#include "nsIStreamListenerTee.h"
#include "nsIThreadRetargetableRequest.h"
@@ -421,7 +422,7 @@ private:
bool mFailed;
nsCOMPtr<nsIInputStreamPump> mPump;
nsCOMPtr<nsIURI> mBaseURI;
ChannelInfo mChannelInfo;
nsCString mSecurityInfo;
};
NS_IMPL_ISUPPORTS(CacheScriptLoader, nsIStreamLoaderObserver)
@@ -588,9 +589,19 @@ private:
new InternalResponse(200, NS_LITERAL_CSTRING("OK"));
ir->SetBody(mReader);
// Set the channel info of the channel on the response so that it's
// Set the security info of the channel on the response so that it's
// saved in the cache.
ir->InitChannelInfo(channel);
nsCOMPtr<nsISupports> infoObj;
channel->GetSecurityInfo(getter_AddRefs(infoObj));
if (infoObj) {
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(infoObj);
if (serializable) {
ir->SetSecurityInfo(serializable);
MOZ_ASSERT(!ir->GetSecurityInfo().IsEmpty());
} else {
NS_WARNING("A non-serializable object was obtained from nsIChannel::GetSecurityInfo()!");
}
}
nsRefPtr<Response> response = new Response(mCacheCreator->Global(), ir);
@@ -954,9 +965,18 @@ private:
// Take care of the base URI first.
mWorkerPrivate->SetBaseURI(finalURI);
// Store the channel info if needed.
// Store the security info if needed.
if (mWorkerPrivate->IsServiceWorker()) {
mWorkerPrivate->InitChannelInfo(channel);
nsCOMPtr<nsISupports> infoObj;
channel->GetSecurityInfo(getter_AddRefs(infoObj));
if (infoObj) {
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(infoObj);
if (serializable) {
mWorkerPrivate->SetSecurityInfo(serializable);
} else {
NS_WARNING("A non-serializable object was obtained from nsIChannel::GetSecurityInfo()!");
}
}
}
// Now to figure out which principal to give this worker.
@@ -1027,8 +1047,7 @@ private:
void
DataReceivedFromCache(uint32_t aIndex, const uint8_t* aString,
uint32_t aStringLen,
const ChannelInfo& aChannelInfo)
uint32_t aStringLen, const nsCString& aSecurityInfo)
{
AssertIsOnMainThread();
MOZ_ASSERT(aIndex < mLoadInfos.Length());
@@ -1056,7 +1075,7 @@ private:
MOZ_ASSERT(principal);
nsILoadGroup* loadGroup = mWorkerPrivate->GetLoadGroup();
MOZ_ASSERT(loadGroup);
mWorkerPrivate->InitChannelInfo(aChannelInfo);
mWorkerPrivate->SetSecurityInfo(aSecurityInfo);
// Needed to initialize the principal info. This is fine because
// the cache principal cannot change, unlike the channel principal.
mWorkerPrivate->SetPrincipal(principal, loadGroup);
@@ -1410,11 +1429,11 @@ CacheScriptLoader::ResolvedCallback(JSContext* aCx,
nsCOMPtr<nsIInputStream> inputStream;
response->GetBody(getter_AddRefs(inputStream));
mChannelInfo = response->GetChannelInfo();
mSecurityInfo = response->GetSecurityInfo();
if (!inputStream) {
mLoadInfo.mCacheStatus = ScriptLoadInfo::Cached;
mRunnable->DataReceivedFromCache(mIndex, (uint8_t*)"", 0, mChannelInfo);
mRunnable->DataReceivedFromCache(mIndex, (uint8_t*)"", 0, mSecurityInfo);
return;
}
@@ -1470,7 +1489,7 @@ CacheScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aCont
mLoadInfo.mCacheStatus = ScriptLoadInfo::Cached;
mRunnable->DataReceivedFromCache(mIndex, aString, aStringLen, mChannelInfo);
mRunnable->DataReceivedFromCache(mIndex, aString, aStringLen, mSecurityInfo);
return NS_OK;
}

View File

@@ -98,14 +98,14 @@ class FinishResponse final : public nsRunnable
{
nsMainThreadPtrHandle<nsIInterceptedChannel> mChannel;
nsRefPtr<InternalResponse> mInternalResponse;
ChannelInfo mWorkerChannelInfo;
nsCString mWorkerSecurityInfo;
public:
FinishResponse(nsMainThreadPtrHandle<nsIInterceptedChannel>& aChannel,
InternalResponse* aInternalResponse,
const ChannelInfo& aWorkerChannelInfo)
const nsCString& aWorkerSecurityInfo)
: mChannel(aChannel)
, mInternalResponse(aInternalResponse)
, mWorkerChannelInfo(aWorkerChannelInfo)
, mWorkerSecurityInfo(aWorkerSecurityInfo)
{
}
@@ -114,17 +114,19 @@ public:
{
AssertIsOnMainThread();
ChannelInfo channelInfo;
if (mInternalResponse->GetChannelInfo().IsInitialized()) {
channelInfo = mInternalResponse->GetChannelInfo();
} else {
nsCOMPtr<nsISupports> infoObj;
nsAutoCString securityInfo(mInternalResponse->GetSecurityInfo());
if (securityInfo.IsEmpty()) {
// We are dealing with a synthesized response here, so fall back to the
// channel info for the worker script.
channelInfo = mWorkerChannelInfo;
// security info for the worker script.
securityInfo = mWorkerSecurityInfo;
}
nsresult rv = mChannel->SetChannelInfo(&channelInfo);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
nsresult rv = NS_DeserializeObject(securityInfo, getter_AddRefs(infoObj));
if (NS_SUCCEEDED(rv)) {
rv = mChannel->SetSecurityInfo(infoObj);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
mChannel->SynthesizeStatus(mInternalResponse->GetStatus(), mInternalResponse->GetStatusText());
@@ -167,14 +169,14 @@ struct RespondWithClosure
{
nsMainThreadPtrHandle<nsIInterceptedChannel> mInterceptedChannel;
nsRefPtr<InternalResponse> mInternalResponse;
ChannelInfo mWorkerChannelInfo;
nsCString mWorkerSecurityInfo;
RespondWithClosure(nsMainThreadPtrHandle<nsIInterceptedChannel>& aChannel,
InternalResponse* aInternalResponse,
const ChannelInfo& aWorkerChannelInfo)
const nsCString& aWorkerSecurityInfo)
: mInterceptedChannel(aChannel)
, mInternalResponse(aInternalResponse)
, mWorkerChannelInfo(aWorkerChannelInfo)
, mWorkerSecurityInfo(aWorkerSecurityInfo)
{
}
};
@@ -186,7 +188,7 @@ void RespondWithCopyComplete(void* aClosure, nsresult aStatus)
if (NS_SUCCEEDED(aStatus)) {
event = new FinishResponse(data->mInterceptedChannel,
data->mInternalResponse,
data->mWorkerChannelInfo);
data->mWorkerSecurityInfo);
} else {
event = new CancelChannelRunnable(data->mInterceptedChannel);
}
@@ -253,7 +255,7 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValu
worker->AssertIsOnWorkerThread();
nsAutoPtr<RespondWithClosure> closure(
new RespondWithClosure(mInterceptedChannel, ir, worker->GetChannelInfo()));
new RespondWithClosure(mInterceptedChannel, ir, worker->GetSecurityInfo()));
nsCOMPtr<nsIInputStream> body;
response->GetBody(getter_AddRefs(body));
// Errors and redirects may not have a body.

View File

@@ -10,6 +10,7 @@
#include "mozilla/dom/cache/CacheStorage.h"
#include "mozilla/dom/cache/Cache.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsSerializationHelper.h"
#include "nsIPrincipal.h"
#include "Workers.h"
@@ -445,9 +446,9 @@ public:
}
void
InitChannelInfo(nsIChannel* aChannel)
SetSecurityInfo(nsISerializable* aSecurityInfo)
{
mChannelInfo.InitFromChannel(aChannel);
NS_SerializeToString(aSecurityInfo, mSecurityInfo);
}
private:
@@ -544,7 +545,7 @@ private:
new InternalResponse(200, NS_LITERAL_CSTRING("OK"));
ir->SetBody(body);
ir->InitChannelInfo(mChannelInfo);
ir->SetSecurityInfo(mSecurityInfo);
nsRefPtr<Response> response = new Response(aCache->GetGlobalObject(), ir);
@@ -576,7 +577,7 @@ private:
// Only used if the network script has changed and needs to be cached.
nsString mNewCacheName;
ChannelInfo mChannelInfo;
nsCString mSecurityInfo;
nsCString mMaxScope;
@@ -605,7 +606,16 @@ CompareNetwork::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
MOZ_ASSERT(channel == mChannel);
#endif
mManager->InitChannelInfo(mChannel);
nsCOMPtr<nsISupports> infoObj;
mChannel->GetSecurityInfo(getter_AddRefs(infoObj));
if (infoObj) {
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(infoObj);
if (serializable) {
mManager->SetSecurityInfo(serializable);
} else {
NS_WARNING("A non-serializable object was obtained from nsIChannel::GetSecurityInfo()!");
}
}
return NS_OK;
}

View File

@@ -32,6 +32,7 @@
#include "nsIXPConnect.h"
#include "nsPerformance.h"
#include "nsPIDOMWindow.h"
#include "nsSerializationHelper.h"
#include <algorithm>
#include "jsfriendapi.h"
@@ -4074,6 +4075,17 @@ WorkerPrivateParent<Derived>::SetPrincipal(nsIPrincipal* aPrincipal,
PrincipalToPrincipalInfo(aPrincipal, mLoadInfo.mPrincipalInfo)));
}
template <class Derived>
void
WorkerPrivateParent<Derived>::SetSecurityInfo(nsISerializable* aSerializable)
{
MOZ_ASSERT(IsServiceWorker());
AssertIsOnMainThread();
nsAutoCString securityInfo;
NS_SerializeToString(aSerializable, securityInfo);
SetSecurityInfo(securityInfo);
}
template <class Derived>
JSContext*
WorkerPrivateParent<Derived>::ParentJSContext() const

View File

@@ -498,34 +498,24 @@ public:
return mLoadInfo.mServiceWorkerCacheName;
}
const ChannelInfo&
GetChannelInfo() const
const nsCString&
GetSecurityInfo() const
{
MOZ_ASSERT(IsServiceWorker());
return mLoadInfo.mChannelInfo;
return mLoadInfo.mSecurityInfo;
}
void
SetChannelInfo(const ChannelInfo& aChannelInfo)
SetSecurityInfo(const nsCString& aSecurityInfo)
{
MOZ_ASSERT(IsServiceWorker());
AssertIsOnMainThread();
MOZ_ASSERT(!mLoadInfo.mChannelInfo.IsInitialized());
MOZ_ASSERT(aChannelInfo.IsInitialized());
mLoadInfo.mChannelInfo = aChannelInfo;
MOZ_ASSERT(mLoadInfo.mSecurityInfo.IsEmpty());
mLoadInfo.mSecurityInfo = aSecurityInfo;
}
void
InitChannelInfo(nsIChannel* aChannel)
{
mLoadInfo.mChannelInfo.InitFromChannel(aChannel);
}
void
InitChannelInfo(const ChannelInfo& aChannelInfo)
{
mLoadInfo.mChannelInfo = aChannelInfo;
}
SetSecurityInfo(nsISerializable* aSerializable);
// This is used to handle importScripts(). When the worker is first loaded
// and executed, it happens in a sync loop. At this point it sets

View File

@@ -20,7 +20,6 @@
#include "nsILoadContext.h"
#include "nsIWeakReferenceUtils.h"
#include "nsIInterfaceRequestor.h"
#include "mozilla/dom/ChannelInfo.h"
#define BEGIN_WORKERS_NAMESPACE \
namespace mozilla { namespace dom { namespace workers {
@@ -245,7 +244,7 @@ struct WorkerLoadInfo
nsString mServiceWorkerCacheName;
ChannelInfo mChannelInfo;
nsCString mSecurityInfo;
uint64_t mWindowID;
uint64_t mServiceWorkerID;

View File

@@ -9,16 +9,6 @@ interface nsIChannel;
interface nsIOutputStream;
interface nsIURI;
%{C++
namespace mozilla {
namespace dom {
class ChannelInfo;
}
}
%}
[ptr] native ChannelInfo(mozilla::dom::ChannelInfo);
/**
* Interface to allow implementors of nsINetworkInterceptController to control the behaviour
* of intercepted channels without tying implementation details of the interception to
@@ -26,7 +16,7 @@ class ChannelInfo;
* which do not implement nsIChannel.
*/
[scriptable, uuid(f2c07a6b-366d-4ef4-85ab-a77f4bcb1646)]
[scriptable, uuid(2fc1170c-4f9d-4c9e-8e5d-2d351dbe03f2)]
interface nsIInterceptedChannel : nsISupports
{
/**
@@ -77,10 +67,9 @@ interface nsIInterceptedChannel : nsISupports
readonly attribute bool isNavigation;
/**
* This method allows to override the channel info for the channel.
* This method allows to override the security info for the channel.
*/
[noscript]
void setChannelInfo(in ChannelInfo channelInfo);
void setSecurityInfo(in nsISupports securityInfo);
};
/**

View File

@@ -13,7 +13,6 @@
#include "nsHttpChannel.h"
#include "HttpChannelChild.h"
#include "nsHttpResponseHead.h"
#include "mozilla/dom/ChannelInfo.h"
namespace mozilla {
namespace net {
@@ -234,13 +233,13 @@ InterceptedChannelChrome::Cancel()
}
NS_IMETHODIMP
InterceptedChannelChrome::SetChannelInfo(dom::ChannelInfo* aChannelInfo)
InterceptedChannelChrome::SetSecurityInfo(nsISupports* aSecurityInfo)
{
if (!mChannel) {
return NS_ERROR_FAILURE;
}
return aChannelInfo->ResurrectInfoOnChannel(mChannel);
return mChannel->OverrideSecurityInfo(aSecurityInfo);
}
InterceptedChannelContent::InterceptedChannelContent(HttpChannelChild* aChannel,
@@ -341,13 +340,13 @@ InterceptedChannelContent::Cancel()
}
NS_IMETHODIMP
InterceptedChannelContent::SetChannelInfo(dom::ChannelInfo* aChannelInfo)
InterceptedChannelContent::SetSecurityInfo(nsISupports* aSecurityInfo)
{
if (!mChannel) {
return NS_ERROR_FAILURE;
}
return aChannelInfo->ResurrectInfoOnChannel(mChannel);
return mChannel->OverrideSecurityInfo(aSecurityInfo);
}
} // namespace net

View File

@@ -82,7 +82,7 @@ public:
NS_IMETHOD SynthesizeStatus(uint16_t aStatus, const nsACString& aReason) override;
NS_IMETHOD SynthesizeHeader(const nsACString& aName, const nsACString& aValue) override;
NS_IMETHOD Cancel() override;
NS_IMETHOD SetChannelInfo(mozilla::dom::ChannelInfo* aChannelInfo) override;
NS_IMETHOD SetSecurityInfo(nsISupports* aSecurityInfo) override;
virtual void NotifyController() override;
};
@@ -109,7 +109,7 @@ public:
NS_IMETHOD SynthesizeStatus(uint16_t aStatus, const nsACString& aReason) override;
NS_IMETHOD SynthesizeHeader(const nsACString& aName, const nsACString& aValue) override;
NS_IMETHOD Cancel() override;
NS_IMETHOD SetChannelInfo(mozilla::dom::ChannelInfo* aChannelInfo) override;
NS_IMETHOD SetSecurityInfo(nsISupports* aSecurityInfo) override;
virtual void NotifyController() override;
};

View File

@@ -15,7 +15,6 @@
#include "nsITimer.h"
#include "NullHttpTransaction.h"
#include "mozilla/TimeStamp.h"
#include "prio.h"
// a TLSFilterTransaction wraps another nsAHttpTransaction but
// applies a encode/decode filter of TLS onto the ReadSegments

View File

@@ -11,7 +11,6 @@
#include "nsProxyInfo.h"
#include "nsCOMPtr.h"
#include "nsStringFwd.h"
#include "mozilla/Logging.h"
extern PRLogModuleInfo *gHttpLog;