зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1215140 P10 Avoid AddRef'ing the nsIChannel OMT. r=bz
This commit is contained in:
Родитель
e3bee41820
Коммит
69c8a55480
|
@ -109,9 +109,11 @@ AsyncLog(nsIInterceptedChannel *aInterceptedChannel,
|
|||
const nsACString& aMessageName, const nsTArray<nsString>& aParams)
|
||||
{
|
||||
MOZ_ASSERT(aInterceptedChannel);
|
||||
nsCOMPtr<nsIChannel> inner;
|
||||
aInterceptedChannel->GetChannel(getter_AddRefs(inner));
|
||||
nsCOMPtr<nsIConsoleReportCollector> reporter = do_QueryInterface(inner);
|
||||
// Since the intercepted channel is kept alive and paused while handling
|
||||
// the FetchEvent, we are guaranteed the reporter is stable on the worker
|
||||
// thread.
|
||||
nsIConsoleReportCollector* reporter =
|
||||
aInterceptedChannel->GetConsoleReportCollector();
|
||||
if (reporter) {
|
||||
reporter->AddConsoleReport(nsIScriptError::errorFlag,
|
||||
NS_LITERAL_CSTRING("Service Worker Interception"),
|
||||
|
|
|
@ -146,3 +146,9 @@ InterceptedJARChannel::NotifyController()
|
|||
}
|
||||
mController = nullptr;
|
||||
}
|
||||
|
||||
nsIConsoleReportCollector*
|
||||
InterceptedJARChannel::GetConsoleReportCollector() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ public:
|
|||
NS_DECL_NSIINTERCEPTEDCHANNEL
|
||||
|
||||
void NotifyController();
|
||||
|
||||
virtual nsIConsoleReportCollector*
|
||||
GetConsoleReportCollector() const override;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -11,6 +11,7 @@ interface nsIOutputStream;
|
|||
interface nsIURI;
|
||||
|
||||
%{C++
|
||||
#include "nsIConsoleReportCollector.h"
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class ChannelInfo;
|
||||
|
@ -27,7 +28,7 @@ class ChannelInfo;
|
|||
* which do not implement nsIChannel.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(afe6aae6-a80d-405b-856e-df36c19bf3c8)]
|
||||
[scriptable, uuid(ea78e439-cc42-4b2d-a42b-85ab55a149d1)]
|
||||
interface nsIInterceptedChannel : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -85,6 +86,18 @@ interface nsIInterceptedChannel : nsISupports
|
|||
*/
|
||||
[noscript]
|
||||
readonly attribute nsContentPolicyType internalContentPolicyType;
|
||||
|
||||
%{C++
|
||||
// Allow access to the inner channel as a ConsoleReportCollector off
|
||||
// the main thread. Pure C++ method here to avoid requiring an
|
||||
// AddRef() during QI. Callers should not save the returned pointer.
|
||||
// May return nullptr.
|
||||
//
|
||||
// Note: Only safe to use OMT prior to resetInterception(),
|
||||
// finishSynthesizedResponse(), and cancel().
|
||||
virtual nsIConsoleReportCollector*
|
||||
GetConsoleReportCollector() const = 0;
|
||||
%}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -134,6 +134,16 @@ InterceptedChannelChrome::NotifyController()
|
|||
DoNotifyController();
|
||||
}
|
||||
|
||||
nsIConsoleReportCollector*
|
||||
InterceptedChannelChrome::GetConsoleReportCollector() const
|
||||
{
|
||||
// The ConsoleReportCollector should only be used when the inner channel is
|
||||
// stable. Nothing should try to use it once we return to the main thread
|
||||
// and clear the inner channel.
|
||||
MOZ_ASSERT(mChannel);
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::GetChannel(nsIChannel** aChannel)
|
||||
{
|
||||
|
@ -312,6 +322,16 @@ InterceptedChannelContent::NotifyController()
|
|||
DoNotifyController();
|
||||
}
|
||||
|
||||
nsIConsoleReportCollector*
|
||||
InterceptedChannelContent::GetConsoleReportCollector() const
|
||||
{
|
||||
// The ConsoleReportCollector should only be used when the inner channel is
|
||||
// stable. Nothing should try to use it once we return to the main thread
|
||||
// and clear the inner channel.
|
||||
MOZ_ASSERT(mChannel);
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelContent::GetChannel(nsIChannel** aChannel)
|
||||
{
|
||||
|
|
|
@ -82,6 +82,9 @@ public:
|
|||
NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override;
|
||||
|
||||
virtual void NotifyController() override;
|
||||
|
||||
virtual nsIConsoleReportCollector*
|
||||
GetConsoleReportCollector() const override;
|
||||
};
|
||||
|
||||
class InterceptedChannelContent : public InterceptedChannelBase
|
||||
|
@ -110,6 +113,9 @@ public:
|
|||
NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override;
|
||||
|
||||
virtual void NotifyController() override;
|
||||
|
||||
virtual nsIConsoleReportCollector*
|
||||
GetConsoleReportCollector() const override;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
Загрузка…
Ссылка в новой задаче