diff --git a/CLOBBER b/CLOBBER index 04652348f9b5..5630ff8575ec 100644 --- a/CLOBBER +++ b/CLOBBER @@ -22,4 +22,4 @@ # changes to stick? As of bug 928195, this shouldn't be necessary! Please # don't change CLOBBER for WebIDL changes any more. -Merge day clobber +Bug 1220007 Clobber since .idl changes not getting picked up on emulator-L in b2g-inbound diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index efb226352217..01683e494144 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -113,10 +113,7 @@ AsyncLog(nsIInterceptedChannel *aInterceptedChannel, const nsACString& aMessageName, const nsTArray& aParams) { MOZ_ASSERT(aInterceptedChannel); - // 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 = + nsCOMPtr reporter = aInterceptedChannel->GetConsoleReportCollector(); if (reporter) { reporter->AddConsoleReport(nsIScriptError::errorFlag, diff --git a/modules/libjar/InterceptedJARChannel.cpp b/modules/libjar/InterceptedJARChannel.cpp index 832314534306..a47c26247939 100644 --- a/modules/libjar/InterceptedJARChannel.cpp +++ b/modules/libjar/InterceptedJARChannel.cpp @@ -123,6 +123,12 @@ InterceptedJARChannel::SetChannelInfo(mozilla::dom::ChannelInfo* aChannelInfo) return aChannelInfo->ResurrectInfoOnChannel(mChannel); } +NS_IMETHODIMP +InterceptedJARChannel::GetConsoleReportCollector(nsIConsoleReportCollector**) +{ + return NS_ERROR_NOT_AVAILABLE; +} + void InterceptedJARChannel::NotifyController() { @@ -146,9 +152,3 @@ InterceptedJARChannel::NotifyController() } mController = nullptr; } - -nsIConsoleReportCollector* -InterceptedJARChannel::GetConsoleReportCollector() const -{ - return nullptr; -} diff --git a/modules/libjar/InterceptedJARChannel.h b/modules/libjar/InterceptedJARChannel.h index 07a722b81ddc..f1dd2e78e7b4 100644 --- a/modules/libjar/InterceptedJARChannel.h +++ b/modules/libjar/InterceptedJARChannel.h @@ -53,9 +53,6 @@ public: NS_DECL_NSIINTERCEPTEDCHANNEL void NotifyController(); - - virtual nsIConsoleReportCollector* - GetConsoleReportCollector() const override; }; } // namespace net diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl index 83f96ef225ea..3e9ff02018c3 100644 --- a/netwerk/base/nsINetworkInterceptController.idl +++ b/netwerk/base/nsINetworkInterceptController.idl @@ -7,6 +7,7 @@ #include "nsIContentPolicyBase.idl" interface nsIChannel; +interface nsIConsoleReportCollector; interface nsIOutputStream; interface nsIURI; @@ -28,7 +29,7 @@ class ChannelInfo; * which do not implement nsIChannel. */ -[scriptable, uuid(ea78e439-cc42-4b2d-a42b-85ab55a149d1)] +[scriptable, uuid(231bb567-90e1-4973-9728-7dab93ab29a8)] interface nsIInterceptedChannel : nsISupports { /** @@ -87,16 +88,17 @@ interface nsIInterceptedChannel : nsISupports [noscript] readonly attribute nsContentPolicyType internalContentPolicyType; + [noscript] + readonly attribute nsIConsoleReportCollector consoleReportCollector; + %{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; + already_AddRefed + GetConsoleReportCollector() + { + nsCOMPtr reporter; + GetConsoleReportCollector(getter_AddRefs(reporter)); + return reporter.forget(); + } %} }; diff --git a/netwerk/protocol/http/InterceptedChannel.cpp b/netwerk/protocol/http/InterceptedChannel.cpp index 0a9c723774c7..c36351955d52 100644 --- a/netwerk/protocol/http/InterceptedChannel.cpp +++ b/netwerk/protocol/http/InterceptedChannel.cpp @@ -13,6 +13,7 @@ #include "nsHttpChannel.h" #include "HttpChannelChild.h" #include "nsHttpResponseHead.h" +#include "mozilla/ConsoleReportCollector.h" #include "mozilla/dom/ChannelInfo.h" namespace mozilla { @@ -37,6 +38,7 @@ NS_IMPL_ISUPPORTS(InterceptedChannelBase, nsIInterceptedChannel) InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController) : mController(aController) +, mReportCollector(new ConsoleReportCollector()) { } @@ -107,6 +109,15 @@ InterceptedChannelBase::DoSynthesizeHeader(const nsACString& aName, const nsACSt return NS_OK; } +NS_IMETHODIMP +InterceptedChannelBase::GetConsoleReportCollector(nsIConsoleReportCollector** aCollectorOut) +{ + MOZ_ASSERT(aCollectorOut); + nsCOMPtr ref = mReportCollector; + ref.forget(aCollectorOut); + return NS_OK; +} + InterceptedChannelChrome::InterceptedChannelChrome(nsHttpChannel* aChannel, nsINetworkInterceptController* aController, nsICacheEntry* aEntry) @@ -134,16 +145,6 @@ 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) { @@ -158,6 +159,8 @@ InterceptedChannelChrome::ResetInterception() return NS_ERROR_NOT_AVAILABLE; } + mReportCollector->FlushConsoleReports(mChannel); + mSynthesizedCacheEntry->AsyncDoom(nullptr); mSynthesizedCacheEntry = nullptr; @@ -200,6 +203,8 @@ InterceptedChannelChrome::FinishSynthesizedResponse(const nsACString& aFinalURLS return NS_ERROR_NOT_AVAILABLE; } + mReportCollector->FlushConsoleReports(mChannel); + EnsureSynthesizedResponse(); // If the synthesized response is a redirect, then we want to respect @@ -273,6 +278,8 @@ InterceptedChannelChrome::Cancel(nsresult aStatus) return NS_ERROR_FAILURE; } + mReportCollector->FlushConsoleReports(mChannel); + // we need to use AsyncAbort instead of Cancel since there's no active pump // to cancel which will provide OnStart/OnStopRequest to the channel. nsresult rv = mChannel->AsyncAbort(aStatus); @@ -322,16 +329,6 @@ 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) { @@ -346,6 +343,8 @@ InterceptedChannelContent::ResetInterception() return NS_ERROR_NOT_AVAILABLE; } + mReportCollector->FlushConsoleReports(mChannel); + mResponseBody = nullptr; mSynthesizedInput = nullptr; @@ -381,6 +380,8 @@ InterceptedChannelContent::FinishSynthesizedResponse(const nsACString& aFinalURL return NS_ERROR_NOT_AVAILABLE; } + mReportCollector->FlushConsoleReports(mChannel); + EnsureSynthesizedResponse(); nsCOMPtr originalURI; @@ -420,6 +421,8 @@ InterceptedChannelContent::Cancel(nsresult aStatus) return NS_ERROR_FAILURE; } + mReportCollector->FlushConsoleReports(mChannel); + // we need to use AsyncAbort instead of Cancel since there's no active pump // to cancel which will provide OnStart/OnStopRequest to the channel. nsresult rv = mChannel->AsyncAbort(aStatus); diff --git a/netwerk/protocol/http/InterceptedChannel.h b/netwerk/protocol/http/InterceptedChannel.h index 229d56705741..f12b2e99d6f4 100644 --- a/netwerk/protocol/http/InterceptedChannel.h +++ b/netwerk/protocol/http/InterceptedChannel.h @@ -36,6 +36,8 @@ protected: // Response head for use when synthesizing Maybe> mSynthesizedResponseHead; + nsCOMPtr mReportCollector; + void EnsureSynthesizedResponse(); void DoNotifyController(); nsresult DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason); @@ -52,6 +54,7 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD GetResponseBody(nsIOutputStream** aOutput) override; + NS_IMETHOD GetConsoleReportCollector(nsIConsoleReportCollector** aCollectorOut) override; }; class InterceptedChannelChrome : public InterceptedChannelBase @@ -82,9 +85,6 @@ public: NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override; virtual void NotifyController() override; - - virtual nsIConsoleReportCollector* - GetConsoleReportCollector() const override; }; class InterceptedChannelContent : public InterceptedChannelBase @@ -113,9 +113,6 @@ public: NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override; virtual void NotifyController() override; - - virtual nsIConsoleReportCollector* - GetConsoleReportCollector() const override; }; } // namespace net