Merge mozilla-central to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2015-11-03 14:09:31 +01:00
commit 862b6d1dc3
11 changed files with 50 additions and 87 deletions

View File

@ -79,27 +79,6 @@ ConsoleReportCollector::FlushConsoleReports(nsIDocument* aDocument)
} }
} }
void
ConsoleReportCollector::FlushConsoleReports(nsIConsoleReportCollector* aCollector)
{
MOZ_ASSERT(aCollector);
nsTArray<PendingReport> reports;
{
MutexAutoLock lock(mMutex);
mPendingReports.SwapElements(reports);
}
for (uint32_t i = 0; i < reports.Length(); ++i) {
PendingReport& report = reports[i];
aCollector->AddConsoleReport(report.mErrorFlags, report.mCategory,
report.mPropertiesFile, report.mSourceFileURI,
report.mLineNumber, report.mColumnNumber,
report.mMessageName, report.mStringParams);
}
}
ConsoleReportCollector::~ConsoleReportCollector() ConsoleReportCollector::~ConsoleReportCollector()
{ {
} }

View File

@ -29,9 +29,6 @@ public:
void void
FlushConsoleReports(nsIDocument* aDocument) override; FlushConsoleReports(nsIDocument* aDocument) override;
void
FlushConsoleReports(nsIConsoleReportCollector* aCollector) override;
private: private:
~ConsoleReportCollector(); ~ConsoleReportCollector();

View File

@ -66,7 +66,7 @@ public:
aLineNumber, aColumnNumber, aMessageName, params); aLineNumber, aColumnNumber, aMessageName, params);
} }
// Flush all pending reports to the console. Main thread only. // Flush all pending reports to the console.
// //
// aDocument An optional document representing where to flush the // aDocument An optional document representing where to flush the
// reports. If provided, then the corresponding window's // reports. If provided, then the corresponding window's
@ -74,14 +74,6 @@ public:
// go to the browser console. // go to the browser console.
virtual void virtual void
FlushConsoleReports(nsIDocument* aDocument) = 0; FlushConsoleReports(nsIDocument* aDocument) = 0;
// Flush all pending reports to another collector. May be called from any
// thread.
//
// aCollector A required collector object that will effectively take
// ownership of our currently console reports.
virtual void
FlushConsoleReports(nsIConsoleReportCollector* aCollector) = 0;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsIConsoleReportCollector, NS_NSICONSOLEREPORTCOLLECTOR_IID) NS_DEFINE_STATIC_IID_ACCESSOR(nsIConsoleReportCollector, NS_NSICONSOLEREPORTCOLLECTOR_IID)

View File

@ -113,7 +113,10 @@ AsyncLog(nsIInterceptedChannel *aInterceptedChannel,
const nsACString& aMessageName, const nsTArray<nsString>& aParams) const nsACString& aMessageName, const nsTArray<nsString>& aParams)
{ {
MOZ_ASSERT(aInterceptedChannel); MOZ_ASSERT(aInterceptedChannel);
nsCOMPtr<nsIConsoleReportCollector> reporter = // 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(); aInterceptedChannel->GetConsoleReportCollector();
if (reporter) { if (reporter) {
reporter->AddConsoleReport(nsIScriptError::errorFlag, reporter->AddConsoleReport(nsIScriptError::errorFlag,

View File

@ -123,12 +123,6 @@ InterceptedJARChannel::SetChannelInfo(mozilla::dom::ChannelInfo* aChannelInfo)
return aChannelInfo->ResurrectInfoOnChannel(mChannel); return aChannelInfo->ResurrectInfoOnChannel(mChannel);
} }
NS_IMETHODIMP
InterceptedJARChannel::GetConsoleReportCollector(nsIConsoleReportCollector**)
{
return NS_ERROR_NOT_AVAILABLE;
}
void void
InterceptedJARChannel::NotifyController() InterceptedJARChannel::NotifyController()
{ {
@ -152,3 +146,9 @@ InterceptedJARChannel::NotifyController()
} }
mController = nullptr; mController = nullptr;
} }
nsIConsoleReportCollector*
InterceptedJARChannel::GetConsoleReportCollector() const
{
return nullptr;
}

View File

@ -53,6 +53,9 @@ public:
NS_DECL_NSIINTERCEPTEDCHANNEL NS_DECL_NSIINTERCEPTEDCHANNEL
void NotifyController(); void NotifyController();
virtual nsIConsoleReportCollector*
GetConsoleReportCollector() const override;
}; };
} // namespace net } // namespace net

View File

@ -7,7 +7,6 @@
#include "nsIContentPolicyBase.idl" #include "nsIContentPolicyBase.idl"
interface nsIChannel; interface nsIChannel;
interface nsIConsoleReportCollector;
interface nsIOutputStream; interface nsIOutputStream;
interface nsIURI; interface nsIURI;
@ -29,7 +28,7 @@ class ChannelInfo;
* which do not implement nsIChannel. * which do not implement nsIChannel.
*/ */
[scriptable, uuid(231bb567-90e1-4973-9728-7dab93ab29a8)] [scriptable, uuid(ea78e439-cc42-4b2d-a42b-85ab55a149d1)]
interface nsIInterceptedChannel : nsISupports interface nsIInterceptedChannel : nsISupports
{ {
/** /**
@ -88,17 +87,16 @@ interface nsIInterceptedChannel : nsISupports
[noscript] [noscript]
readonly attribute nsContentPolicyType internalContentPolicyType; readonly attribute nsContentPolicyType internalContentPolicyType;
[noscript]
readonly attribute nsIConsoleReportCollector consoleReportCollector;
%{C++ %{C++
already_AddRefed<nsIConsoleReportCollector> // Allow access to the inner channel as a ConsoleReportCollector off
GetConsoleReportCollector() // the main thread. Pure C++ method here to avoid requiring an
{ // AddRef() during QI. Callers should not save the returned pointer.
nsCOMPtr<nsIConsoleReportCollector> reporter; // May return nullptr.
GetConsoleReportCollector(getter_AddRefs(reporter)); //
return reporter.forget(); // Note: Only safe to use OMT prior to resetInterception(),
} // finishSynthesizedResponse(), and cancel().
virtual nsIConsoleReportCollector*
GetConsoleReportCollector() const = 0;
%} %}
}; };

View File

@ -2357,12 +2357,6 @@ HttpBaseChannel::FlushConsoleReports(nsIDocument* aDocument)
mReportCollector->FlushConsoleReports(aDocument); mReportCollector->FlushConsoleReports(aDocument);
} }
void
HttpBaseChannel::FlushConsoleReports(nsIConsoleReportCollector* aCollector)
{
mReportCollector->FlushConsoleReports(aCollector);
}
nsIPrincipal * nsIPrincipal *
HttpBaseChannel::GetURIPrincipal() HttpBaseChannel::GetURIPrincipal()
{ {

View File

@ -247,9 +247,6 @@ public:
void void
FlushConsoleReports(nsIDocument* aDocument) override; FlushConsoleReports(nsIDocument* aDocument) override;
void
FlushConsoleReports(nsIConsoleReportCollector* aCollector) override;
class nsContentEncodings : public nsIUTF8StringEnumerator class nsContentEncodings : public nsIUTF8StringEnumerator
{ {
public: public:

View File

@ -13,7 +13,6 @@
#include "nsHttpChannel.h" #include "nsHttpChannel.h"
#include "HttpChannelChild.h" #include "HttpChannelChild.h"
#include "nsHttpResponseHead.h" #include "nsHttpResponseHead.h"
#include "mozilla/ConsoleReportCollector.h"
#include "mozilla/dom/ChannelInfo.h" #include "mozilla/dom/ChannelInfo.h"
namespace mozilla { namespace mozilla {
@ -38,7 +37,6 @@ NS_IMPL_ISUPPORTS(InterceptedChannelBase, nsIInterceptedChannel)
InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController) InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController)
: mController(aController) : mController(aController)
, mReportCollector(new ConsoleReportCollector())
{ {
} }
@ -109,15 +107,6 @@ InterceptedChannelBase::DoSynthesizeHeader(const nsACString& aName, const nsACSt
return NS_OK; 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, InterceptedChannelChrome::InterceptedChannelChrome(nsHttpChannel* aChannel,
nsINetworkInterceptController* aController, nsINetworkInterceptController* aController,
nsICacheEntry* aEntry) nsICacheEntry* aEntry)
@ -145,6 +134,16 @@ InterceptedChannelChrome::NotifyController()
DoNotifyController(); 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 NS_IMETHODIMP
InterceptedChannelChrome::GetChannel(nsIChannel** aChannel) InterceptedChannelChrome::GetChannel(nsIChannel** aChannel)
{ {
@ -159,8 +158,6 @@ InterceptedChannelChrome::ResetInterception()
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
mReportCollector->FlushConsoleReports(mChannel);
mSynthesizedCacheEntry->AsyncDoom(nullptr); mSynthesizedCacheEntry->AsyncDoom(nullptr);
mSynthesizedCacheEntry = nullptr; mSynthesizedCacheEntry = nullptr;
@ -203,8 +200,6 @@ InterceptedChannelChrome::FinishSynthesizedResponse(const nsACString& aFinalURLS
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
mReportCollector->FlushConsoleReports(mChannel);
EnsureSynthesizedResponse(); EnsureSynthesizedResponse();
// If the synthesized response is a redirect, then we want to respect // If the synthesized response is a redirect, then we want to respect
@ -278,8 +273,6 @@ InterceptedChannelChrome::Cancel(nsresult aStatus)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
mReportCollector->FlushConsoleReports(mChannel);
// we need to use AsyncAbort instead of Cancel since there's no active pump // we need to use AsyncAbort instead of Cancel since there's no active pump
// to cancel which will provide OnStart/OnStopRequest to the channel. // to cancel which will provide OnStart/OnStopRequest to the channel.
nsresult rv = mChannel->AsyncAbort(aStatus); nsresult rv = mChannel->AsyncAbort(aStatus);
@ -329,6 +322,16 @@ InterceptedChannelContent::NotifyController()
DoNotifyController(); 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 NS_IMETHODIMP
InterceptedChannelContent::GetChannel(nsIChannel** aChannel) InterceptedChannelContent::GetChannel(nsIChannel** aChannel)
{ {
@ -343,8 +346,6 @@ InterceptedChannelContent::ResetInterception()
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
mReportCollector->FlushConsoleReports(mChannel);
mResponseBody = nullptr; mResponseBody = nullptr;
mSynthesizedInput = nullptr; mSynthesizedInput = nullptr;
@ -380,8 +381,6 @@ InterceptedChannelContent::FinishSynthesizedResponse(const nsACString& aFinalURL
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
mReportCollector->FlushConsoleReports(mChannel);
EnsureSynthesizedResponse(); EnsureSynthesizedResponse();
nsCOMPtr<nsIURI> originalURI; nsCOMPtr<nsIURI> originalURI;
@ -421,8 +420,6 @@ InterceptedChannelContent::Cancel(nsresult aStatus)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
mReportCollector->FlushConsoleReports(mChannel);
// we need to use AsyncAbort instead of Cancel since there's no active pump // we need to use AsyncAbort instead of Cancel since there's no active pump
// to cancel which will provide OnStart/OnStopRequest to the channel. // to cancel which will provide OnStart/OnStopRequest to the channel.
nsresult rv = mChannel->AsyncAbort(aStatus); nsresult rv = mChannel->AsyncAbort(aStatus);

View File

@ -36,8 +36,6 @@ protected:
// Response head for use when synthesizing // Response head for use when synthesizing
Maybe<nsAutoPtr<nsHttpResponseHead>> mSynthesizedResponseHead; Maybe<nsAutoPtr<nsHttpResponseHead>> mSynthesizedResponseHead;
nsCOMPtr<nsIConsoleReportCollector> mReportCollector;
void EnsureSynthesizedResponse(); void EnsureSynthesizedResponse();
void DoNotifyController(); void DoNotifyController();
nsresult DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason); nsresult DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason);
@ -54,7 +52,6 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD GetResponseBody(nsIOutputStream** aOutput) override; NS_IMETHOD GetResponseBody(nsIOutputStream** aOutput) override;
NS_IMETHOD GetConsoleReportCollector(nsIConsoleReportCollector** aCollectorOut) override;
}; };
class InterceptedChannelChrome : public InterceptedChannelBase class InterceptedChannelChrome : public InterceptedChannelBase
@ -85,6 +82,9 @@ public:
NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override; NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override;
virtual void NotifyController() override; virtual void NotifyController() override;
virtual nsIConsoleReportCollector*
GetConsoleReportCollector() const override;
}; };
class InterceptedChannelContent : public InterceptedChannelBase class InterceptedChannelContent : public InterceptedChannelBase
@ -113,6 +113,9 @@ public:
NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override; NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override;
virtual void NotifyController() override; virtual void NotifyController() override;
virtual nsIConsoleReportCollector*
GetConsoleReportCollector() const override;
}; };
} // namespace net } // namespace net