tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 70238397ad9d0d7543f547312b7590312146b142
parent ad59af6512c1fdbc7a6c26ff993ed4ffaa03b05e
Author: Tom Schuster <tschuster@mozilla.com>
Date:   Mon, 17 Nov 2025 11:19:42 +0000

Bug 1985987 - Get a process for remote image decoding. r=nika

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

Diffstat:
Mimage/remote/RemoteImageProtocolHandler.cpp | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/image/remote/RemoteImageProtocolHandler.cpp b/image/remote/RemoteImageProtocolHandler.cpp @@ -9,10 +9,14 @@ #include "nsNetUtil.h" #include "nsURLHelper.h" #include "mozilla/dom/ipc/IdType.h" +#include "mozilla/dom/ContentProcessManager.h" namespace mozilla::image { +using mozilla::dom::ContentParent; using mozilla::dom::ContentParentId; +using mozilla::dom::ContentProcessManager; +using mozilla::dom::UniqueContentParentKeepAlive; StaticRefPtr<RemoteImageProtocolHandler> RemoteImageProtocolHandler::sSingleton; @@ -30,6 +34,25 @@ NS_IMETHODIMP RemoteImageProtocolHandler::AllowPort(int32_t, const char*, return NS_OK; } +static UniqueContentParentKeepAlive GetLaunchingContentParentForDecode( + const Maybe<ContentParentId>& aContentParentId) { + if (aContentParentId.isSome()) { + if (ContentProcessManager* cpm = ContentProcessManager::GetSingleton()) { + if (ContentParent* cp = cpm->GetContentProcessById(*aContentParentId)) { + return cp->TryAddKeepAlive(/* aBrowserId */ 0); + } + } + } + + // We use the extension process as a fallback, because + // it is usually running, and should be OK to parse images. + return ContentParent::GetNewOrUsedLaunchingBrowserProcess( + EXTENSION_REMOTE_TYPE, + /* aGroup */ nullptr, + /* aPriority */ hal::PROCESS_PRIORITY_FOREGROUND, + /* aPreferUsed */ true); +} + // Parse out the relevant parts of the moz-remote-image URL static nsresult ParseURI(nsIURI* aURI, nsIURI** aRemoteURI, ImageIntSize* aSize, Maybe<ContentParentId>& aContentParentId) {