зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1389303 - [1.3] Call OnStart/OnStop callbacks on successful URI load in the external protocol channel. r=mcmanus
This commit is contained in:
Родитель
b1e9bcda7b
Коммит
456f394895
|
@ -71,6 +71,7 @@ private:
|
|||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsILoadInfo> mLoadInfo;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsExtProtocolChannel)
|
||||
|
@ -175,16 +176,23 @@ nsresult nsExtProtocolChannel::OpenURL()
|
|||
}
|
||||
|
||||
rv = extProtService->LoadURI(mUrl, aggCallbacks);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// despite success, we need to abort this channel, at the very least
|
||||
// to make it clear to the caller that no on{Start,Stop}Request
|
||||
// should be expected.
|
||||
rv = NS_ERROR_NO_CONTENT;
|
||||
|
||||
if (NS_SUCCEEDED(rv) && mListener) {
|
||||
RefPtr<nsExtProtocolChannel> self = this;
|
||||
nsCOMPtr<nsIStreamListener> listener = mListener;
|
||||
MessageLoop::current()->PostTask(
|
||||
NS_NewRunnableFunction(
|
||||
"nsExtProtocolChannel::OpenURL",
|
||||
[self, listener]() {
|
||||
listener->OnStartRequest(self, nullptr);
|
||||
listener->OnStopRequest(self, nullptr, self->mStatus);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
finish:
|
||||
mCallbacks = nullptr;
|
||||
mListener = nullptr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -218,6 +226,7 @@ NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen(nsIStreamListener *listener, nsISu
|
|||
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
|
||||
|
||||
mWasOpened = true;
|
||||
mListener = listener;
|
||||
|
||||
return OpenURL();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче