Bug 1236686 - Remove nsIFetchEventDispatcher; r=jdm

This commit is contained in:
Ehsan Akhgari
2016-01-04 17:40:04 -05:00
parent d737c8fd8d
commit 6e8b3ac548
8 changed files with 34 additions and 178 deletions

View File

@@ -14181,55 +14181,8 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceReques
return NS_OK;
}
namespace {
class FetchEventDispatcher final : public nsIFetchEventDispatcher
{
public:
FetchEventDispatcher(nsIInterceptedChannel* aChannel,
nsIRunnable* aContinueRunnable)
: mChannel(aChannel)
, mContinueRunnable(aContinueRunnable)
{
}
NS_DECL_ISUPPORTS
NS_DECL_NSIFETCHEVENTDISPATCHER
private:
~FetchEventDispatcher()
{
}
nsCOMPtr<nsIInterceptedChannel> mChannel;
nsCOMPtr<nsIRunnable> mContinueRunnable;
};
NS_IMPL_ISUPPORTS(FetchEventDispatcher, nsIFetchEventDispatcher)
NS_IMETHODIMP
FetchEventDispatcher::Dispatch()
{
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (!swm) {
mChannel->Cancel(NS_ERROR_INTERCEPTION_FAILED);
return NS_OK;
}
ErrorResult error;
swm->DispatchPreparedFetchEvent(mChannel, mContinueRunnable, error);
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
}
return NS_OK;
}
}
NS_IMETHODIMP
nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel,
nsIFetchEventDispatcher** aFetchDispatcher)
nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel)
{
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (!swm) {
@@ -14266,18 +14219,12 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel,
attrs.InheritFromDocShellToDoc(GetOriginAttributes(), uri);
ErrorResult error;
nsCOMPtr<nsIRunnable> runnable =
swm->PrepareFetchEvent(attrs, doc, mInterceptedDocumentId, aChannel,
isReload, isSubresourceLoad, error);
swm->DispatchFetchEvent(attrs, doc, mInterceptedDocumentId, aChannel,
isReload, isSubresourceLoad, error);
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
}
MOZ_ASSERT(runnable);
RefPtr<FetchEventDispatcher> dispatcher =
new FetchEventDispatcher(aChannel, runnable);
dispatcher.forget(aFetchDispatcher);
return NS_OK;
}