Backed out 2 changesets (bug 1120487) for card_manager_test.js Gaia unit test failures.

Backed out changeset 357fcbe1de45 (bug 1120487)
Backed out changeset 33c588a14445 (bug 1120487)

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2015-05-20 14:12:13 -04:00
parent da32a81d18
commit c2339f6da3
5 changed files with 22 additions and 243 deletions

View File

@ -91,7 +91,6 @@ XPIDL_SOURCES += [
'nsIRequestObserverProxy.idl',
'nsIResponseHeadProvider.idl',
'nsIResumableChannel.idl',
'nsISecCheckWrapChannel.idl',
'nsISecretDecoderRing.idl',
'nsISecureBrowserUI.idl',
'nsISecurityEventSink.idl',
@ -214,7 +213,6 @@ UNIFIED_SOURCES += [
'nsProtocolProxyService.cpp',
'nsProxyInfo.cpp',
'nsRequestObserverProxy.cpp',
'nsSecCheckWrapChannel.cpp',
'nsSerializationHelper.cpp',
'nsServerSocket.cpp',
'nsSimpleNestedURI.cpp',

View File

@ -22,7 +22,6 @@
#include "nsEscape.h"
#include "nsNetCID.h"
#include "nsCRT.h"
#include "nsSecCheckWrapChannel.h"
#include "nsSimpleNestedURI.h"
#include "nsNetUtil.h"
#include "nsTArray.h"
@ -662,43 +661,43 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
// Keep in mind that Addons can implement their own Protocolhandlers, hence
// NewChannel2() might *not* be implemented.
// We do not want to break those addons, therefore we first try to create a channel
// calling NewChannel2(); if that fails:
// * we fall back to creating a channel by calling NewChannel()
// * wrap the addon channel
// * and attach the loadInfo to the channel wrapper
nsCOMPtr<nsIChannel> channel;
// calling NewChannel2(); if that fails we fall back to creating a channel by calling
// NewChannel();
bool newChannel2Succeeded = true;
nsCOMPtr<nsIProxiedProtocolHandler> pph = do_QueryInterface(handler);
if (pph) {
rv = pph->NewProxiedChannel2(aURI, nullptr, aProxyFlags, aProxyURI,
aLoadInfo, getter_AddRefs(channel));
aLoadInfo, result);
// if calling NewProxiedChannel2() fails we try to fall back to
// creating a new proxied channel by calling NewProxiedChannel().
if (NS_FAILED(rv)) {
newChannel2Succeeded = false;
rv = pph->NewProxiedChannel(aURI, nullptr, aProxyFlags, aProxyURI,
getter_AddRefs(channel));
NS_ENSURE_SUCCESS(rv, rv);
// we have to wrap that channel
channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
result);
}
}
else {
rv = handler->NewChannel2(aURI, aLoadInfo, getter_AddRefs(channel));
rv = handler->NewChannel2(aURI, aLoadInfo, result);
// if calling newChannel2() fails we try to fall back to
// creating a new channel by calling NewChannel().
if (NS_FAILED(rv)) {
rv = handler->NewChannel(aURI, getter_AddRefs(channel));
NS_ENSURE_SUCCESS(rv, rv);
// we have to wrap that channel
channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
newChannel2Succeeded = false;
rv = handler->NewChannel(aURI, result);
}
}
NS_ENSURE_SUCCESS(rv, rv);
// Make sure that all the individual protocolhandlers attach a loadInfo.
if (aLoadInfo) {
// make sure we have the same instance of loadInfo on the newly created channel
if (aLoadInfo && newChannel2Succeeded) {
// Make sure that all the individual protocolhandlers attach
// a loadInfo within it's implementation of ::newChannel2().
// Once Bug 1087720 lands, we should remove the surrounding
// if-clause here and always assert that we indeed have a
// loadinfo on the newly created channel.
nsCOMPtr<nsILoadInfo> loadInfo;
channel->GetLoadInfo(getter_AddRefs(loadInfo));
(*result)->GetLoadInfo(getter_AddRefs(loadInfo));
// make sure we have the same instance of loadInfo on the newly created channel
if (aLoadInfo != loadInfo) {
MOZ_ASSERT(false, "newly created channel must have a loadinfo attached");
return NS_ERROR_UNEXPECTED;
@ -707,7 +706,7 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
// If we're sandboxed, make sure to clear any owner the channel
// might already have.
if (loadInfo->GetLoadingSandboxed()) {
channel->SetOwner(nullptr);
(*result)->SetOwner(nullptr);
}
}
@ -719,7 +718,7 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
// implement the new interface.
// See bug 529041
if (!gHasWarnedUploadChannel2 && scheme.EqualsLiteral("http")) {
nsCOMPtr<nsIUploadChannel2> uploadChannel2 = do_QueryInterface(channel);
nsCOMPtr<nsIUploadChannel2> uploadChannel2 = do_QueryInterface(*result);
if (!uploadChannel2) {
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
@ -732,7 +731,6 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
}
}
channel.forget(result);
return NS_OK;
}

View File

@ -1,24 +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 "nsISupports.idl"
interface nsIChannel;
/**
* nsISecCheckWrapChannel
* Describes an XPCOM component used to wrap channels for performing
* security checks. Channels wrapped inside this class can use
* this interface to query the wrapped inner channel.
*/
[scriptable, uuid(9446c5d5-c9fb-4a6e-acf9-ca4fc666efe0)]
interface nsISecCheckWrapChannel : nsISupports
{
/**
* Returns the wrapped channel inside this class.
*/
readonly attribute nsIChannel innerChannel;
};

View File

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 "nsSecCheckWrapChannel.h"
#include "nsHttpChannel.h"
#include "nsCOMPtr.h"
#ifdef PR_LOGGING
static PRLogModuleInfo*
GetChannelWrapperLog()
{
static PRLogModuleInfo* gChannelWrapperPRLog;
if (!gChannelWrapperPRLog) {
gChannelWrapperPRLog = PR_NewLogModule("ChannelWrapper");
}
return gChannelWrapperPRLog;
}
#endif
#define CHANNELWRAPPERLOG(args) PR_LOG(GetChannelWrapperLog(), 4, args)
NS_IMPL_ADDREF(nsSecCheckWrapChannelBase)
NS_IMPL_RELEASE(nsSecCheckWrapChannelBase)
NS_INTERFACE_MAP_BEGIN(nsSecCheckWrapChannelBase)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIHttpChannel, mHttpChannel)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIHttpChannelInternal, mHttpChannelInternal)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIHttpChannel)
NS_INTERFACE_MAP_ENTRY(nsIRequest)
NS_INTERFACE_MAP_ENTRY(nsIChannel)
NS_INTERFACE_MAP_ENTRY(nsISecCheckWrapChannel)
NS_INTERFACE_MAP_END
//---------------------------------------------------------
// nsSecCheckWrapChannelBase implementation
//---------------------------------------------------------
nsSecCheckWrapChannelBase::nsSecCheckWrapChannelBase(nsIChannel* aChannel)
: mChannel(aChannel)
, mHttpChannel(do_QueryInterface(aChannel))
, mHttpChannelInternal(do_QueryInterface(aChannel))
, mRequest(do_QueryInterface(aChannel))
{
MOZ_ASSERT(mChannel, "can not create a channel wrapper without a channel");
}
nsSecCheckWrapChannelBase::~nsSecCheckWrapChannelBase()
{
}
//---------------------------------------------------------
// nsISecCheckWrapChannel implementation
//---------------------------------------------------------
NS_IMETHODIMP
nsSecCheckWrapChannelBase::GetInnerChannel(nsIChannel **aInnerChannel)
{
NS_IF_ADDREF(*aInnerChannel = mChannel);
return NS_OK;
}
//---------------------------------------------------------
// nsSecCheckWrapChannel implementation
//---------------------------------------------------------
nsSecCheckWrapChannel::nsSecCheckWrapChannel(nsIChannel* aChannel,
nsILoadInfo* aLoadInfo)
: nsSecCheckWrapChannelBase(aChannel)
, mLoadInfo(aLoadInfo)
{
#ifdef PR_LOGGING
{
nsCOMPtr<nsIURI> uri;
mChannel->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
if (uri) {
uri->GetSpec(spec);
}
CHANNELWRAPPERLOG(("nsSecCheckWrapChannel::nsSecCheckWrapChannel [%p] (%s)",this, spec.get()));
}
#endif
}
nsSecCheckWrapChannel::~nsSecCheckWrapChannel()
{
}
//---------------------------------------------------------
// nsIChannel implementation
//---------------------------------------------------------
NS_IMETHODIMP
nsSecCheckWrapChannel::GetLoadInfo(nsILoadInfo** aLoadInfo)
{
CHANNELWRAPPERLOG(("nsSecCheckWrapChannel::GetLoadInfo() [%p]",this));
NS_IF_ADDREF(*aLoadInfo = mLoadInfo);
return NS_OK;
}
NS_IMETHODIMP
nsSecCheckWrapChannel::SetLoadInfo(nsILoadInfo* aLoadInfo)
{
CHANNELWRAPPERLOG(("nsSecCheckWrapChannel::SetLoadInfo() [%p]", this));
mLoadInfo = aLoadInfo;
return NS_OK;
}

View File

@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 nsSecCheckWrapChannel_h__
#define nsSecCheckWrapChannel_h__
#include "nsIHttpChannel.h"
#include "nsIHttpChannelInternal.h"
#include "nsISecCheckWrapChannel.h"
#include "nsIWyciwygChannel.h"
#include "mozilla/LoadInfo.h"
/*
* The nsSecCheckWrapChannelBase wraps channels that do *not*
* * provide a newChannel2() implementation
* * provide get/setLoadInfo functions
*
* In order to perform security checks for channels
* a) before opening the channel, and
* b) after redirects
* we are attaching a loadinfo object to every channel which
* provides information about the content-type of the channel,
* who initiated the load, etc.
*
* Addon created channels might *not* provide that loadInfo object for
* some transition time before we mark the NewChannel-API as deprecated.
* We do not want to break those addons hence we wrap such channels
* using the provided wrapper in this class.
*
* Please note that the wrapper only forwards calls for
* * nsIRequest
* * nsIChannel
* * nsIHttpChannel
* * nsIHttpChannelInternal
*
* In case any addon needs to query the inner channel this class
* provides a readonly function to query the wrapped channel.
*
*/
class nsSecCheckWrapChannelBase : public nsIHttpChannel
, public nsIHttpChannelInternal
, public nsISecCheckWrapChannel
{
public:
NS_FORWARD_NSIHTTPCHANNEL(mHttpChannel->)
NS_FORWARD_NSIHTTPCHANNELINTERNAL(mHttpChannelInternal->)
NS_FORWARD_NSICHANNEL(mChannel->)
NS_FORWARD_NSIREQUEST(mRequest->)
NS_DECL_NSISECCHECKWRAPCHANNEL
NS_DECL_ISUPPORTS
explicit nsSecCheckWrapChannelBase(nsIChannel* aChannel);
protected:
virtual ~nsSecCheckWrapChannelBase();
nsCOMPtr<nsIChannel> mChannel;
// We do a QI in the constructor to set the following pointers.
nsCOMPtr<nsIHttpChannel> mHttpChannel;
nsCOMPtr<nsIHttpChannelInternal> mHttpChannelInternal;
nsCOMPtr<nsIRequest> mRequest;
};
/* We define a separate class here to make it clear that we're
* overriding Get/SetLoadInfo, rather that using the forwarded
* implementations provided by NS_FORWARD_NSICHANNEL"
*/
class nsSecCheckWrapChannel : public nsSecCheckWrapChannelBase
{
public:
NS_IMETHOD GetLoadInfo(nsILoadInfo **aLoadInfo);
NS_IMETHOD SetLoadInfo(nsILoadInfo *aLoadInfo);
nsSecCheckWrapChannel(nsIChannel* aChannel, nsILoadInfo* aLoadInfo);
protected:
virtual ~nsSecCheckWrapChannel();
nsCOMPtr<nsILoadInfo> mLoadInfo;
};
#endif // nsSecCheckWrapChannel_h__