summaryrefslogtreecommitdiffstats
path: root/ipc/glue
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /ipc/glue
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ipc/glue')
-rw-r--r--ipc/glue/BackgroundUtils.cpp2
-rw-r--r--ipc/glue/ExtensionKitUtils.h80
-rw-r--r--ipc/glue/ExtensionKitUtils.mm129
-rw-r--r--ipc/glue/GeckoChildProcessHost.cpp202
-rw-r--r--ipc/glue/GeckoChildProcessHost.h12
-rw-r--r--ipc/glue/NodeChannel.cpp2
-rw-r--r--ipc/glue/NodeChannel.h2
-rw-r--r--ipc/glue/NodeController.cpp4
-rw-r--r--ipc/glue/PBackgroundSharedTypes.ipdlh2
-rw-r--r--ipc/glue/ProcessUtils.h4
-rw-r--r--ipc/glue/ProcessUtils_common.cpp10
-rw-r--r--ipc/glue/ProtocolUtils.h10
-rw-r--r--ipc/glue/UtilityAudioDecoderChild.cpp2
-rw-r--r--ipc/glue/moz.build12
14 files changed, 427 insertions, 46 deletions
diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp
index 435e29f635..eb1e46fb42 100644
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -249,7 +249,7 @@ nsresult CSPToCSPInfo(nsIContentSecurityPolicy* aCSP, CSPInfo* aCSPInfo) {
selfURI->GetSpec(selfURISpec);
}
- nsAutoString referrer;
+ nsAutoCString referrer;
aCSP->GetReferrer(referrer);
uint64_t windowID = aCSP->GetInnerWindowID();
diff --git a/ipc/glue/ExtensionKitUtils.h b/ipc/glue/ExtensionKitUtils.h
new file mode 100644
index 0000000000..88ee5ac0f9
--- /dev/null
+++ b/ipc/glue/ExtensionKitUtils.h
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_ipc_ExtensionKitUtils_h
+#define mozilla_ipc_ExtensionKitUtils_h
+
+#include <functional>
+#include <xpc/xpc.h>
+#include "mozilla/DarwinObjectPtr.h"
+#include "mozilla/Result.h"
+#include "mozilla/ResultVariant.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/ipc/LaunchError.h"
+
+namespace mozilla::ipc {
+
+class BEProcessCapabilityGrantDeleter {
+ public:
+ void operator()(void* aGrant) const;
+};
+
+using UniqueBEProcessCapabilityGrant =
+ mozilla::UniquePtr<void, BEProcessCapabilityGrantDeleter>;
+
+class ExtensionKitProcess {
+ public:
+ enum class Kind {
+ WebContent,
+ Networking,
+ Rendering,
+ };
+
+ // Called to start the process. The `aCompletion` function may be executed on
+ // a background libdispatch thread.
+ static void StartProcess(
+ Kind aKind,
+ const std::function<void(Result<ExtensionKitProcess, LaunchError>&&)>&
+ aCompletion);
+
+ // Get the kind of process being started.
+ Kind GetKind() const { return mKind; }
+
+ // Make an xpc_connection_t to this process. If an error is encountered,
+ // `aError` will be populated with the error.
+ //
+ // Ownership over the newly created connection is returned to the caller.
+ // The connection is returned in a suspended state, and must be resumed.
+ DarwinObjectPtr<xpc_connection_t> MakeLibXPCConnection();
+
+ UniqueBEProcessCapabilityGrant GrantForegroundCapability();
+
+ // Invalidate the process, indicating that it should be cleaned up &
+ // destroyed.
+ void Invalidate();
+
+ // Explicit copy constructors
+ ExtensionKitProcess(const ExtensionKitProcess&);
+ ExtensionKitProcess& operator=(const ExtensionKitProcess&);
+
+ // Release the object when completed.
+ ~ExtensionKitProcess();
+
+ private:
+ ExtensionKitProcess(Kind aKind, void* aProcessObject)
+ : mKind(aKind), mProcessObject(aProcessObject) {}
+
+ // Type tag for `mProcessObject`.
+ Kind mKind;
+
+ // This is one of `BEWebContentProcess`, `BENetworkingProcess` or
+ // `BERenderingProcess`. It has been type erased to be usable from C++ code.
+ void* mProcessObject;
+};
+
+} // namespace mozilla::ipc
+
+#endif // mozilla_ipc_ExtensionKitUtils_h
diff --git a/ipc/glue/ExtensionKitUtils.mm b/ipc/glue/ExtensionKitUtils.mm
new file mode 100644
index 0000000000..9a42251b38
--- /dev/null
+++ b/ipc/glue/ExtensionKitUtils.mm
@@ -0,0 +1,129 @@
+/* -*- Mode: c++; c-basic-offset: 2; tab-width: 4; indent-tabs-mode: nil; -*-
+ * vim: set sw=2 ts=4 expandtab:
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "ExtensionKitUtils.h"
+#include "LaunchError.h"
+
+#import <BrowserEngineKit/BrowserEngineKit.h>
+
+namespace mozilla::ipc {
+
+void BEProcessCapabilityGrantDeleter::operator()(void* aGrant) const {
+ auto grant = static_cast<id<BEProcessCapabilityGrant>>(aGrant);
+ [grant invalidate];
+ [grant release];
+}
+
+void ExtensionKitProcess::StartProcess(
+ Kind aKind,
+ const std::function<void(Result<ExtensionKitProcess, LaunchError>&&)>&
+ aCompletion) {
+ auto callCompletion = [=](auto* aProcess, NSError* aError) {
+ if (aProcess) {
+ [aProcess retain];
+ aCompletion(ExtensionKitProcess(aKind, aProcess));
+ } else {
+ NSLog(@"Error launching process, description '%@', reason '%@'",
+ [aError localizedDescription], [aError localizedFailureReason]);
+ aCompletion(Err(LaunchError("ExtensionKitProcess::StartProcess")));
+ }
+ };
+
+ switch (aKind) {
+ case Kind::WebContent: {
+ [BEWebContentProcess
+ webContentProcessWithInterruptionHandler:^{
+ }
+ completion:^(BEWebContentProcess* process, NSError* error) {
+ callCompletion(process, error);
+ }];
+ return;
+ }
+ case Kind::Networking: {
+ [BENetworkingProcess
+ networkProcessWithInterruptionHandler:^{
+ }
+ completion:^(BENetworkingProcess* process, NSError* error) {
+ callCompletion(process, error);
+ }];
+ return;
+ }
+ case Kind::Rendering: {
+ [BERenderingProcess
+ renderingProcessWithInterruptionHandler:^{
+ }
+ completion:^(BERenderingProcess* process, NSError* error) {
+ callCompletion(process, error);
+ }];
+ return;
+ }
+ }
+}
+
+template <typename F>
+static void SwitchObject(ExtensionKitProcess::Kind aKind, void* aProcessObject,
+ F&& aMatcher) {
+ switch (aKind) {
+ case ExtensionKitProcess::Kind::WebContent:
+ aMatcher(static_cast<BEWebContentProcess*>(aProcessObject));
+ break;
+ case ExtensionKitProcess::Kind::Networking:
+ aMatcher(static_cast<BENetworkingProcess*>(aProcessObject));
+ break;
+ case ExtensionKitProcess::Kind::Rendering:
+ aMatcher(static_cast<BERenderingProcess*>(aProcessObject));
+ break;
+ }
+}
+
+DarwinObjectPtr<xpc_connection_t> ExtensionKitProcess::MakeLibXPCConnection() {
+ NSError* error = nullptr;
+ DarwinObjectPtr<xpc_connection_t> xpcConnection;
+ SwitchObject(mKind, mProcessObject, [&](auto* aProcessObject) {
+ xpcConnection = [aProcessObject makeLibXPCConnectionError:&error];
+ });
+ return xpcConnection;
+}
+
+void ExtensionKitProcess::Invalidate() {
+ SwitchObject(mKind, mProcessObject,
+ [&](auto* aProcessObject) { [aProcessObject invalidate]; });
+}
+
+UniqueBEProcessCapabilityGrant
+ExtensionKitProcess::GrantForegroundCapability() {
+ NSError* error = nullptr;
+ BEProcessCapability* cap = [BEProcessCapability foreground];
+ id<BEProcessCapabilityGrant> grant = nil;
+ SwitchObject(mKind, mProcessObject, [&](auto* aProcessObject) {
+ grant = [aProcessObject grantCapability:cap error:&error];
+ });
+ return UniqueBEProcessCapabilityGrant(grant ? [grant retain] : nil);
+}
+
+ExtensionKitProcess::ExtensionKitProcess(const ExtensionKitProcess& aOther)
+ : mKind(aOther.mKind), mProcessObject(aOther.mProcessObject) {
+ SwitchObject(mKind, mProcessObject,
+ [&](auto* aProcessObject) { [aProcessObject retain]; });
+}
+
+ExtensionKitProcess& ExtensionKitProcess::operator=(
+ const ExtensionKitProcess& aOther) {
+ Kind oldKind = std::exchange(mKind, aOther.mKind);
+ void* oldProcessObject = std::exchange(mProcessObject, aOther.mProcessObject);
+ SwitchObject(mKind, mProcessObject,
+ [&](auto* aProcessObject) { [aProcessObject retain]; });
+ SwitchObject(oldKind, oldProcessObject,
+ [&](auto* aProcessObject) { [aProcessObject release]; });
+ return *this;
+}
+
+ExtensionKitProcess::~ExtensionKitProcess() {
+ SwitchObject(mKind, mProcessObject,
+ [&](auto* aProcessObject) { [aProcessObject release]; });
+}
+
+} // namespace mozilla::ipc
diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp
index 3e444060bc..cb038911d4 100644
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -13,15 +13,16 @@
#include "base/task.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/process_watcher.h"
-#include "mozilla/ProcessType.h"
-#ifdef MOZ_WIDGET_COCOA
-# include <bsm/libbsm.h>
+#ifdef XP_DARWIN
# include <mach/mach_traps.h>
-# include <servers/bootstrap.h>
# include "SharedMemoryBasic.h"
# include "base/rand_util.h"
# include "chrome/common/mach_ipc_mac.h"
# include "mozilla/StaticPrefs_media.h"
+#endif
+#ifdef MOZ_WIDGET_COCOA
+# include <bsm/libbsm.h>
+# include <servers/bootstrap.h>
# include "nsILocalFileMac.h"
#endif
@@ -128,9 +129,14 @@ namespace ipc {
struct LaunchResults {
base::ProcessHandle mHandle = 0;
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
task_t mChildTask = MACH_PORT_NULL;
#endif
+#ifdef XP_IOS
+ Maybe<ExtensionKitProcess> mExtensionKitProcess;
+ DarwinObjectPtr<xpc_connection_t> mXPCConnection;
+ UniqueBEProcessCapabilityGrant mForegroundCapabilityGrant;
+#endif
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
RefPtr<AbstractSandboxBroker> mSandboxBroker;
#endif
@@ -354,9 +360,9 @@ class IosProcessLauncher : public PosixProcessLauncher {
: PosixProcessLauncher(aHost, std::move(aExtraOpts)) {}
protected:
- virtual RefPtr<ProcessHandlePromise> DoLaunch() override {
- MOZ_CRASH("IosProcessLauncher::DoLaunch not implemented");
- }
+ virtual RefPtr<ProcessHandlePromise> DoLaunch() override;
+
+ DarwinObjectPtr<xpc_object_t> mBootstrapMessage;
};
typedef IosProcessLauncher ProcessLauncher;
# else
@@ -390,7 +396,7 @@ GeckoChildProcessHost::GeckoChildProcessHost(GeckoProcessType aProcessType,
#endif
mHandleLock("mozilla.ipc.GeckoChildProcessHost.mHandleLock"),
mChildProcessHandle(0),
-#if defined(MOZ_WIDGET_COCOA)
+#if defined(XP_DARWIN)
mChildTask(MACH_PORT_NULL),
#endif
#if defined(MOZ_SANDBOX) && defined(XP_MACOSX)
@@ -443,11 +449,22 @@ GeckoChildProcessHost::~GeckoChildProcessHost()
{
mozilla::AutoWriteLock hLock(mHandleLock);
-#if defined(MOZ_WIDGET_COCOA)
+#if defined(XP_DARWIN)
if (mChildTask != MACH_PORT_NULL) {
mach_port_deallocate(mach_task_self(), mChildTask);
}
#endif
+#if defined(XP_IOS)
+ if (mForegroundCapabilityGrant) {
+ mForegroundCapabilityGrant.reset();
+ }
+ if (mExtensionKitProcess) {
+ mExtensionKitProcess->Invalidate();
+ }
+ if (mXPCConnection) {
+ xpc_connection_cancel(mXPCConnection.get());
+ }
+#endif
if (mChildProcessHandle != 0) {
ProcessWatcher::EnsureProcessTerminated(
@@ -483,7 +500,7 @@ base::ProcessId GeckoChildProcessHost::GetChildProcessId() {
return base::GetProcId(mChildProcessHandle);
}
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
task_t GeckoChildProcessHost::GetChildTask() {
mozilla::AutoReadLock handleLock(mHandleLock);
return mChildTask;
@@ -765,14 +782,20 @@ bool GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts) {
// "safe" invalid value to use in places like this.
aResults.mHandle = 0;
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
this->mChildTask = aResults.mChildTask;
#endif
+#ifdef XP_IOS
+ this->mExtensionKitProcess = aResults.mExtensionKitProcess;
+ this->mXPCConnection = aResults.mXPCConnection;
+ this->mForegroundCapabilityGrant =
+ std::move(aResults.mForegroundCapabilityGrant);
+#endif
if (mNodeChannel) {
mNodeChannel->SetOtherPid(
base::GetProcId(this->mChildProcessHandle));
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
mNodeChannel->SetMachTaskPort(this->mChildTask);
#endif
}
@@ -798,7 +821,8 @@ bool GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts) {
CHROMIUM_LOG(ERROR)
<< "Failed to launch "
<< XRE_GeckoProcessTypeToString(mProcessType)
- << " subprocess";
+ << " subprocess @" << aError.FunctionName()
+ << " (Error:" << aError.ErrorCode() << ")";
Telemetry::Accumulate(
Telemetry::SUBPROCESS_LAUNCH_FAILURE,
nsDependentCString(
@@ -1243,16 +1267,13 @@ Result<Ok, LaunchError> PosixProcessLauncher::DoSetup() {
// STDOUT_FILENO, for example
// The fork server doesn't use IPC::Channel, so can skip this step.
if (mProcessType != GeckoProcessType_ForkServer) {
-# ifdef MOZ_WIDGET_ANDROID
- // On Android mChannelDstFd is uninitialised and the launching code uses
- // only the first of each pair.
- mLaunchOptions->fds_to_remap.push_back(
- std::pair<int, int>(mClientChannelHandle.get(), -1));
-# else
+# if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_UIKIT)
+ // On Android/iOS, mChannelDstFd is initialised to -1 and the launching
+ // code uses only the first of each pair.
MOZ_ASSERT(mChannelDstFd >= 0);
+# endif
mLaunchOptions->fds_to_remap.push_back(
std::pair<int, int>(mClientChannelHandle.get(), mChannelDstFd));
-# endif
}
// no need for kProcessChannelID, the child process inherits the
@@ -1356,6 +1377,143 @@ RefPtr<ProcessHandlePromise> PosixProcessLauncher::DoLaunch() {
}
#endif // XP_UNIX
+#ifdef XP_IOS
+RefPtr<ProcessHandlePromise> IosProcessLauncher::DoLaunch() {
+ MOZ_RELEASE_ASSERT(mLaunchOptions->fds_to_remap.size() == 3,
+ "Unexpected fds_to_remap on iOS");
+
+ ExtensionKitProcess::Kind kind = ExtensionKitProcess::Kind::WebContent;
+ if (mProcessType == GeckoProcessType_GPU) {
+ kind = ExtensionKitProcess::Kind::Rendering;
+ } else if (mProcessType == GeckoProcessType_Socket) {
+ kind = ExtensionKitProcess::Kind::Networking;
+ }
+
+ DarwinObjectPtr<xpc_object_t> bootstrapMessage =
+ AdoptDarwinObject(xpc_dictionary_create_empty());
+ xpc_dictionary_set_string(bootstrapMessage.get(), "message-name",
+ "bootstrap");
+
+ DarwinObjectPtr<xpc_object_t> environDict =
+ AdoptDarwinObject(xpc_dictionary_create_empty());
+ for (auto& [envKey, envValue] : mLaunchOptions->env_map) {
+ xpc_dictionary_set_string(environDict.get(), envKey.c_str(),
+ envValue.c_str());
+ }
+ xpc_dictionary_set_value(bootstrapMessage.get(), "environ",
+ environDict.get());
+
+ // XXX: this processing depends entirely on the internals of
+ // ContentParent::LaunchSubprocess()
+ // GeckoChildProcessHost::PerformAsyncLaunch(), and the order in
+ // which they append to fds_to_remap. There must be a better way to do it.
+ // See bug 1440207.
+ int prefsFd = mLaunchOptions->fds_to_remap[0].first;
+ int prefMapFd = mLaunchOptions->fds_to_remap[1].first;
+ int ipcFd = mLaunchOptions->fds_to_remap[2].first;
+ xpc_dictionary_set_fd(bootstrapMessage.get(), "prefs", prefsFd);
+ xpc_dictionary_set_fd(bootstrapMessage.get(), "prefmap", prefMapFd);
+ xpc_dictionary_set_fd(bootstrapMessage.get(), "channel", ipcFd);
+
+ // Setup stdout and stderr to inherit.
+ xpc_dictionary_set_fd(bootstrapMessage.get(), "stdout", STDOUT_FILENO);
+ xpc_dictionary_set_fd(bootstrapMessage.get(), "stderr", STDERR_FILENO);
+
+ DarwinObjectPtr<xpc_object_t> argsArray =
+ AdoptDarwinObject(xpc_array_create_empty());
+ for (auto& argv : mChildArgv) {
+ xpc_array_set_string(argsArray.get(), XPC_ARRAY_APPEND, argv.c_str());
+ }
+ MOZ_ASSERT(xpc_array_get_count(argsArray.get()) == mChildArgv.size());
+ xpc_dictionary_set_value(bootstrapMessage.get(), "argv", argsArray.get());
+
+ auto promise = MakeRefPtr<ProcessHandlePromise::Private>(__func__);
+ ExtensionKitProcess::StartProcess(kind, [self = RefPtr{this}, promise,
+ bootstrapMessage =
+ std::move(bootstrapMessage)](
+ Result<ExtensionKitProcess,
+ LaunchError>&& result) {
+ if (result.isErr()) {
+ CHROMIUM_LOG(ERROR) << "ExtensionKitProcess::StartProcess failed";
+ promise->Reject(result.unwrapErr(), __func__);
+ return;
+ }
+
+ auto process = result.unwrap();
+ self->mResults.mForegroundCapabilityGrant =
+ process.GrantForegroundCapability();
+ self->mResults.mXPCConnection = process.MakeLibXPCConnection();
+ self->mResults.mExtensionKitProcess = Some(std::move(process));
+
+ // We don't actually use the event handler for anything other than
+ // watching for errors. Once the promise is resolved, this becomes a
+ // no-op.
+ xpc_connection_set_event_handler(self->mResults.mXPCConnection.get(), ^(
+ xpc_object_t event) {
+ if (!event || xpc_get_type(event) == XPC_TYPE_ERROR) {
+ CHROMIUM_LOG(WARNING) << "XPC connection received encountered an error";
+ promise->Reject(LaunchError("xpc_connection_event_handler"), __func__);
+ }
+ });
+ xpc_connection_resume(self->mResults.mXPCConnection.get());
+
+ // Send our bootstrap message to the content and wait for it to reply with
+ // the task port before resolving.
+ // FIXME: Should we have a time-out for if the child process doesn't respond
+ // in time? The main thread may be blocked while we're starting this
+ // process.
+ xpc_connection_send_message_with_reply(
+ self->mResults.mXPCConnection.get(), bootstrapMessage.get(), nullptr,
+ ^(xpc_object_t reply) {
+ if (xpc_get_type(reply) == XPC_TYPE_ERROR) {
+ CHROMIUM_LOG(ERROR)
+ << "Got error sending XPC bootstrap message to child";
+ promise->Reject(
+ LaunchError("xpc_connection_send_message_with_reply error"),
+ __func__);
+ return;
+ }
+
+ if (xpc_get_type(reply) != XPC_TYPE_DICTIONARY) {
+ CHROMIUM_LOG(ERROR)
+ << "Unexpected reply type for bootstrap message from child";
+ promise->Reject(
+ LaunchError(
+ "xpc_connection_send_message_with_reply non-dictionary"),
+ __func__);
+ return;
+ }
+
+ // FIXME: We have to trust the child to tell us its pid & mach task.
+ // WebKit uses `xpc_connection_get_pid` to get the pid, however this
+ // is marked as unavailable on iOS.
+ //
+ // Given how the process is started, however, validating this
+ // information it sends us this early during startup may be
+ // unnecessary.
+ self->mResults.mChildTask =
+ xpc_dictionary_copy_mach_send(reply, "task");
+ pid_t pid =
+ static_cast<pid_t>(xpc_dictionary_get_int64(reply, "pid"));
+ CHROMIUM_LOG(INFO) << "ExtensionKit process started, task: "
+ << self->mResults.mChildTask << ", pid: " << pid;
+
+ pid_t taskPid;
+ kern_return_t kr = pid_for_task(self->mResults.mChildTask, &taskPid);
+ if (kr != KERN_SUCCESS || pid != taskPid) {
+ CHROMIUM_LOG(ERROR) << "Could not validate child task matches pid";
+ promise->Reject(LaunchError("pid_for_task mismatch"), __func__);
+ return;
+ }
+
+ promise->Resolve(pid, __func__);
+ });
+ });
+
+ return promise;
+}
+#endif
+
#ifdef XP_MACOSX
Result<Ok, LaunchError> MacProcessLauncher::DoFinishLaunch() {
Result<Ok, LaunchError> aError = PosixProcessLauncher::DoFinishLaunch();
@@ -1647,7 +1805,7 @@ RefPtr<ProcessLaunchPromise> BaseProcessLauncher::FinishLaunch() {
Telemetry::AccumulateTimeDelta(Telemetry::CHILD_PROCESS_LAUNCH_MS,
mStartTimeStamp);
- return ProcessLaunchPromise::CreateAndResolve(mResults, __func__);
+ return ProcessLaunchPromise::CreateAndResolve(std::move(mResults), __func__);
}
bool GeckoChildProcessHost::OpenPrivilegedHandle(base::ProcessId aPid) {
diff --git a/ipc/glue/GeckoChildProcessHost.h b/ipc/glue/GeckoChildProcessHost.h
index 89ed399fea..61c986c5a2 100644
--- a/ipc/glue/GeckoChildProcessHost.h
+++ b/ipc/glue/GeckoChildProcessHost.h
@@ -33,6 +33,10 @@
#include "nsXULAppAPI.h" // for GeckoProcessType
#include "nsString.h"
+#if defined(XP_IOS)
+# include "mozilla/ipc/ExtensionKitUtils.h"
+#endif
+
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
# include "sandboxBroker.h"
#endif
@@ -151,7 +155,7 @@ class GeckoChildProcessHost : public SupportsWeakPtr,
GeckoProcessType GetProcessType() { return mProcessType; }
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
task_t GetChildTask();
#endif
@@ -266,6 +270,12 @@ class GeckoChildProcessHost : public SupportsWeakPtr,
#if defined(XP_DARWIN)
task_t mChildTask MOZ_GUARDED_BY(mHandleLock);
#endif
+#if defined(MOZ_WIDGET_UIKIT)
+ Maybe<ExtensionKitProcess> mExtensionKitProcess MOZ_GUARDED_BY(mHandleLock);
+ DarwinObjectPtr<xpc_connection_t> mXPCConnection MOZ_GUARDED_BY(mHandleLock);
+ UniqueBEProcessCapabilityGrant mForegroundCapabilityGrant
+ MOZ_GUARDED_BY(mHandleLock);
+#endif
RefPtr<ProcessHandlePromise> mHandlePromise;
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
diff --git a/ipc/glue/NodeChannel.cpp b/ipc/glue/NodeChannel.cpp
index 169aa91f9b..7da0fa3543 100644
--- a/ipc/glue/NodeChannel.cpp
+++ b/ipc/glue/NodeChannel.cpp
@@ -112,7 +112,7 @@ void NodeChannel::SetOtherPid(base::ProcessId aNewPid) {
mChannel->SetOtherPid(aNewPid);
}
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
void NodeChannel::SetMachTaskPort(task_t aTask) {
AssertIOThread();
diff --git a/ipc/glue/NodeChannel.h b/ipc/glue/NodeChannel.h
index fb3d297348..56f9a19ce1 100644
--- a/ipc/glue/NodeChannel.h
+++ b/ipc/glue/NodeChannel.h
@@ -118,7 +118,7 @@ class NodeChannel final : public IPC::Channel::Listener {
// THREAD.
void SetOtherPid(base::ProcessId aNewPid);
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
// Called by the GeckoChildProcessHost to provide the task_t for the peer
// process. MUST BE CALLED FROM THE IO THREAD.
void SetMachTaskPort(task_t aTask);
diff --git a/ipc/glue/NodeController.cpp b/ipc/glue/NodeController.cpp
index 532e4fa509..7781771660 100644
--- a/ipc/glue/NodeController.cpp
+++ b/ipc/glue/NodeController.cpp
@@ -315,7 +315,7 @@ void NodeController::ForwardEvent(const NodeName& aNode,
// On Windows and macOS, messages holding HANDLEs or mach ports must be
// relayed via the broker process so it can transfer ownership.
bool needsRelay = false;
-#if defined(XP_WIN) || defined(XP_MACOSX)
+#if defined(XP_WIN) || defined(XP_DARWIN)
if (!IsBroker() && aNode != kBrokerNodeName &&
aEvent->type() == Event::kUserMessage) {
auto* userEvent = static_cast<UserMessageEvent*>(aEvent.get());
@@ -439,7 +439,7 @@ void NodeController::OnEventMessage(const NodeName& aFromNode,
}
NodeName fromNode = aFromNode;
-#if defined(XP_WIN) || defined(XP_MACOSX)
+#if defined(XP_WIN) || defined(XP_DARWIN)
if (isRelay) {
if (event->type() != Event::kUserMessage) {
NODECONTROLLER_WARNING(
diff --git a/ipc/glue/PBackgroundSharedTypes.ipdlh b/ipc/glue/PBackgroundSharedTypes.ipdlh
index 92175b782d..101f5eb6d7 100644
--- a/ipc/glue/PBackgroundSharedTypes.ipdlh
+++ b/ipc/glue/PBackgroundSharedTypes.ipdlh
@@ -64,7 +64,7 @@ namespace ipc {
ContentSecurityPolicy[] policyInfos;
PrincipalInfo requestPrincipalInfo;
nsCString selfURISpec;
- nsString referrer;
+ nsCString referrer;
uint64_t innerWindowID;
bool skipAllowInlineStyleCheck;
};
diff --git a/ipc/glue/ProcessUtils.h b/ipc/glue/ProcessUtils.h
index b0f146ef6d..27c336a92c 100644
--- a/ipc/glue/ProcessUtils.h
+++ b/ipc/glue/ProcessUtils.h
@@ -71,8 +71,8 @@ class SharedPreferenceDeserializer final {
base::SharedMemory mShmem;
};
-#ifdef ANDROID
-// Android doesn't use -prefsHandle or -prefMapHandle. It gets those FDs
+#if defined(ANDROID) || defined(XP_IOS)
+// Android/iOS doesn't use -prefsHandle or -prefMapHandle. It gets those FDs
// another way.
void SetPrefsFd(int aFd);
void SetPrefMapFd(int aFd);
diff --git a/ipc/glue/ProcessUtils_common.cpp b/ipc/glue/ProcessUtils_common.cpp
index 69eb4bdf28..8fccce5862 100644
--- a/ipc/glue/ProcessUtils_common.cpp
+++ b/ipc/glue/ProcessUtils_common.cpp
@@ -98,7 +98,7 @@ void SharedPreferenceSerializer::AddSharedPrefCmdLineArgs(
geckoargs::sPrefMapSize.Put((uintptr_t)(GetPrefMapSize()), aExtraOpts);
}
-#ifdef ANDROID
+#if defined(ANDROID) || defined(XP_IOS)
static int gPrefsFd = -1;
static int gPrefMapFd = -1;
@@ -145,8 +145,8 @@ bool SharedPreferenceDeserializer::DeserializeFromSharedMemory(
return false;
}
-#ifdef ANDROID
- // Android is different; get the FD via gPrefsFd instead of a fixed fd.
+#if defined(ANDROID) || defined(XP_IOS)
+ // Android/iOS is different; get the FD via gPrefsFd instead of a fixed fd.
MOZ_RELEASE_ASSERT(gPrefsFd != -1);
prefsHandle = Some(UniqueFileHandle(gPrefsFd));
@@ -195,8 +195,8 @@ static const int kJSInitFileDescriptor = 11;
void ExportSharedJSInit(mozilla::ipc::GeckoChildProcessHost& procHost,
std::vector<std::string>& aExtraOpts) {
-#ifdef ANDROID
- // The code to support Android is added in a follow-up patch.
+#if defined(ANDROID) || defined(XP_IOS)
+ // The code to support Android/iOS is added in a follow-up patch.
return;
#else
auto& shmem = xpc::SelfHostedShmem::GetSingleton();
diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h
index 7edce9612b..2800a41c91 100644
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -110,9 +110,6 @@ struct ActorHandle {
int mId;
};
-// What happens if Interrupt calls race?
-enum RacyInterruptPolicy { RIPError, RIPChildWins, RIPParentWins };
-
enum class LinkStatus : uint8_t {
// The actor has not established a link yet, or the actor is no longer in use
// by IPC, and its 'Dealloc' method has been called or is being called.
@@ -128,7 +125,7 @@ enum class LinkStatus : uint8_t {
Connected,
// The link has begun being destroyed. Messages may still be received, but
- // cannot be sent. (exception: sync/intr replies may be sent while Doomed).
+ // cannot be sent. (exception: sync replies may be sent while Doomed).
Doomed,
// The link has been destroyed, and messages will no longer be sent or
@@ -223,8 +220,6 @@ class IProtocol : public HasResultCodes {
virtual Result OnMessageReceived(const Message& aMessage) = 0;
virtual Result OnMessageReceived(const Message& aMessage,
UniquePtr<Message>& aReply) = 0;
- virtual Result OnCallReceived(const Message& aMessage,
- UniquePtr<Message>& aReply) = 0;
bool AllocShmem(size_t aSize, Shmem* aOutMem);
bool AllocUnsafeShmem(size_t aSize, Shmem* aOutMem);
bool DeallocShmem(Shmem& aMem);
@@ -461,8 +456,7 @@ class IToplevelProtocol : public IRefCountedProtocol {
// the same thread. This method should be called on the thread to perform
// the link.
//
- // WARNING: Attempting to send a sync or intr message on the same thread
- // will crash.
+ // WARNING: Attempting to send a sync message on the same thread will crash.
bool OpenOnSameThread(IToplevelProtocol* aTarget,
mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide);
diff --git a/ipc/glue/UtilityAudioDecoderChild.cpp b/ipc/glue/UtilityAudioDecoderChild.cpp
index cc3560e05b..ec46927870 100644
--- a/ipc/glue/UtilityAudioDecoderChild.cpp
+++ b/ipc/glue/UtilityAudioDecoderChild.cpp
@@ -246,7 +246,7 @@ void UtilityAudioDecoderChild::GetKeySystemCapabilities(
info->mClearlead =
DoesKeySystemSupportClearLead(info->mKeySystemName);
if (capabilities.isHDCP22Compatible()) {
- info->mIsHDCP22Compatible = true;
+ info->mIsHDCP22Compatible = *capabilities.isHDCP22Compatible();
}
}
promise->MaybeResolve(cdmInfo);
diff --git a/ipc/glue/moz.build b/ipc/glue/moz.build
index 7aa29612b8..f5bf67f777 100644
--- a/ipc/glue/moz.build
+++ b/ipc/glue/moz.build
@@ -153,6 +153,14 @@ if CONFIG["OS_ARCH"] != "WINNT":
"FileDescriptorShuffle.cpp",
]
+if CONFIG["TARGET_OS"] == "iOS":
+ EXPORTS.mozilla.ipc += [
+ "ExtensionKitUtils.h",
+ ]
+ UNIFIED_SOURCES += [
+ "ExtensionKitUtils.mm",
+ ]
+
EXPORTS.ipc += [
"EnumSerializer.h",
"IPCMessageUtils.h",
@@ -284,8 +292,10 @@ include("/ipc/chromium/chromium-config.mozbuild")
FINAL_LIBRARY = "xul"
-if CONFIG["OS_ARCH"] == "Darwin":
+if CONFIG["TARGET_OS"] == "OSX":
OS_LIBS += ["bsm"] # for audit_token_to_pid
+elif CONFIG["TARGET_OS"] == "iOS":
+ OS_LIBS += ["-framework BrowserEngineKit"]
for var in (
"MOZ_CHILD_PROCESS_NAME",