Bug 1324419 - Use QueryObject for nsHttpChannel. r=mcmanus

--HG--
extra : rebase_source : 192a4705e4e91bc393a283743a1ad8880da6aeba
This commit is contained in:
Honza Bambas 2017-02-17 08:08:00 -05:00
Родитель 5d95d03e70
Коммит bb033696f7
8 изменённых файлов: 20 добавлений и 48 удалений

Просмотреть файл

@ -19,6 +19,7 @@
#include "nsHttpChannel.h"
#include "LoadInfo.h"
#include "mozilla/Unused.h"
#include "nsQueryObject.h"
namespace mozilla {
namespace net {
@ -129,7 +130,9 @@ HSTSPrimingListener::CheckHSTSPrimingRequestStatus(nsIRequest* aRequest)
}
bool synthesized = false;
nsHttpChannel* rawHttpChannel = static_cast<nsHttpChannel*>(httpChannel.get());
RefPtr<nsHttpChannel> rawHttpChannel = do_QueryObject(httpChannel);
NS_ENSURE_STATE(rawHttpChannel);
rv = rawHttpChannel->GetResponseSynthesized(&synthesized);
NS_ENSURE_SUCCESS(rv, rv);
if (synthesized) {

Просмотреть файл

@ -2722,12 +2722,6 @@ HttpBaseChannel::GetIntegrityMetadata(nsAString& aIntegrityMetadata)
return NS_OK;
}
mozilla::net::nsHttpChannel*
HttpBaseChannel::QueryHttpChannelImpl(void)
{
return nullptr;
}
//-----------------------------------------------------------------------------
// HttpBaseChannel::nsISupportsPriority
//-----------------------------------------------------------------------------

Просмотреть файл

@ -251,7 +251,6 @@ public:
NS_IMETHOD GetConnectionInfoHashKey(nsACString& aConnectionInfoHashKey) override;
NS_IMETHOD GetIntegrityMetadata(nsAString& aIntegrityMetadata) override;
NS_IMETHOD SetIntegrityMetadata(const nsAString& aIntegrityMetadata) override;
virtual mozilla::net::nsHttpChannel * QueryHttpChannelImpl(void) override;
inline void CleanRedirectCacheChainIfNecessary()
{

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsIWindowWatcher.h"
#include "nsIDocument.h"
#include "nsStringStream.h"
#include "nsQueryObject.h"
using mozilla::BasePrincipal;
using namespace mozilla::dom;
@ -366,13 +367,14 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannelInternal(getter_AddRefs(channel), uri, loadInfo,
nullptr, nullptr, aLoadFlags, ios);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return SendFailedAsyncOpen(rv);
}
// This cast is safe since this is AsyncOpen specific to http. channel
// is ensured to be nsHttpChannel.
mChannel = static_cast<nsHttpChannel *>(channel.get());
mChannel = do_QueryObject(channel, &rv);
if (NS_FAILED(rv)) {
return SendFailedAsyncOpen(rv);
}
// Set the channelId allocated in child to the parent instance
mChannel->SetChannelId(aChannelId);
@ -601,11 +603,13 @@ HttpChannelParent::ConnectChannel(const uint32_t& registrarId, const bool& shoul
return true;
}
// It's safe to cast here since the found parent-side real channel is ensured
// to be http (nsHttpChannel). ConnectChannel called from HttpChannelParent::Init
// can only be called for http channels. It's bound by ipdl.
mChannel = static_cast<nsHttpChannel*>(channel.get());
LOG((" found channel %p, rv=%08x", mChannel.get(), rv));
LOG((" found channel %p, rv=%08x", channel.get(), rv));
mChannel = do_QueryObject(channel);
if (!mChannel) {
LOG((" but it's not nsHttpChannel"));
Delete();
return true;
}
nsCOMPtr<nsINetworkInterceptController> controller;
NS_QueryNotificationCallbacks(channel, controller);
@ -1102,14 +1106,7 @@ HttpChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
MOZ_RELEASE_ASSERT(!mDivertingFromChild,
"Cannot call OnStartRequest if diverting is set!");
// We can't cast here since the new channel can be a redirect to a different
// schema. We must query the channel implementation through a special method.
nsHttpChannel *chan = nullptr;
nsCOMPtr<nsIHttpChannelInternal> httpChannelInternal(do_QueryInterface(aRequest));
if (httpChannelInternal) {
chan = httpChannelInternal->QueryHttpChannelImpl();
}
RefPtr<nsHttpChannel> chan = do_QueryObject(aRequest);
if (!chan) {
LOG((" aRequest is not nsHttpChannel"));
NS_ERROR("Expecting only nsHttpChannel as aRequest in HttpChannelParent::OnStartRequest");

Просмотреть файл

@ -6263,12 +6263,6 @@ nsHttpChannel::ForceIntercepted(uint64_t aInterceptionID)
return NS_OK;
}
mozilla::net::nsHttpChannel*
nsHttpChannel::QueryHttpChannelImpl(void)
{
return this;
}
//-----------------------------------------------------------------------------
// nsHttpChannel::nsISupportsPriority
//-----------------------------------------------------------------------------

Просмотреть файл

@ -152,7 +152,6 @@ public:
// nsIHttpChannelInternal
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override;
NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override;
virtual mozilla::net::nsHttpChannel * QueryHttpChannelImpl(void) override;
// nsISupportsPriority
NS_IMETHOD SetPriority(int32_t value) override;
// nsIClassOfService

Просмотреть файл

@ -9,12 +9,10 @@
#include "nsTArrayForwardDeclare.h"
template<class T> class nsCOMArray;
class nsCString;
namespace mozilla { namespace net { class nsHttpChannel; } }
%}
[ptr] native StringArray(nsTArray<nsCString>);
[ref] native StringArrayRef(const nsTArray<nsCString>);
[ref] native securityMessagesArray(nsCOMArray<nsISecurityConsoleMessage>);
[ptr] native nsHttpChannelPtr(mozilla::net::nsHttpChannel);
interface nsIAsyncInputStream;
interface nsIAsyncOutputStream;
@ -305,10 +303,4 @@ interface nsIHttpChannelInternal : nsISupports
* The connection info's hash key. We use it to test connection separation.
*/
readonly attribute ACString connectionInfoHashKey;
/**
* Returns nsHttpChannel (self) when this actually is implementing nsHttpChannel.
*/
[noscript, notxpcom, nostdcall]
nsHttpChannelPtr queryHttpChannelImpl();
};

Просмотреть файл

@ -1015,15 +1015,9 @@ nsViewSourceChannel::SetIsMainDocumentChannel(bool aValue)
mHttpChannel->SetIsMainDocumentChannel(aValue);
}
// Have to manually forward since these are [notxpcom]
// Have to manually forward SetCorsPreflightParameters since it's [notxpcom]
void
nsViewSourceChannel::SetCorsPreflightParameters(const nsTArray<nsCString>& aUnsafeHeaders)
{
mHttpChannelInternal->SetCorsPreflightParameters(aUnsafeHeaders);
}
mozilla::net::nsHttpChannel *
nsViewSourceChannel::QueryHttpChannelImpl()
{
return mHttpChannelInternal->QueryHttpChannelImpl();
}