mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
Bug 1556489 - P25. Make nsIIdentChannel support conditional for nsBaseChannel. r=mayhemer
So that we can restrict QI(nsIIdentChannel) to nsIHttpChannel and DocumentChannelChild objects only. Differential Revision: https://phabricator.services.mozilla.com/D44111 MANUAL PUSH: multiple authors stack
This commit is contained in:
parent
e93ff775a3
commit
1c657f7d19
@ -23,7 +23,6 @@
|
||||
#include "LoadInfo.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsRedirectHistoryEntry.h"
|
||||
#include "nsHttpHandler.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -67,8 +66,6 @@ nsBaseChannel::nsBaseChannel()
|
||||
mContentLength(-1),
|
||||
mWasOpened(false) {
|
||||
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE);
|
||||
RefPtr<nsHttpHandler> handler = nsHttpHandler::GetInstance();
|
||||
Unused << handler->NewChannelId(mChannelId);
|
||||
}
|
||||
|
||||
nsBaseChannel::~nsBaseChannel() {
|
||||
@ -350,11 +347,22 @@ void nsBaseChannel::ClassifyURI() {
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsBaseChannel::nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(
|
||||
nsBaseChannel, nsHashPropertyBag, nsIRequest, nsIChannel, nsIIdentChannel,
|
||||
nsIThreadRetargetableRequest, nsIInterfaceRequestor, nsITransportEventSink,
|
||||
nsIRequestObserver, nsIStreamListener, nsIThreadRetargetableStreamListener,
|
||||
nsIAsyncVerifyRedirectCallback, nsIPrivateBrowsingChannel)
|
||||
NS_IMPL_ADDREF(nsBaseChannel)
|
||||
NS_IMPL_RELEASE(nsBaseChannel)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsBaseChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIChannel)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIdentChannel, mChannelId.isSome())
|
||||
NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITransportEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAsyncVerifyRedirectCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrivateBrowsingChannel)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsHashPropertyBag)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsBaseChannel::nsIRequest
|
||||
@ -705,13 +713,19 @@ nsBaseChannel::AsyncOpen(nsIStreamListener* aListener) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseChannel::GetChannelId(uint64_t* aChannelId) {
|
||||
*aChannelId = mChannelId;
|
||||
if (!mChannelId) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
*aChannelId = *mChannelId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseChannel::SetChannelId(uint64_t aChannelId) {
|
||||
mChannelId = aChannelId;
|
||||
if (!mChannelId) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
*mChannelId = aChannelId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define nsBaseChannel_h__
|
||||
|
||||
#include "mozilla/net/NeckoTargetHolder.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
@ -41,6 +42,12 @@ class nsIInputStream;
|
||||
//
|
||||
// nsBaseChannel implements nsITransportEventSink to support progress & status
|
||||
// notifications generated by the transport layer.
|
||||
//
|
||||
// nsBaseChannel will only implement nsIIdentChannel if mChannelId is set.
|
||||
// It is required for devtools to capture transfer information for network
|
||||
// connection, and not all nsBaseChannel implementation should be logged.
|
||||
// Currently only DocumentChannelChild implements nsIIdentChannel via
|
||||
// nsBaseChannel.
|
||||
|
||||
class nsBaseChannel
|
||||
: public nsHashPropertyBag,
|
||||
@ -300,7 +307,7 @@ class nsBaseChannel
|
||||
uint32_t mContentDispositionHint;
|
||||
nsAutoPtr<nsString> mContentDispositionFilename;
|
||||
int64_t mContentLength;
|
||||
uint64_t mChannelId;
|
||||
mozilla::Maybe<uint64_t> mChannelId;
|
||||
bool mWasOpened;
|
||||
|
||||
friend class mozilla::net::PrivateBrowsingChannel<nsBaseChannel>;
|
||||
|
@ -15,12 +15,13 @@
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/net/HttpChannelChild.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
#include "nsContentSecurityManager.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsHttpHandler.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsSerializationHelper.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::ipc;
|
||||
@ -60,6 +61,10 @@ DocumentChannelChild::DocumentChannelChild(
|
||||
SetURI(aLoadState->URI());
|
||||
SetLoadInfo(aLoadInfo);
|
||||
SetLoadFlags(aLoadFlags);
|
||||
RefPtr<nsHttpHandler> handler = nsHttpHandler::GetInstance();
|
||||
uint64_t channelId;
|
||||
Unused << handler->NewChannelId(channelId);
|
||||
mChannelId.emplace(channelId);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -141,7 +146,7 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
|
||||
args.cacheKey() = mCacheKey;
|
||||
args.isActive() = mIsActive;
|
||||
args.isTopLevelDoc() = mIsTopLevelDoc;
|
||||
args.channelId() = mChannelId;
|
||||
args.channelId() = *mChannelId;
|
||||
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
NS_QueryNotificationCallbacks(this, loadContext);
|
||||
|
Loading…
x
Reference in New Issue
Block a user