From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- ipc/chromium/src/base/message_pump_mac.h | 20 ++++++++++++++++++++ ipc/chromium/src/base/message_pump_mac.mm | 27 ++++++++++++++++++++++++--- ipc/chromium/src/base/process_util_ios.cpp | 17 +++++++++++++++++ ipc/chromium/src/base/process_util_posix.cc | 2 +- 4 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 ipc/chromium/src/base/process_util_ios.cpp (limited to 'ipc/chromium/src/base') diff --git a/ipc/chromium/src/base/message_pump_mac.h b/ipc/chromium/src/base/message_pump_mac.h index 13902bbf3e..7d7796b98b 100644 --- a/ipc/chromium/src/base/message_pump_mac.h +++ b/ipc/chromium/src/base/message_pump_mac.h @@ -144,11 +144,13 @@ class MessagePumpCFRunLoopBase : public MessagePump { // the basis of run loops starting and stopping. virtual void EnterExitRunLoop(CFRunLoopActivity activity); +#if !defined(XP_IOS) // IOKit power state change notification callback, called when the system // enters and leaves the sleep state. static void PowerStateNotification(void* info, io_service_t service, uint32_t message_type, void* message_argument); +#endif // The thread's run loop. CFRunLoopRef run_loop_; @@ -241,6 +243,23 @@ class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase { DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop); }; +#if defined(XP_IOS) +// This is a fake message pump. It attaches sources to the main thread's +// CFRunLoop, so PostTask() will work, but it is unable to drive the loop +// directly, so calling Run() or Quit() are errors. +class MessagePumpUIApplication : public MessagePumpCFRunLoopBase { + public: + MessagePumpUIApplication() {} + + void DoRun(Delegate* delegate) override; + void Quit() override; + + private: + DISALLOW_COPY_AND_ASSIGN(MessagePumpUIApplication); +}; + +#else + class MessagePumpNSApplication : public MessagePumpCFRunLoopBase { public: MessagePumpNSApplication(); @@ -264,6 +283,7 @@ class MessagePumpNSApplication : public MessagePumpCFRunLoopBase { DISALLOW_COPY_AND_ASSIGN(MessagePumpNSApplication); }; +#endif class MessagePumpMac { public: diff --git a/ipc/chromium/src/base/message_pump_mac.mm b/ipc/chromium/src/base/message_pump_mac.mm index 1382e2a0dc..a5e7092d16 100644 --- a/ipc/chromium/src/base/message_pump_mac.mm +++ b/ipc/chromium/src/base/message_pump_mac.mm @@ -4,14 +4,18 @@ #include "base/message_pump_mac.h" -#import +#if !defined(XP_IOS) +# import +# include +#endif #import #include -#include #include -#import "base/chrome_application_mac.h" +#if !defined(XP_IOS) +# import "base/chrome_application_mac.h" +#endif #include "base/logging.h" #include "base/time.h" @@ -120,6 +124,7 @@ MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase() EnterExitObserver, &observer_context); CFRunLoopAddObserver(run_loop_, enter_exit_observer_, kCFRunLoopCommonModes); +#if !defined(XP_IOS) root_power_domain_ = IORegisterForSystemPower(this, &power_notification_port_, PowerStateNotification, &power_notification_object_); @@ -128,12 +133,14 @@ MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase() run_loop_, IONotificationPortGetRunLoopSource(power_notification_port_), kCFRunLoopCommonModes); } +#endif } // Ideally called on the run loop thread. If other run loops were running // lower on the run loop thread's stack when this object was created, the // same number of run loops must be running when this object is destroyed. MessagePumpCFRunLoopBase::~MessagePumpCFRunLoopBase() { +#if !defined(XP_IOS) if (root_power_domain_ != MACH_PORT_NULL) { CFRunLoopRemoveSource( run_loop_, IONotificationPortGetRunLoopSource(power_notification_port_), @@ -142,6 +149,7 @@ MessagePumpCFRunLoopBase::~MessagePumpCFRunLoopBase() { IOServiceClose(root_power_domain_); IONotificationPortDestroy(power_notification_port_); } +#endif CFRunLoopRemoveObserver(run_loop_, enter_exit_observer_, kCFRunLoopCommonModes); @@ -478,6 +486,7 @@ void MessagePumpCFRunLoopBase::EnterExitObserver(CFRunLoopObserverRef observer, self->EnterExitRunLoop(activity); } +#if !defined(XP_IOS) // Called from the run loop. // static void MessagePumpCFRunLoopBase::PowerStateNotification(void* info, @@ -544,6 +553,7 @@ void MessagePumpCFRunLoopBase::PowerStateNotification(void* info, break; } } +#endif // Called by MessagePumpCFRunLoopBase::EnterExitRunLoop. The default // implementation is a no-op. @@ -630,6 +640,12 @@ void MessagePumpNSRunLoop::Quit() { CFRunLoopWakeUp(run_loop()); } +#if defined(XP_IOS) +void MessagePumpUIApplication::DoRun(Delegate* delegate) { NOTREACHED(); } + +void MessagePumpUIApplication::Quit() { NOTREACHED(); } + +#else MessagePumpNSApplication::MessagePumpNSApplication() : keep_running_(true), running_own_loop_(false) {} @@ -722,11 +738,16 @@ NSAutoreleasePool* MessagePumpNSApplication::CreateAutoreleasePool() { } return pool; } +#endif // static MessagePump* MessagePumpMac::Create() { if ([NSThread isMainThread]) { +#if defined(XP_IOS) + return new MessagePumpUIApplication; +#else return new MessagePumpNSApplication; +#endif } return new MessagePumpNSRunLoop; diff --git a/ipc/chromium/src/base/process_util_ios.cpp b/ipc/chromium/src/base/process_util_ios.cpp new file mode 100644 index 0000000000..1ec4e77561 --- /dev/null +++ b/ipc/chromium/src/base/process_util_ios.cpp @@ -0,0 +1,17 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/process_util.h" + +namespace base { + +Result LaunchApp(const std::vector& argv, + LaunchOptions&& options, + ProcessHandle* process_handle) { + return Err(LaunchError("LaunchApp is not supported on iOS")); +} + +} // namespace base diff --git a/ipc/chromium/src/base/process_util_posix.cc b/ipc/chromium/src/base/process_util_posix.cc index 3229570ad8..d91dc25e9f 100644 --- a/ipc/chromium/src/base/process_util_posix.cc +++ b/ipc/chromium/src/base/process_util_posix.cc @@ -198,7 +198,7 @@ void CloseSuperfluousFds(void* aCtx, bool (*aShouldPreserve)(void*, int)) { bool IsProcessDead(ProcessHandle handle, bool blocking) { auto handleForkServer = [handle]() -> mozilla::Maybe { #ifdef MOZ_ENABLE_FORKSERVER - if (errno == ECHILD && mozilla::ipc::ForkServiceChild::Get()) { + if (errno == ECHILD && mozilla::ipc::ForkServiceChild::WasUsed()) { // We only know if a process exists, but not if it has crashed. // // Since content processes are not direct children of the chrome -- cgit v1.2.3