Bug 1544526 - Copy the callback instead of moving r=mayhemer

Differential Revision: https://phabricator.services.mozilla.com/D27894

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kershaw Chang 2019-04-26 18:33:28 +00:00
Родитель a6845a59a2
Коммит 351a470dad
4 изменённых файлов: 21 добавлений и 10 удалений

Просмотреть файл

@ -980,8 +980,9 @@ mozilla::ipc::IPCResult NeckoParent::RecvEnsureHSTSData(
auto callback = [aResolver{std::move(aResolver)}](bool aResult) {
aResolver(aResult);
};
gHttpHandler->EnsureHSTSDataReadyNative(
new HSTSDataCallbackWrapper(std::move(callback)));
RefPtr<HSTSDataCallbackWrapper> wrapper =
new HSTSDataCallbackWrapper(std::move(callback));
gHttpHandler->EnsureHSTSDataReadyNative(wrapper.forget());
return IPC_OK();
}

Просмотреть файл

@ -2601,10 +2601,9 @@ nsHttpsHandler::AllowPort(int32_t aPort, const char *aScheme, bool *_retval) {
return NS_OK;
}
NS_IMETHODIMP
nsHttpHandler::EnsureHSTSDataReadyNative(HSTSDataCallbackWrapper *aCallback) {
nsresult nsHttpHandler::EnsureHSTSDataReadyNative(
already_AddRefed<mozilla::net::HSTSDataCallbackWrapper> aCallback) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aCallback);
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), "http://example.com");
@ -2614,14 +2613,14 @@ nsHttpHandler::EnsureHSTSDataReadyNative(HSTSDataCallbackWrapper *aCallback) {
bool willCallback = false;
OriginAttributes originAttributes;
RefPtr<HSTSDataCallbackWrapper> callback = aCallback;
auto func = [callback{std::move(callback)}](bool aResult, nsresult aStatus) {
auto func = [callback](bool aResult, nsresult aStatus) {
callback->DoCallback(aResult);
};
rv = NS_ShouldSecureUpgrade(uri, nullptr, nullptr, false, false,
originAttributes, shouldUpgrade, std::move(func),
willCallback);
if (NS_FAILED(rv) || !willCallback) {
aCallback->DoCallback(false);
callback->DoCallback(false);
return rv;
}
@ -2667,7 +2666,7 @@ nsHttpHandler::EnsureHSTSDataReady(JSContext *aCx, Promise **aPromise) {
RefPtr<HSTSDataCallbackWrapper> wrapper =
new HSTSDataCallbackWrapper(std::move(callback));
promise.forget(aPromise);
return EnsureHSTSDataReadyNative(wrapper);
return EnsureHSTSDataReadyNative(wrapper.forget());
}
void nsHttpHandler::ShutdownConnectionManager() {

Просмотреть файл

@ -742,6 +742,10 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
void BlacklistSpdy(const nsHttpConnectionInfo *ci);
MOZ_MUST_USE bool IsSpdyBlacklisted(const nsHttpConnectionInfo *ci);
virtual nsresult EnsureHSTSDataReadyNative(
already_AddRefed<mozilla::net::HSTSDataCallbackWrapper> aCallback)
override;
private:
nsTHashtable<nsCStringHashKey> mBlacklistedSpdyOrigins;
@ -773,6 +777,11 @@ class nsHttpsHandler : public nsIHttpProtocolHandler,
nsHttpsHandler() = default;
MOZ_MUST_USE nsresult Init();
virtual nsresult EnsureHSTSDataReadyNative(
already_AddRefed<mozilla::net::HSTSDataCallbackWrapper> aCallback)
override {
return gHttpHandler->EnsureHSTSDataReadyNative(std::move(aCallback));
}
};
//-----------------------------------------------------------------------------

Просмотреть файл

@ -68,8 +68,10 @@ interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler
/**
* A C++ friendly version of EnsureHSTSDataReady
*/
[noscript]
void EnsureHSTSDataReadyNative(in HSTSDataCallbackWrapperPtr aCallback);
%{C++
virtual nsresult EnsureHSTSDataReadyNative(
already_AddRefed<mozilla::net::HSTSDataCallbackWrapper> aCallback) = 0;
%}
};
%{C++