mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1220007 P2 Make InterceptedChannel's collect logs locally and only flush to nsIChannel on main thread r=bz
This commit is contained in:
parent
fc4396e3a7
commit
6ce99caa07
2
CLOBBER
2
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
|
||||
|
@ -113,10 +113,7 @@ AsyncLog(nsIInterceptedChannel *aInterceptedChannel,
|
||||
const nsACString& aMessageName, const nsTArray<nsString>& 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<nsIConsoleReportCollector> reporter =
|
||||
aInterceptedChannel->GetConsoleReportCollector();
|
||||
if (reporter) {
|
||||
reporter->AddConsoleReport(nsIScriptError::errorFlag,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -53,9 +53,6 @@ public:
|
||||
NS_DECL_NSIINTERCEPTEDCHANNEL
|
||||
|
||||
void NotifyController();
|
||||
|
||||
virtual nsIConsoleReportCollector*
|
||||
GetConsoleReportCollector() const override;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
@ -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<nsIConsoleReportCollector>
|
||||
GetConsoleReportCollector()
|
||||
{
|
||||
nsCOMPtr<nsIConsoleReportCollector> reporter;
|
||||
GetConsoleReportCollector(getter_AddRefs(reporter));
|
||||
return reporter.forget();
|
||||
}
|
||||
%}
|
||||
};
|
||||
|
||||
|
@ -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<nsIConsoleReportCollector> 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<nsIURI> 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);
|
||||
|
@ -36,6 +36,8 @@ protected:
|
||||
// Response head for use when synthesizing
|
||||
Maybe<nsAutoPtr<nsHttpResponseHead>> mSynthesizedResponseHead;
|
||||
|
||||
nsCOMPtr<nsIConsoleReportCollector> 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
|
||||
|
Loading…
Reference in New Issue
Block a user