зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1605072 - Make CanonicalBrowsingContext::ChangeFrameRemoteness use async process launching;r=kmag,nika
Differential Revision: https://phabricator.services.mozilla.com/D57775 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f4fcc09d90
Коммит
c1bdaea3f3
|
@ -253,26 +253,6 @@ void CanonicalBrowsingContext::LoadURI(const nsAString& aURI,
|
||||||
LoadURI(nullptr, loadState, true);
|
LoadURI(nullptr, loadState, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
using NewOrUsedPromise = MozPromise<RefPtr<ContentParent>, nsresult, false>;
|
|
||||||
|
|
||||||
// NOTE: This method is currently a dummy, and always actually spawns sync. It
|
|
||||||
// mostly exists so I can test out the async API right now.
|
|
||||||
RefPtr<NewOrUsedPromise> GetNewOrUsedBrowserProcessAsync(
|
|
||||||
const nsAString& aRemoteType) {
|
|
||||||
RefPtr<ContentParent> contentParent =
|
|
||||||
ContentParent::GetNewOrUsedBrowserProcess(
|
|
||||||
nullptr, aRemoteType, hal::PROCESS_PRIORITY_FOREGROUND, nullptr,
|
|
||||||
false);
|
|
||||||
if (!contentParent) {
|
|
||||||
return NewOrUsedPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
|
|
||||||
}
|
|
||||||
return NewOrUsedPromise::CreateAndResolve(contentParent, __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
void CanonicalBrowsingContext::PendingRemotenessChange::Complete(
|
void CanonicalBrowsingContext::PendingRemotenessChange::Complete(
|
||||||
ContentParent* aContentParent) {
|
ContentParent* aContentParent) {
|
||||||
if (!mPromise) {
|
if (!mPromise) {
|
||||||
|
@ -484,14 +464,19 @@ CanonicalBrowsingContext::ChangeFrameRemoteness(const nsAString& aRemoteType,
|
||||||
new PendingRemotenessChange(this, promise, aPendingSwitchId);
|
new PendingRemotenessChange(this, promise, aPendingSwitchId);
|
||||||
mPendingRemotenessChange = change;
|
mPendingRemotenessChange = change;
|
||||||
|
|
||||||
GetNewOrUsedBrowserProcessAsync(aRemoteType)
|
ContentParent::GetNewOrUsedBrowserProcessAsync(
|
||||||
|
/* aFrameElement = */ nullptr,
|
||||||
|
/* aRemoteType = */ aRemoteType,
|
||||||
|
/* aPriority = */ hal::PROCESS_PRIORITY_FOREGROUND,
|
||||||
|
/* aOpener = */ nullptr,
|
||||||
|
/* aPreferUsed = */ false)
|
||||||
->Then(
|
->Then(
|
||||||
GetMainThreadSerialEventTarget(), __func__,
|
GetMainThreadSerialEventTarget(), __func__,
|
||||||
[change](ContentParent* aContentParent) {
|
[change](ContentParent* aContentParent) {
|
||||||
change->Complete(aContentParent);
|
change->Complete(aContentParent);
|
||||||
},
|
},
|
||||||
[change](nsresult aRv) { change->Cancel(aRv); });
|
[change](LaunchError aError) { change->Cancel(NS_ERROR_FAILURE); });
|
||||||
return promise;
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Promise> CanonicalBrowsingContext::ChangeFrameRemoteness(
|
already_AddRefed<Promise> CanonicalBrowsingContext::ChangeFrameRemoteness(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче