Merge mozilla-central to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2015-11-03 14:09:31 +01:00
commit 923b9735f2
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()
{
}

View File

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

View File

@ -66,7 +66,7 @@ public:
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
// reports. If provided, then the corresponding window's
@ -74,14 +74,6 @@ public:
// go to the browser console.
virtual void
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)

View File

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

View File

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

View File

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

View File

@ -7,7 +7,6 @@
#include "nsIContentPolicyBase.idl"
interface nsIChannel;
interface nsIConsoleReportCollector;
interface nsIOutputStream;
interface nsIURI;
@ -29,7 +28,7 @@ class ChannelInfo;
* which do not implement nsIChannel.
*/
[scriptable, uuid(231bb567-90e1-4973-9728-7dab93ab29a8)]
[scriptable, uuid(ea78e439-cc42-4b2d-a42b-85ab55a149d1)]
interface nsIInterceptedChannel : nsISupports
{
/**
@ -88,17 +87,16 @@ interface nsIInterceptedChannel : nsISupports
[noscript]
readonly attribute nsContentPolicyType internalContentPolicyType;
[noscript]
readonly attribute nsIConsoleReportCollector consoleReportCollector;
%{C++
already_AddRefed<nsIConsoleReportCollector>
GetConsoleReportCollector()
{
nsCOMPtr<nsIConsoleReportCollector> reporter;
GetConsoleReportCollector(getter_AddRefs(reporter));
return reporter.forget();
}
// 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;
%}
};

View File

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

View File

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

View File

@ -13,7 +13,6 @@
#include "nsHttpChannel.h"
#include "HttpChannelChild.h"
#include "nsHttpResponseHead.h"
#include "mozilla/ConsoleReportCollector.h"
#include "mozilla/dom/ChannelInfo.h"
namespace mozilla {
@ -38,7 +37,6 @@ NS_IMPL_ISUPPORTS(InterceptedChannelBase, nsIInterceptedChannel)
InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController)
: mController(aController)
, mReportCollector(new ConsoleReportCollector())
{
}
@ -109,15 +107,6 @@ 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)
@ -145,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)
{
@ -159,8 +158,6 @@ InterceptedChannelChrome::ResetInterception()
return NS_ERROR_NOT_AVAILABLE;
}
mReportCollector->FlushConsoleReports(mChannel);
mSynthesizedCacheEntry->AsyncDoom(nullptr);
mSynthesizedCacheEntry = nullptr;
@ -203,8 +200,6 @@ 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
@ -278,8 +273,6 @@ 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);
@ -329,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)
{
@ -343,8 +346,6 @@ InterceptedChannelContent::ResetInterception()
return NS_ERROR_NOT_AVAILABLE;
}
mReportCollector->FlushConsoleReports(mChannel);
mResponseBody = nullptr;
mSynthesizedInput = nullptr;
@ -380,8 +381,6 @@ InterceptedChannelContent::FinishSynthesizedResponse(const nsACString& aFinalURL
return NS_ERROR_NOT_AVAILABLE;
}
mReportCollector->FlushConsoleReports(mChannel);
EnsureSynthesizedResponse();
nsCOMPtr<nsIURI> originalURI;
@ -421,8 +420,6 @@ 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);

View File

@ -36,8 +36,6 @@ 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);
@ -54,7 +52,6 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetResponseBody(nsIOutputStream** aOutput) override;
NS_IMETHOD GetConsoleReportCollector(nsIConsoleReportCollector** aCollectorOut) override;
};
class InterceptedChannelChrome : public InterceptedChannelBase
@ -85,6 +82,9 @@ public:
NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override;
virtual void NotifyController() override;
virtual nsIConsoleReportCollector*
GetConsoleReportCollector() const override;
};
class InterceptedChannelContent : public InterceptedChannelBase
@ -113,6 +113,9 @@ public:
NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override;
virtual void NotifyController() override;
virtual nsIConsoleReportCollector*
GetConsoleReportCollector() const override;
};
} // namespace net