Move scoped_mach_port to base/apple, leave a forwarding header
Crashpad is not yet updated for the new location, so leave a
forwarding header to be removed later.
Bug: 1444927
Change-Id: I624cae5d8b97e490bc6749fd35be3abf1b072546
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4784629
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1184421}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
ee2dfb18fa
commit
dd92b53f5b
base
BUILD.gn
apple
mac
mach_port_rendezvous.ccmach_port_rendezvous.hmach_port_rendezvous_fuzzer.ccmach_port_rendezvous_unittest.ccscoped_mach_port.h
memory
message_loop
metrics
process
synchronization
system
time
chrome
components
content
browser
child_process_task_port_provider_mac.ccchild_process_task_port_provider_mac.hchild_process_task_port_provider_mac_unittest.cc
memory
child
extensions/browser/api/system_cpu
ios/chrome/browser/memory
ipc
media/audio/mac
mojo
core
public
services/device/compute_pressure
testing/libfuzzer/fuzzers/mach
tools/memory/simulator
ui/gfx/mojom
@ -1961,6 +1961,8 @@ component("base") {
|
||||
"apple/owned_objc.mm",
|
||||
"apple/scoped_cffiledescriptorref.h",
|
||||
"apple/scoped_dispatch_object.h",
|
||||
"apple/scoped_mach_port.cc",
|
||||
"apple/scoped_mach_port.h",
|
||||
"apple/scoped_nsobject.h",
|
||||
"apple/scoped_objc_class_swizzler.h",
|
||||
"apple/scoped_objc_class_swizzler.mm",
|
||||
@ -1970,8 +1972,6 @@ component("base") {
|
||||
"files/file_util_apple.mm",
|
||||
"mac/foundation_util.h",
|
||||
"mac/foundation_util.mm",
|
||||
"mac/scoped_mach_port.cc",
|
||||
"mac/scoped_mach_port.h",
|
||||
"mac/scoped_mach_vm.cc",
|
||||
"mac/scoped_mach_vm.h",
|
||||
"mac/scoped_nsautorelease_pool.cc",
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -38,8 +38,8 @@ class DispatchSourceMachTest : public testing::Test {
|
||||
}
|
||||
|
||||
private:
|
||||
base::mac::ScopedMachReceiveRight receive_right_;
|
||||
base::mac::ScopedMachSendRight send_right_;
|
||||
base::apple::ScopedMachReceiveRight receive_right_;
|
||||
base::apple::ScopedMachSendRight send_right_;
|
||||
};
|
||||
|
||||
TEST_F(DispatchSourceMachTest, ReceiveAfterResume) {
|
||||
|
@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
|
||||
namespace base::mac {
|
||||
namespace base::apple {
|
||||
namespace internal {
|
||||
|
||||
// static
|
||||
@ -65,10 +65,11 @@ bool CreateMachPort(ScopedMachReceiveRight* receive,
|
||||
ScopedMachSendRight RetainMachSendRight(mach_port_t port) {
|
||||
kern_return_t kr =
|
||||
mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1);
|
||||
if (kr == KERN_SUCCESS)
|
||||
if (kr == KERN_SUCCESS) {
|
||||
return ScopedMachSendRight(port);
|
||||
}
|
||||
MACH_DLOG(ERROR, kr) << "mach_port_mod_refs +1";
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace base::mac
|
||||
} // namespace base::apple
|
79
base/apple/scoped_mach_port.h
Normal file
79
base/apple/scoped_mach_port.h
Normal file
@ -0,0 +1,79 @@
|
||||
// Copyright 2012 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_APPLE_SCOPED_MACH_PORT_H_
|
||||
#define BASE_APPLE_SCOPED_MACH_PORT_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
|
||||
#include "base/base_export.h"
|
||||
#include "base/scoped_generic.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
namespace base::apple {
|
||||
|
||||
namespace internal {
|
||||
|
||||
struct BASE_EXPORT SendRightTraits {
|
||||
static mach_port_t InvalidValue() {
|
||||
return MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
BASE_EXPORT static void Free(mach_port_t port);
|
||||
};
|
||||
|
||||
struct BASE_EXPORT ReceiveRightTraits {
|
||||
static mach_port_t InvalidValue() {
|
||||
return MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
BASE_EXPORT static void Free(mach_port_t port);
|
||||
};
|
||||
|
||||
struct PortSetTraits {
|
||||
static mach_port_t InvalidValue() {
|
||||
return MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
BASE_EXPORT static void Free(mach_port_t port);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// A scoper for handling a Mach port that names a send right. Send rights are
|
||||
// reference counted, and this takes ownership of the right on construction
|
||||
// and then removes a reference to the right on destruction. If the reference
|
||||
// is the last one on the right, the right is deallocated.
|
||||
using ScopedMachSendRight =
|
||||
ScopedGeneric<mach_port_t, internal::SendRightTraits>;
|
||||
|
||||
// A scoper for handling a Mach port's receive right. There is only one
|
||||
// receive right per port. This takes ownership of the receive right on
|
||||
// construction and then destroys the right on destruction, turning all
|
||||
// outstanding send rights into dead names.
|
||||
using ScopedMachReceiveRight =
|
||||
ScopedGeneric<mach_port_t, internal::ReceiveRightTraits>;
|
||||
|
||||
// A scoper for handling a Mach port set. A port set can have only one
|
||||
// reference. This takes ownership of that single reference on construction and
|
||||
// destroys the port set on destruction. Destroying a port set does not destroy
|
||||
// the receive rights that are members of the port set.
|
||||
using ScopedMachPortSet = ScopedGeneric<mach_port_t, internal::PortSetTraits>;
|
||||
|
||||
// Constructs a Mach port receive right and places the result in |receive|.
|
||||
// If |send| is non-null, a send right will be created as well and stored
|
||||
// there. If |queue_limit| is specified, the receive right will be constructed
|
||||
// with the specified mpo_qlmit. Returns true on success and false on failure.
|
||||
BASE_EXPORT bool CreateMachPort(
|
||||
ScopedMachReceiveRight* receive,
|
||||
ScopedMachSendRight* send,
|
||||
absl::optional<mach_port_msgcount_t> queue_limit = absl::nullopt);
|
||||
|
||||
// Increases the user reference count for MACH_PORT_RIGHT_SEND by 1 and returns
|
||||
// a new scoper to manage the additional right.
|
||||
BASE_EXPORT ScopedMachSendRight RetainMachSendRight(mach_port_t port);
|
||||
|
||||
} // namespace base::apple
|
||||
|
||||
#endif // BASE_APPLE_SCOPED_MACH_PORT_H_
|
@ -59,11 +59,11 @@ MachRendezvousPort::MachRendezvousPort(mach_port_t name,
|
||||
disposition == MACH_MSG_TYPE_MAKE_SEND_ONCE);
|
||||
}
|
||||
|
||||
MachRendezvousPort::MachRendezvousPort(mac::ScopedMachSendRight send_right)
|
||||
MachRendezvousPort::MachRendezvousPort(apple::ScopedMachSendRight send_right)
|
||||
: name_(send_right.release()), disposition_(MACH_MSG_TYPE_MOVE_SEND) {}
|
||||
|
||||
MachRendezvousPort::MachRendezvousPort(
|
||||
mac::ScopedMachReceiveRight receive_right)
|
||||
apple::ScopedMachReceiveRight receive_right)
|
||||
: name_(receive_right.release()),
|
||||
disposition_(MACH_MSG_TYPE_MOVE_RECEIVE) {}
|
||||
|
||||
@ -143,7 +143,7 @@ MachPortRendezvousServer::MachPortRendezvousServer() {
|
||||
StringPrintf(kBootstrapNameFormat, mac::BaseBundleID(), getpid());
|
||||
kern_return_t kr = bootstrap_check_in(
|
||||
bootstrap_port, bootstrap_name.c_str(),
|
||||
mac::ScopedMachReceiveRight::Receiver(server_port_).get());
|
||||
apple::ScopedMachReceiveRight::Receiver(server_port_).get());
|
||||
BOOTSTRAP_CHECK(kr == KERN_SUCCESS, kr)
|
||||
<< "bootstrap_check_in " << bootstrap_name;
|
||||
|
||||
@ -277,21 +277,21 @@ MachPortRendezvousClient* MachPortRendezvousClient::GetInstance() {
|
||||
return client;
|
||||
}
|
||||
|
||||
mac::ScopedMachSendRight MachPortRendezvousClient::TakeSendRight(
|
||||
apple::ScopedMachSendRight MachPortRendezvousClient::TakeSendRight(
|
||||
MachPortsForRendezvous::key_type key) {
|
||||
MachRendezvousPort port = PortForKey(key);
|
||||
DCHECK(port.disposition() == 0 ||
|
||||
port.disposition() == MACH_MSG_TYPE_PORT_SEND ||
|
||||
port.disposition() == MACH_MSG_TYPE_PORT_SEND_ONCE);
|
||||
return mac::ScopedMachSendRight(port.name());
|
||||
return apple::ScopedMachSendRight(port.name());
|
||||
}
|
||||
|
||||
mac::ScopedMachReceiveRight MachPortRendezvousClient::TakeReceiveRight(
|
||||
apple::ScopedMachReceiveRight MachPortRendezvousClient::TakeReceiveRight(
|
||||
MachPortsForRendezvous::key_type key) {
|
||||
MachRendezvousPort port = PortForKey(key);
|
||||
DCHECK(port.disposition() == 0 ||
|
||||
port.disposition() == MACH_MSG_TYPE_PORT_RECEIVE);
|
||||
return mac::ScopedMachReceiveRight(port.name());
|
||||
return apple::ScopedMachReceiveRight(port.name());
|
||||
}
|
||||
|
||||
size_t MachPortRendezvousClient::GetPortCount() {
|
||||
@ -307,11 +307,11 @@ std::string MachPortRendezvousClient::GetBootstrapName() {
|
||||
bool MachPortRendezvousClient::AcquirePorts() {
|
||||
AutoLock lock(lock_);
|
||||
|
||||
mac::ScopedMachSendRight server_port;
|
||||
apple::ScopedMachSendRight server_port;
|
||||
std::string bootstrap_name = GetBootstrapName();
|
||||
kern_return_t kr = bootstrap_look_up(
|
||||
bootstrap_port, const_cast<char*>(bootstrap_name.c_str()),
|
||||
mac::ScopedMachSendRight::Receiver(server_port).get());
|
||||
apple::ScopedMachSendRight::Receiver(server_port).get());
|
||||
if (kr != KERN_SUCCESS) {
|
||||
BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up " << bootstrap_name;
|
||||
return false;
|
||||
@ -321,7 +321,7 @@ bool MachPortRendezvousClient::AcquirePorts() {
|
||||
}
|
||||
|
||||
bool MachPortRendezvousClient::SendRequest(
|
||||
mac::ScopedMachSendRight server_port) {
|
||||
apple::ScopedMachSendRight server_port) {
|
||||
const size_t buffer_size = CalculateResponseSize(kMaximumRendezvousPorts) +
|
||||
sizeof(mach_msg_trailer_t);
|
||||
auto buffer = std::make_unique<uint8_t[]>(buffer_size);
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
#include "base/apple/dispatch_source_mach.h"
|
||||
#include "base/apple/scoped_dispatch_object.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/base_export.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/thread_annotations.h"
|
||||
|
||||
@ -48,9 +48,9 @@ class BASE_EXPORT MachRendezvousPort {
|
||||
// Creates a rendezvous port that allows specifying the specific disposition.
|
||||
MachRendezvousPort(mach_port_t name, mach_msg_type_name_t disposition);
|
||||
// Creates a rendezvous port for MACH_MSG_TYPE_MOVE_SEND.
|
||||
explicit MachRendezvousPort(mac::ScopedMachSendRight send_right);
|
||||
explicit MachRendezvousPort(apple::ScopedMachSendRight send_right);
|
||||
// Creates a rendezvous port for MACH_MSG_TYPE_MOVE_RECEIVE.
|
||||
explicit MachRendezvousPort(mac::ScopedMachReceiveRight receive_right);
|
||||
explicit MachRendezvousPort(apple::ScopedMachReceiveRight receive_right);
|
||||
|
||||
// Note that the destructor does not call Destroy() explicitly.
|
||||
// To avoid leaking ports, either use dispositions that create rights during
|
||||
@ -147,7 +147,7 @@ class BASE_EXPORT MachPortRendezvousServer {
|
||||
|
||||
// The Mach receive right for the server. A send right to this is port is
|
||||
// registered in the bootstrap server.
|
||||
mac::ScopedMachReceiveRight server_port_;
|
||||
apple::ScopedMachReceiveRight server_port_;
|
||||
|
||||
// Mach message dispatch source for |server_port_|.
|
||||
std::unique_ptr<DispatchSourceMach> dispatch_source_;
|
||||
@ -175,13 +175,14 @@ class BASE_EXPORT MachPortRendezvousClient {
|
||||
// right exists, or it was already taken, returns an invalid right. Safe to
|
||||
// call from any thread. DCHECKs if the right referenced by |key| is not a
|
||||
// send or send-once right.
|
||||
mac::ScopedMachSendRight TakeSendRight(MachPortsForRendezvous::key_type key);
|
||||
apple::ScopedMachSendRight TakeSendRight(
|
||||
MachPortsForRendezvous::key_type key);
|
||||
|
||||
// Returns the Mach receive right that was registered with |key|. If no such
|
||||
// right exists, or it was already taken, returns an invalid right. Safe to
|
||||
// call from any thread. DCHECKs if the right referenced by |key| is not a
|
||||
// receive right.
|
||||
mac::ScopedMachReceiveRight TakeReceiveRight(
|
||||
apple::ScopedMachReceiveRight TakeReceiveRight(
|
||||
MachPortsForRendezvous::key_type key);
|
||||
|
||||
// Returns the number of ports in the client. After PerformRendezvous(), this
|
||||
@ -201,7 +202,7 @@ class BASE_EXPORT MachPortRendezvousClient {
|
||||
bool AcquirePorts();
|
||||
|
||||
// Sends the actual IPC message to |server_port| and parses the reply.
|
||||
bool SendRequest(mac::ScopedMachSendRight server_port)
|
||||
bool SendRequest(apple::ScopedMachSendRight server_port)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
|
||||
// Returns a MachRendezvousPort for a given key and removes it from the
|
||||
|
@ -30,7 +30,7 @@ struct MachPortRendezvousFuzzer {
|
||||
base::MachPortRendezvousServer::GetInstance()->client_data_.clear();
|
||||
}
|
||||
|
||||
base::mac::ScopedMachSendRight server_send_right;
|
||||
base::apple::ScopedMachSendRight server_send_right;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
@ -44,7 +44,7 @@ MULTIPROCESS_TEST_MAIN(TakeSendRight) {
|
||||
|
||||
CHECK_EQ(1u, rendezvous_client->GetPortCount());
|
||||
|
||||
mac::ScopedMachSendRight port =
|
||||
apple::ScopedMachSendRight port =
|
||||
rendezvous_client->TakeSendRight(kTestPortKey);
|
||||
CHECK(port.is_valid());
|
||||
|
||||
@ -66,10 +66,10 @@ TEST_F(MachPortRendezvousServerTest, SendRight) {
|
||||
auto* server = MachPortRendezvousServer::GetInstance();
|
||||
ASSERT_TRUE(server);
|
||||
|
||||
mac::ScopedMachReceiveRight port;
|
||||
apple::ScopedMachReceiveRight port;
|
||||
kern_return_t kr =
|
||||
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
|
||||
mac::ScopedMachReceiveRight::Receiver(port).get());
|
||||
apple::ScopedMachReceiveRight::Receiver(port).get());
|
||||
ASSERT_EQ(kr, KERN_SUCCESS);
|
||||
|
||||
MachRendezvousPort rendezvous_port(port.get(), MACH_MSG_TYPE_MAKE_SEND);
|
||||
@ -127,10 +127,10 @@ TEST_F(MachPortRendezvousServerTest, CleanupIfNoRendezvous) {
|
||||
auto* server = MachPortRendezvousServer::GetInstance();
|
||||
ASSERT_TRUE(server);
|
||||
|
||||
mac::ScopedMachReceiveRight port;
|
||||
apple::ScopedMachReceiveRight port;
|
||||
kern_return_t kr =
|
||||
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
|
||||
mac::ScopedMachReceiveRight::Receiver(port).get());
|
||||
apple::ScopedMachReceiveRight::Receiver(port).get());
|
||||
ASSERT_EQ(kr, KERN_SUCCESS);
|
||||
|
||||
MachRendezvousPort rendezvous_port(port.get(), MACH_MSG_TYPE_MAKE_SEND);
|
||||
|
@ -1,78 +1,23 @@
|
||||
// Copyright 2012 The Chromium Authors
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_MAC_SCOPED_MACH_PORT_H_
|
||||
#define BASE_MAC_SCOPED_MACH_PORT_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
|
||||
#include "base/base_export.h"
|
||||
#include "base/scoped_generic.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
// This is a forwarding header so that Crashpad can continue to build correctly
|
||||
// until mini_chromium and then it are updated and rolled.
|
||||
|
||||
// TODO(https://crbug.com/1444927): Update mini_chromium, update Crashpad, roll
|
||||
// Crashpad, and then delete this forwarding header.
|
||||
|
||||
namespace base::mac {
|
||||
|
||||
namespace internal {
|
||||
|
||||
struct BASE_EXPORT SendRightTraits {
|
||||
static mach_port_t InvalidValue() {
|
||||
return MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
BASE_EXPORT static void Free(mach_port_t port);
|
||||
};
|
||||
|
||||
struct BASE_EXPORT ReceiveRightTraits {
|
||||
static mach_port_t InvalidValue() {
|
||||
return MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
BASE_EXPORT static void Free(mach_port_t port);
|
||||
};
|
||||
|
||||
struct PortSetTraits {
|
||||
static mach_port_t InvalidValue() {
|
||||
return MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
BASE_EXPORT static void Free(mach_port_t port);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// A scoper for handling a Mach port that names a send right. Send rights are
|
||||
// reference counted, and this takes ownership of the right on construction
|
||||
// and then removes a reference to the right on destruction. If the reference
|
||||
// is the last one on the right, the right is deallocated.
|
||||
using ScopedMachSendRight =
|
||||
ScopedGeneric<mach_port_t, internal::SendRightTraits>;
|
||||
|
||||
// A scoper for handling a Mach port's receive right. There is only one
|
||||
// receive right per port. This takes ownership of the receive right on
|
||||
// construction and then destroys the right on destruction, turning all
|
||||
// outstanding send rights into dead names.
|
||||
using ScopedMachReceiveRight =
|
||||
ScopedGeneric<mach_port_t, internal::ReceiveRightTraits>;
|
||||
|
||||
// A scoper for handling a Mach port set. A port set can have only one
|
||||
// reference. This takes ownership of that single reference on construction and
|
||||
// destroys the port set on destruction. Destroying a port set does not destroy
|
||||
// the receive rights that are members of the port set.
|
||||
using ScopedMachPortSet = ScopedGeneric<mach_port_t, internal::PortSetTraits>;
|
||||
|
||||
// Constructs a Mach port receive right and places the result in |receive|.
|
||||
// If |send| is non-null, a send right will be created as well and stored
|
||||
// there. If |queue_limit| is specified, the receive right will be constructed
|
||||
// with the specified mpo_qlmit. Returns true on success and false on failure.
|
||||
BASE_EXPORT bool CreateMachPort(
|
||||
ScopedMachReceiveRight* receive,
|
||||
ScopedMachSendRight* send,
|
||||
absl::optional<mach_port_msgcount_t> queue_limit = absl::nullopt);
|
||||
|
||||
// Increases the user reference count for MACH_PORT_RIGHT_SEND by 1 and returns
|
||||
// a new scoper to manage the additional right.
|
||||
BASE_EXPORT ScopedMachSendRight RetainMachSendRight(mach_port_t port);
|
||||
using ScopedMachSendRight = base::apple::ScopedMachSendRight;
|
||||
using ScopedMachReceiveRight = base::apple::ScopedMachReceiveRight;
|
||||
using ScopedMachPortSet = base::apple::ScopedMachPortSet;
|
||||
|
||||
} // namespace base::mac
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
#include <mach/mach.h>
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
#include <lib/zx/vmo.h>
|
||||
#elif BUILDFLAG(IS_WIN)
|
||||
@ -51,7 +51,7 @@ struct BASE_EXPORT ScopedFDPair {
|
||||
// Platform-specific shared memory type used by the shared memory system.
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
using PlatformSharedMemoryHandle = mach_port_t;
|
||||
using ScopedPlatformSharedMemoryHandle = mac::ScopedMachSendRight;
|
||||
using ScopedPlatformSharedMemoryHandle = apple::ScopedMachSendRight;
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
using PlatformSharedMemoryHandle = zx::unowned_vmo;
|
||||
using ScopedPlatformSharedMemoryHandle = zx::vmo;
|
||||
|
@ -13,7 +13,7 @@ namespace base::subtle {
|
||||
|
||||
// static
|
||||
PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Take(
|
||||
mac::ScopedMachSendRight handle,
|
||||
apple::ScopedMachSendRight handle,
|
||||
Mode mode,
|
||||
size_t size,
|
||||
const UnguessableToken& guid) {
|
||||
@ -59,7 +59,7 @@ PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Duplicate() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
return PlatformSharedMemoryRegion(mac::ScopedMachSendRight(handle_.get()),
|
||||
return PlatformSharedMemoryRegion(apple::ScopedMachSendRight(handle_.get()),
|
||||
mode_, size_, guid_);
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ bool PlatformSharedMemoryRegion::ConvertToReadOnly(void* mapped_addr) {
|
||||
CHECK_EQ(mode_, Mode::kWritable)
|
||||
<< "Only writable shared memory region can be converted to read-only";
|
||||
|
||||
mac::ScopedMachSendRight handle_copy(handle_.release());
|
||||
apple::ScopedMachSendRight handle_copy(handle_.release());
|
||||
|
||||
void* temp_addr = mapped_addr;
|
||||
mac::ScopedMachVM scoped_memory;
|
||||
@ -95,11 +95,11 @@ bool PlatformSharedMemoryRegion::ConvertToReadOnly(void* mapped_addr) {
|
||||
|
||||
// Make new memory object.
|
||||
memory_object_size_t allocation_size = size_;
|
||||
mac::ScopedMachSendRight named_right;
|
||||
apple::ScopedMachSendRight named_right;
|
||||
kern_return_t kr = mach_make_memory_entry_64(
|
||||
mach_task_self(), &allocation_size,
|
||||
reinterpret_cast<memory_object_offset_t>(temp_addr), VM_PROT_READ,
|
||||
mac::ScopedMachSendRight::Receiver(named_right).get(), MACH_PORT_NULL);
|
||||
apple::ScopedMachSendRight::Receiver(named_right).get(), MACH_PORT_NULL);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
MACH_DLOG(ERROR, kr) << "mach_make_memory_entry_64";
|
||||
return false;
|
||||
@ -138,12 +138,12 @@ PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Create(Mode mode,
|
||||
"lead to this region being non-modifiable";
|
||||
|
||||
memory_object_size_t vm_size = size;
|
||||
mac::ScopedMachSendRight named_right;
|
||||
apple::ScopedMachSendRight named_right;
|
||||
kern_return_t kr = mach_make_memory_entry_64(
|
||||
mach_task_self(), &vm_size,
|
||||
0, // Address.
|
||||
MAP_MEM_NAMED_CREATE | VM_PROT_READ | VM_PROT_WRITE,
|
||||
mac::ScopedMachSendRight::Receiver(named_right).get(),
|
||||
apple::ScopedMachSendRight::Receiver(named_right).get(),
|
||||
MACH_PORT_NULL); // Parent handle.
|
||||
// Crash as soon as shm allocation fails to debug the issue
|
||||
// https://crbug.com/872237.
|
||||
@ -190,7 +190,7 @@ bool PlatformSharedMemoryRegion::CheckPlatformHandlePermissionsCorrespondToMode(
|
||||
}
|
||||
|
||||
PlatformSharedMemoryRegion::PlatformSharedMemoryRegion(
|
||||
mac::ScopedMachSendRight handle,
|
||||
apple::ScopedMachSendRight handle,
|
||||
Mode mode,
|
||||
size_t size,
|
||||
const UnguessableToken& guid)
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <mach/thread_policy.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/threading/threading_features.h"
|
||||
#endif
|
||||
|
@ -130,7 +130,7 @@ MessagePumpKqueue::MessagePumpKqueue()
|
||||
// using an EVFILT_USER event, especially when triggered across threads.
|
||||
kern_return_t kr = mach_port_allocate(
|
||||
mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
|
||||
base::mac::ScopedMachReceiveRight::Receiver(wakeup_).get());
|
||||
base::apple::ScopedMachReceiveRight::Receiver(wakeup_).get());
|
||||
MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_port_allocate";
|
||||
|
||||
// Configure the event to directly receive the Mach message as part of the
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/containers/id_map.h"
|
||||
#include "base/files/scoped_file.h"
|
||||
#include "base/location.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/message_loop/message_pump.h"
|
||||
@ -161,7 +161,7 @@ class BASE_EXPORT MessagePumpKqueue : public MessagePump,
|
||||
|
||||
// Receive right to which an empty Mach message is sent to wake up the pump
|
||||
// in response to ScheduleWork().
|
||||
mac::ScopedMachReceiveRight wakeup_;
|
||||
apple::ScopedMachReceiveRight wakeup_;
|
||||
// Scratch buffer that is used to receive the message sent to |wakeup_|.
|
||||
mach_msg_empty_rcv_t wakeup_buffer_;
|
||||
|
||||
|
@ -28,16 +28,16 @@ class MessagePumpKqueueTest : public testing::Test {
|
||||
|
||||
MessagePumpKqueue* pump() { return pump_; }
|
||||
|
||||
static void CreatePortPair(mac::ScopedMachReceiveRight* receive,
|
||||
mac::ScopedMachSendRight* send) {
|
||||
static void CreatePortPair(apple::ScopedMachReceiveRight* receive,
|
||||
apple::ScopedMachSendRight* send) {
|
||||
mach_port_options_t options{};
|
||||
options.flags = MPO_INSERT_SEND_RIGHT;
|
||||
mac::ScopedMachReceiveRight port;
|
||||
apple::ScopedMachReceiveRight port;
|
||||
kern_return_t kr = mach_port_construct(
|
||||
mach_task_self(), &options, 0,
|
||||
mac::ScopedMachReceiveRight::Receiver(*receive).get());
|
||||
apple::ScopedMachReceiveRight::Receiver(*receive).get());
|
||||
ASSERT_EQ(kr, KERN_SUCCESS);
|
||||
*send = mac::ScopedMachSendRight(receive->get());
|
||||
*send = apple::ScopedMachSendRight(receive->get());
|
||||
}
|
||||
|
||||
static mach_msg_return_t SendEmptyMessage(mach_port_t remote_port,
|
||||
@ -79,8 +79,8 @@ class PortWatcher : public MessagePumpKqueue::MachPortWatcher {
|
||||
};
|
||||
|
||||
TEST_F(MessagePumpKqueueTest, MachPortBasicWatch) {
|
||||
mac::ScopedMachReceiveRight port;
|
||||
mac::ScopedMachSendRight send_right;
|
||||
apple::ScopedMachReceiveRight port;
|
||||
apple::ScopedMachSendRight send_right;
|
||||
CreatePortPair(&port, &send_right);
|
||||
|
||||
mach_msg_id_t msgid = 'helo';
|
||||
@ -110,8 +110,8 @@ TEST_F(MessagePumpKqueueTest, MachPortBasicWatch) {
|
||||
}
|
||||
|
||||
TEST_F(MessagePumpKqueueTest, MachPortStopWatching) {
|
||||
mac::ScopedMachReceiveRight port;
|
||||
mac::ScopedMachSendRight send_right;
|
||||
apple::ScopedMachReceiveRight port;
|
||||
apple::ScopedMachSendRight send_right;
|
||||
CreatePortPair(&port, &send_right);
|
||||
|
||||
RunLoop run_loop;
|
||||
@ -141,8 +141,8 @@ TEST_F(MessagePumpKqueueTest, MachPortStopWatching) {
|
||||
}
|
||||
|
||||
TEST_F(MessagePumpKqueueTest, MultipleMachWatchers) {
|
||||
mac::ScopedMachReceiveRight port1, port2;
|
||||
mac::ScopedMachSendRight send_right1, send_right2;
|
||||
apple::ScopedMachReceiveRight port1, port2;
|
||||
apple::ScopedMachSendRight send_right1, send_right2;
|
||||
CreatePortPair(&port1, &send_right1);
|
||||
CreatePortPair(&port2, &send_right2);
|
||||
|
||||
|
@ -1105,7 +1105,7 @@ FieldTrialList::DeserializeSharedMemoryRegionMetadata(
|
||||
auto* rendezvous = MachPortRendezvousClient::GetInstance();
|
||||
if (!rendezvous)
|
||||
return ReadOnlySharedMemoryRegion();
|
||||
mac::ScopedMachSendRight scoped_handle = rendezvous->TakeSendRight(
|
||||
apple::ScopedMachSendRight scoped_handle = rendezvous->TakeSendRight(
|
||||
static_cast<MachPortsForRendezvous::key_type>(field_trial_handle));
|
||||
if (!scoped_handle.is_valid())
|
||||
return ReadOnlySharedMemoryRegion();
|
||||
|
@ -12,9 +12,9 @@
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/numerics/safe_math.h"
|
||||
#include "base/time/time.h"
|
||||
@ -162,7 +162,7 @@ int ProcessMetrics::GetIdleWakeupsPerSecond() {
|
||||
|
||||
// Bytes committed by the system.
|
||||
size_t GetSystemCommitCharge() {
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
|
||||
vm_statistics_data_t data;
|
||||
kern_return_t kr = host_statistics(
|
||||
@ -178,7 +178,7 @@ size_t GetSystemCommitCharge() {
|
||||
bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) {
|
||||
struct host_basic_info hostinfo;
|
||||
mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
int result = host_info(host.get(), HOST_BASIC_INFO,
|
||||
reinterpret_cast<host_info_t>(&hostinfo), &count);
|
||||
if (result != KERN_SUCCESS) {
|
||||
@ -245,18 +245,18 @@ MachVMRegionResult GetTopInfo(mach_port_t task,
|
||||
// The kernel always returns a null object for VM_REGION_TOP_INFO, but
|
||||
// balance it with a deallocate in case this ever changes. See 10.9.2
|
||||
// xnu-2422.90.20/osfmk/vm/vm_map.c vm_map_region.
|
||||
mac::ScopedMachSendRight object_name;
|
||||
apple::ScopedMachSendRight object_name;
|
||||
|
||||
kern_return_t kr =
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
mach_vm_region(task, address, size, VM_REGION_TOP_INFO,
|
||||
reinterpret_cast<vm_region_info_t>(info), &info_count,
|
||||
mac::ScopedMachSendRight::Receiver(object_name).get());
|
||||
apple::ScopedMachSendRight::Receiver(object_name).get());
|
||||
#else
|
||||
vm_region_64(task, reinterpret_cast<vm_address_t*>(address),
|
||||
reinterpret_cast<vm_size_t*>(size), VM_REGION_TOP_INFO,
|
||||
reinterpret_cast<vm_region_info_t>(info), &info_count,
|
||||
mac::ScopedMachSendRight::Receiver(object_name).get());
|
||||
apple::ScopedMachSendRight::Receiver(object_name).get());
|
||||
#endif
|
||||
return ParseOutputFromMachVMRegion(kr);
|
||||
}
|
||||
@ -269,19 +269,19 @@ MachVMRegionResult GetBasicInfo(mach_port_t task,
|
||||
// The kernel always returns a null object for VM_REGION_BASIC_INFO_64, but
|
||||
// balance it with a deallocate in case this ever changes. See 10.9.2
|
||||
// xnu-2422.90.20/osfmk/vm/vm_map.c vm_map_region.
|
||||
mac::ScopedMachSendRight object_name;
|
||||
apple::ScopedMachSendRight object_name;
|
||||
|
||||
kern_return_t kr =
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
mach_vm_region(task, address, size, VM_REGION_BASIC_INFO_64,
|
||||
reinterpret_cast<vm_region_info_t>(info), &info_count,
|
||||
mac::ScopedMachSendRight::Receiver(object_name).get());
|
||||
apple::ScopedMachSendRight::Receiver(object_name).get());
|
||||
|
||||
#else
|
||||
vm_region_64(task, reinterpret_cast<vm_address_t*>(address),
|
||||
reinterpret_cast<vm_size_t*>(size), VM_REGION_BASIC_INFO_64,
|
||||
reinterpret_cast<vm_region_info_t>(info), &info_count,
|
||||
mac::ScopedMachSendRight::Receiver(object_name).get());
|
||||
apple::ScopedMachSendRight::Receiver(object_name).get());
|
||||
#endif
|
||||
return ParseOutputFromMachVMRegion(kr);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|
||||
#include <list>
|
||||
@ -203,7 +203,7 @@ class BASE_EXPORT WaitableEvent {
|
||||
friend class RefCountedThreadSafe<ReceiveRight>;
|
||||
~ReceiveRight();
|
||||
|
||||
mac::ScopedMachReceiveRight right_;
|
||||
apple::ScopedMachReceiveRight right_;
|
||||
};
|
||||
|
||||
const ResetPolicy policy_;
|
||||
@ -214,7 +214,7 @@ class BASE_EXPORT WaitableEvent {
|
||||
// The send right used to signal the event. This can be disposed of with
|
||||
// the event, unlike the receive right, since a deleted event cannot be
|
||||
// signaled.
|
||||
mac::ScopedMachSendRight send_right_;
|
||||
apple::ScopedMachSendRight send_right_;
|
||||
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|
||||
// On Windows, you must not close a HANDLE which is currently being waited on.
|
||||
// The MSDN documentation says that the resulting behaviour is 'undefined'.
|
||||
|
@ -178,7 +178,7 @@ size_t WaitableEvent::WaitMany(WaitableEvent** raw_waitables, size_t count) {
|
||||
|
||||
kern_return_t kr;
|
||||
|
||||
mac::ScopedMachPortSet port_set;
|
||||
apple::ScopedMachPortSet port_set;
|
||||
{
|
||||
mach_port_t name;
|
||||
kr =
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/check_op.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/process/process_metrics.h"
|
||||
@ -110,7 +110,7 @@ std::string SysInfo::GetIOSBuildNumber() {
|
||||
uint64_t SysInfo::AmountOfPhysicalMemoryImpl() {
|
||||
struct host_basic_info hostinfo;
|
||||
mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
int result = host_info(host.get(), HOST_BASIC_INFO,
|
||||
reinterpret_cast<host_info_t>(&hostinfo), &count);
|
||||
if (result != KERN_SUCCESS) {
|
||||
|
@ -12,11 +12,11 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/check_op.h"
|
||||
#include "base/debug/stack_trace.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
@ -113,7 +113,7 @@ std::string SysInfo::OperatingSystemArchitecture() {
|
||||
uint64_t SysInfo::AmountOfPhysicalMemoryImpl() {
|
||||
struct host_basic_info hostinfo;
|
||||
mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
int result = host_info(host.get(), HOST_BASIC_INFO,
|
||||
reinterpret_cast<host_info_t>(&hostinfo), &count);
|
||||
if (result != KERN_SUCCESS) {
|
||||
|
@ -15,9 +15,9 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/time/time_override.h"
|
||||
#include "build/build_config.h"
|
||||
|
@ -80,7 +80,7 @@ void MachBootstrapAcceptor::HandleRequest() {
|
||||
pid_t sender_pid = audit_token_to_pid(request.trailer.msgh_audit);
|
||||
|
||||
mojo::PlatformChannelEndpoint remote_endpoint(mojo::PlatformHandle(
|
||||
base::mac::ScopedMachSendRight(request.header.msgh_remote_port)));
|
||||
base::apple::ScopedMachSendRight(request.header.msgh_remote_port)));
|
||||
if (!remote_endpoint.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include <utility>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
#include "base/time/time.h"
|
||||
@ -41,14 +41,14 @@ constexpr base::TimeDelta kLockPollingInterval = base::Seconds(3);
|
||||
//
|
||||
// Returns the receive right if the right was successfully acquired. If the
|
||||
// right cannot be acquired for any reason, returns an invalid right instead.
|
||||
base::mac::ScopedMachReceiveRight TryAcquireReceive(
|
||||
const base::mac::ScopedMachSendRight& bootstrap_right,
|
||||
base::apple::ScopedMachReceiveRight TryAcquireReceive(
|
||||
const base::apple::ScopedMachSendRight& bootstrap_right,
|
||||
const std::string& service_name) {
|
||||
VLOG(2) << __func__;
|
||||
base::mac::ScopedMachReceiveRight target_right;
|
||||
base::apple::ScopedMachReceiveRight target_right;
|
||||
kern_return_t check_in_result = bootstrap_check_in(
|
||||
bootstrap_right.get(), service_name.c_str(),
|
||||
base::mac::ScopedMachReceiveRight::Receiver(target_right).get());
|
||||
base::apple::ScopedMachReceiveRight::Receiver(target_right).get());
|
||||
if (check_in_result != KERN_SUCCESS) {
|
||||
// Log error reports for all errors other than BOOTSTRAP_NOT_PRIVILEGED.
|
||||
// BOOTSTRAP_NOT_PRIVILEGED is not logged because it just means that another
|
||||
@ -60,7 +60,7 @@ base::mac::ScopedMachReceiveRight TryAcquireReceive(
|
||||
BOOTSTRAP_VLOG(2, check_in_result)
|
||||
<< " lock already held: " << service_name;
|
||||
}
|
||||
return base::mac::ScopedMachReceiveRight();
|
||||
return base::apple::ScopedMachReceiveRight();
|
||||
}
|
||||
return target_right;
|
||||
}
|
||||
@ -78,7 +78,7 @@ namespace updater {
|
||||
class ScopedLockImpl {
|
||||
public:
|
||||
// Constructs a ScopedLockImpl from a receive right.
|
||||
explicit ScopedLockImpl(base::mac::ScopedMachReceiveRight receive_right);
|
||||
explicit ScopedLockImpl(base::apple::ScopedMachReceiveRight receive_right);
|
||||
|
||||
// Releases the receive right (and therefore releases the lock).
|
||||
~ScopedLockImpl() = default;
|
||||
@ -89,10 +89,11 @@ class ScopedLockImpl {
|
||||
private:
|
||||
// The Mach port representing the held lock itself. We only care about
|
||||
// service ownership; no messages are transferred with this port.
|
||||
base::mac::ScopedMachReceiveRight receive_right_;
|
||||
base::apple::ScopedMachReceiveRight receive_right_;
|
||||
};
|
||||
|
||||
ScopedLockImpl::ScopedLockImpl(base::mac::ScopedMachReceiveRight receive_right)
|
||||
ScopedLockImpl::ScopedLockImpl(
|
||||
base::apple::ScopedMachReceiveRight receive_right)
|
||||
: receive_right_(std::move(receive_right)) {
|
||||
mach_port_type_t port_type = 0;
|
||||
kern_return_t port_check_result =
|
||||
@ -130,18 +131,18 @@ std::unique_ptr<ScopedLock> ScopedLock::Create(const std::string& name,
|
||||
// when launching a privileged process. It's repeated here so processes
|
||||
// launched via sudo (such as the integration test helper) can reach the
|
||||
// system-scope locks.
|
||||
base::mac::ScopedMachSendRight bootstrap_right =
|
||||
base::mac::RetainMachSendRight(bootstrap_port);
|
||||
base::apple::ScopedMachSendRight bootstrap_right =
|
||||
base::apple::RetainMachSendRight(bootstrap_port);
|
||||
if (!geteuid()) {
|
||||
// Move the initial bootstrap right into `next_right` so the first loop is
|
||||
// not a special case. base::ScopedGeneric calls `abort()` if you `reset` it
|
||||
// to what it already holds, so this has to be a move, not a retain.
|
||||
base::mac::ScopedMachSendRight next_right(bootstrap_right.release());
|
||||
base::apple::ScopedMachSendRight next_right(bootstrap_right.release());
|
||||
while (bootstrap_right.get() != next_right.get()) {
|
||||
bootstrap_right.reset(next_right.release());
|
||||
kern_return_t bootstrap_err = bootstrap_parent(
|
||||
bootstrap_right.get(),
|
||||
base::mac::ScopedMachSendRight::Receiver(next_right).get());
|
||||
base::apple::ScopedMachSendRight::Receiver(next_right).get());
|
||||
if (bootstrap_err != KERN_SUCCESS) {
|
||||
BOOTSTRAP_LOG(ERROR, bootstrap_err)
|
||||
<< "can't bootstrap_parent in ScopedLock::Create (for euid 0)";
|
||||
@ -153,7 +154,7 @@ std::unique_ptr<ScopedLock> ScopedLock::Create(const std::string& name,
|
||||
}
|
||||
|
||||
// Make one try to acquire the lock, even if the timeout is zero or negative.
|
||||
base::mac::ScopedMachReceiveRight receive_right(
|
||||
base::apple::ScopedMachReceiveRight receive_right(
|
||||
TryAcquireReceive(bootstrap_right, service_name.c_str()));
|
||||
|
||||
base::TimeTicks deadline = base::TimeTicks::Now() + timeout;
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
#include "base/apple/dispatch_source_mach.h"
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/mac/scoped_mach_msg_destroy.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/threading/sequence_bound.h"
|
||||
@ -93,7 +93,7 @@ void NamedMojoServerEndpointConnectorMac::HandleRequest() {
|
||||
info->audit_token = request.trailer.msgh_audit;
|
||||
|
||||
mojo::PlatformChannelEndpoint remote_endpoint(mojo::PlatformHandle(
|
||||
base::mac::ScopedMachSendRight(request.header.msgh_remote_port)));
|
||||
base::apple::ScopedMachSendRight(request.header.msgh_remote_port)));
|
||||
if (!remote_endpoint.is_valid()) {
|
||||
LOG(ERROR) << "Endpoint is invalid.";
|
||||
return;
|
||||
|
@ -54,7 +54,7 @@ ChildProcessTaskPortProvider::ChildProcessTaskPortProvider() {
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK(base::mac::CreateMachPort(¬ification_port_, nullptr));
|
||||
CHECK(base::apple::CreateMachPort(¬ification_port_, nullptr));
|
||||
|
||||
const std::string dispatch_name = base::StringPrintf(
|
||||
"%s.ChildProcessTaskPortProvider.%p", base::mac::BaseBundleID(), this);
|
||||
@ -98,15 +98,15 @@ void ChildProcessTaskPortProvider::OnTaskPortReceived(
|
||||
DLOG(ERROR) << "Invalid handle received as task port for pid " << pid;
|
||||
return;
|
||||
}
|
||||
base::mac::ScopedMachSendRight port = task_port.TakeMachSendRight();
|
||||
base::apple::ScopedMachSendRight port = task_port.TakeMachSendRight();
|
||||
|
||||
// Request a notification from the kernel for when the port becomes a dead
|
||||
// name, indicating that the process has died.
|
||||
base::mac::ScopedMachSendRight previous;
|
||||
base::apple::ScopedMachSendRight previous;
|
||||
kern_return_t kr = mach_port_request_notification(
|
||||
mach_task_self(), port.get(), MACH_NOTIFY_DEAD_NAME, 0,
|
||||
notification_port_.get(), MACH_MSG_TYPE_MAKE_SEND_ONCE,
|
||||
base::mac::ScopedMachSendRight::Receiver(previous).get());
|
||||
base::apple::ScopedMachSendRight::Receiver(previous).get());
|
||||
if (kr != KERN_SUCCESS) {
|
||||
// If the argument was invalid, the process is likely already dead.
|
||||
MACH_DVLOG(1, kr) << "mach_port_request_notification";
|
||||
@ -154,7 +154,7 @@ void ChildProcessTaskPortProvider::OnTaskPortDied() {
|
||||
return;
|
||||
|
||||
// Release the DEAD_NAME right.
|
||||
base::mac::ScopedMachSendRight dead_port(notification.not_port);
|
||||
base::apple::ScopedMachSendRight dead_port(notification.not_port);
|
||||
|
||||
base::AutoLock lock(lock_);
|
||||
base::EraseIf(pid_to_task_port_, [&dead_port](const auto& pair) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <map>
|
||||
|
||||
#include "base/apple/dispatch_source_mach.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/process/port_provider_mac.h"
|
||||
#include "base/process/process_handle.h"
|
||||
@ -73,13 +73,13 @@ class CONTENT_EXPORT ChildProcessTaskPortProvider : public base::PortProvider {
|
||||
|
||||
// Maps a PID to the corresponding task port.
|
||||
using PidToTaskPortMap =
|
||||
std::map<base::ProcessHandle, base::mac::ScopedMachSendRight>;
|
||||
std::map<base::ProcessHandle, base::apple::ScopedMachSendRight>;
|
||||
PidToTaskPortMap pid_to_task_port_;
|
||||
|
||||
// A Mach port that is used to register for dead name notifications from
|
||||
// the kernel. All the ports in |pid_to_task_port_| have a notification set
|
||||
// up to send to this port.
|
||||
base::mac::ScopedMachReceiveRight notification_port_;
|
||||
base::apple::ScopedMachReceiveRight notification_port_;
|
||||
|
||||
// Dispatch source for |notification_port_|.
|
||||
std::unique_ptr<base::DispatchSourceMach> notification_source_;
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/clang_profiling_buildflags.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "base/test/task_environment.h"
|
||||
@ -122,9 +122,9 @@ TEST_F(ChildProcessTaskPortProviderTest, ChildLifecycle) {
|
||||
EXPECT_EQ(kMachPortNull, provider()->TaskForPid(99));
|
||||
|
||||
// Create a fake task port for the fake process.
|
||||
base::mac::ScopedMachReceiveRight receive_right;
|
||||
base::mac::ScopedMachSendRight send_right;
|
||||
ASSERT_TRUE(base::mac::CreateMachPort(&receive_right, &send_right));
|
||||
base::apple::ScopedMachReceiveRight receive_right;
|
||||
base::apple::ScopedMachSendRight send_right;
|
||||
ASSERT_TRUE(base::apple::CreateMachPort(&receive_right, &send_right));
|
||||
|
||||
EXPECT_EQ(1u, GetSendRightRefCount(send_right.get()));
|
||||
EXPECT_EQ(0u, GetDeadNameRefCount(send_right.get()));
|
||||
@ -135,7 +135,7 @@ TEST_F(ChildProcessTaskPortProviderTest, ChildLifecycle) {
|
||||
.WillOnce(WithArgs<0>(
|
||||
[&send_right](mojom::ChildProcess::GetTaskPortCallback callback) {
|
||||
std::move(callback).Run(mojo::PlatformHandle(
|
||||
base::mac::RetainMachSendRight(send_right.get())));
|
||||
base::apple::RetainMachSendRight(send_right.get())));
|
||||
}));
|
||||
|
||||
provider()->OnChildProcessLaunched(99, &child_process);
|
||||
@ -169,9 +169,9 @@ TEST_F(ChildProcessTaskPortProviderTest, DeadTaskPort) {
|
||||
EXPECT_EQ(kMachPortNull, provider()->TaskForPid(6));
|
||||
|
||||
// Create a fake task port for the fake process.
|
||||
base::mac::ScopedMachReceiveRight receive_right;
|
||||
base::mac::ScopedMachSendRight send_right;
|
||||
ASSERT_TRUE(base::mac::CreateMachPort(&receive_right, &send_right));
|
||||
base::apple::ScopedMachReceiveRight receive_right;
|
||||
base::apple::ScopedMachSendRight send_right;
|
||||
ASSERT_TRUE(base::apple::CreateMachPort(&receive_right, &send_right));
|
||||
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
||||
base::ThreadPool::CreateSequencedTaskRunner({});
|
||||
@ -182,12 +182,12 @@ TEST_F(ChildProcessTaskPortProviderTest, DeadTaskPort) {
|
||||
WithArgs<0>([&task_runner, &receive_right, &send_right](
|
||||
mojom::ChildProcess::GetTaskPortCallback callback) {
|
||||
mojo::PlatformHandle mach_handle(
|
||||
base::mac::RetainMachSendRight(send_right.get()));
|
||||
base::apple::RetainMachSendRight(send_right.get()));
|
||||
|
||||
// Destroy the receive right.
|
||||
task_runner->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&base::mac::ScopedMachReceiveRight::reset,
|
||||
base::BindOnce(&base::apple::ScopedMachReceiveRight::reset,
|
||||
base::Unretained(&receive_right),
|
||||
kMachPortNull));
|
||||
// And then return a send right to the now-dead name.
|
||||
@ -199,9 +199,9 @@ TEST_F(ChildProcessTaskPortProviderTest, DeadTaskPort) {
|
||||
provider()->OnChildProcessLaunched(6, &child_process);
|
||||
|
||||
// Create a second fake process.
|
||||
base::mac::ScopedMachReceiveRight receive_right2;
|
||||
base::mac::ScopedMachSendRight send_right2;
|
||||
ASSERT_TRUE(base::mac::CreateMachPort(&receive_right2, &send_right2));
|
||||
base::apple::ScopedMachReceiveRight receive_right2;
|
||||
base::apple::ScopedMachSendRight send_right2;
|
||||
ASSERT_TRUE(base::apple::CreateMachPort(&receive_right2, &send_right2));
|
||||
|
||||
MockChildProcess child_contol2;
|
||||
EXPECT_CALL(child_contol2, GetTaskPort(_))
|
||||
@ -213,7 +213,7 @@ TEST_F(ChildProcessTaskPortProviderTest, DeadTaskPort) {
|
||||
base::BindOnce(
|
||||
std::move(callback),
|
||||
mojo::PlatformHandle(
|
||||
base::mac::RetainMachSendRight(send_right2.get()))));
|
||||
base::apple::RetainMachSendRight(send_right2.get()))));
|
||||
}));
|
||||
|
||||
provider()->OnChildProcessLaunched(123, &child_contol2);
|
||||
@ -239,9 +239,9 @@ TEST_F(ChildProcessTaskPortProviderTest, ReplacePort) {
|
||||
EXPECT_EQ(kMachPortNull, provider()->TaskForPid(42));
|
||||
|
||||
// Create a fake task port for the fake process.
|
||||
base::mac::ScopedMachReceiveRight receive_right;
|
||||
base::mac::ScopedMachSendRight send_right;
|
||||
ASSERT_TRUE(base::mac::CreateMachPort(&receive_right, &send_right));
|
||||
base::apple::ScopedMachReceiveRight receive_right;
|
||||
base::apple::ScopedMachSendRight send_right;
|
||||
ASSERT_TRUE(base::apple::CreateMachPort(&receive_right, &send_right));
|
||||
|
||||
EXPECT_EQ(1u, GetSendRightRefCount(send_right.get()));
|
||||
EXPECT_EQ(0u, GetDeadNameRefCount(send_right.get()));
|
||||
@ -253,7 +253,7 @@ TEST_F(ChildProcessTaskPortProviderTest, ReplacePort) {
|
||||
.WillRepeatedly(WithArgs<0>(
|
||||
[&receive_right](mojom::ChildProcess::GetTaskPortCallback callback) {
|
||||
std::move(callback).Run(mojo::PlatformHandle(
|
||||
base::mac::RetainMachSendRight(receive_right.get())));
|
||||
base::apple::RetainMachSendRight(receive_right.get())));
|
||||
}));
|
||||
|
||||
provider()->OnChildProcessLaunched(42, &child_process);
|
||||
@ -274,9 +274,9 @@ TEST_F(ChildProcessTaskPortProviderTest, ReplacePort) {
|
||||
EXPECT_EQ(receive_right.get(), provider()->TaskForPid(42));
|
||||
|
||||
// Now simulate PID reuse by replacing the task port with a new one.
|
||||
base::mac::ScopedMachReceiveRight receive_right2;
|
||||
base::mac::ScopedMachSendRight send_right2;
|
||||
ASSERT_TRUE(base::mac::CreateMachPort(&receive_right2, &send_right2));
|
||||
base::apple::ScopedMachReceiveRight receive_right2;
|
||||
base::apple::ScopedMachSendRight send_right2;
|
||||
ASSERT_TRUE(base::apple::CreateMachPort(&receive_right2, &send_right2));
|
||||
EXPECT_EQ(1u, GetSendRightRefCount(send_right2.get()));
|
||||
|
||||
MockChildProcess child_process2;
|
||||
@ -284,7 +284,7 @@ TEST_F(ChildProcessTaskPortProviderTest, ReplacePort) {
|
||||
.WillOnce(
|
||||
[&send_right2](mojom::ChildProcess::GetTaskPortCallback callback) {
|
||||
std::move(callback).Run(mojo::PlatformHandle(
|
||||
base::mac::RetainMachSendRight(send_right2.get())));
|
||||
base::apple::RetainMachSendRight(send_right2.get())));
|
||||
});
|
||||
|
||||
provider()->OnChildProcessLaunched(42, &child_process2);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/time/time.h"
|
||||
|
||||
namespace content {
|
||||
@ -25,7 +25,7 @@ class SwapMetricsDriverImplMac : public SwapMetricsDriverImpl {
|
||||
base::TimeDelta interval) override;
|
||||
|
||||
private:
|
||||
base::mac::ScopedMachSendRight host_;
|
||||
base::apple::ScopedMachSendRight host_;
|
||||
|
||||
uint64_t last_swapins_ = 0;
|
||||
uint64_t last_swapouts_ = 0;
|
||||
|
@ -302,7 +302,7 @@ class ChildThreadImpl::IOThreadState
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
void GetTaskPort(GetTaskPortCallback callback) override {
|
||||
mojo::PlatformHandle task_port(
|
||||
(base::mac::ScopedMachSendRight(task_self_trap())));
|
||||
(base::apple::ScopedMachSendRight(task_self_trap())));
|
||||
std::move(callback).Run(std::move(task_port));
|
||||
}
|
||||
#endif
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#include <mach/mach_host.h>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/system/sys_info.h"
|
||||
|
||||
namespace extensions {
|
||||
@ -27,7 +27,7 @@ bool CpuInfoProvider::QueryCpuTimePerProcessor(
|
||||
DCHECK(infos);
|
||||
|
||||
natural_t num_of_processors;
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
mach_msg_type_number_t type;
|
||||
processor_cpu_load_info_data_t* cpu_infos;
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/process/process_metrics.h"
|
||||
#include "build/build_config.h"
|
||||
@ -37,7 +37,7 @@ namespace memory_util {
|
||||
uint64_t GetFreePhysicalBytes() {
|
||||
vm_statistics_data_t vmstat;
|
||||
mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
kern_return_t result = host_statistics(
|
||||
host.get(), HOST_VM_INFO, reinterpret_cast<host_info_t>(&vmstat), &count);
|
||||
if (result != KERN_SUCCESS) {
|
||||
|
@ -956,7 +956,7 @@ void ParamTraits<base::subtle::PlatformSharedMemoryRegion>::Write(
|
||||
zx::vmo vmo = const_cast<param_type&>(p).PassPlatformHandle();
|
||||
WriteParam(m, vmo);
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedMachSendRight h =
|
||||
base::apple::ScopedMachSendRight h =
|
||||
const_cast<param_type&>(p).PassPlatformHandle();
|
||||
MachPortMac mach_port_mac(h.get());
|
||||
WriteParam(m, mach_port_mac);
|
||||
@ -1014,8 +1014,8 @@ bool ParamTraits<base::subtle::PlatformSharedMemoryRegion>::Read(
|
||||
if (!ReadParam(m, iter, &mach_port_mac))
|
||||
return false;
|
||||
*r = base::subtle::PlatformSharedMemoryRegion::Take(
|
||||
base::mac::ScopedMachSendRight(mach_port_mac.get_mach_port()), mode, size,
|
||||
guid);
|
||||
base::apple::ScopedMachSendRight(mach_port_mac.get_mach_port()), mode,
|
||||
size, guid);
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
scoped_refptr<base::Pickle::Attachment> attachment;
|
||||
if (!m->ReadAttachment(iter, &attachment))
|
||||
|
@ -10,12 +10,12 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/apple/osstatus_logging.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/metrics/histogram_functions.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/strings/strcat.h"
|
||||
|
@ -15,13 +15,13 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/containers/buffer_iterator.h"
|
||||
#include "base/containers/circular_deque.h"
|
||||
#include "base/containers/span.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/scoped_mach_msg_destroy.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/mac/scoped_mach_vm.h"
|
||||
#include "base/message_loop/message_pump_for_io.h"
|
||||
#include "base/task/current_thread.h"
|
||||
@ -197,8 +197,8 @@ class ChannelMac : public Channel,
|
||||
// establishes the bidirectional communication channel.
|
||||
if (send_port_ != MACH_PORT_NULL) {
|
||||
DCHECK(receive_port_ == MACH_PORT_NULL);
|
||||
CHECK(base::mac::CreateMachPort(&receive_port_, nullptr,
|
||||
MACH_PORT_QLIMIT_LARGE));
|
||||
CHECK(base::apple::CreateMachPort(&receive_port_, nullptr,
|
||||
MACH_PORT_QLIMIT_LARGE));
|
||||
if (!RequestSendDeadNameNotification()) {
|
||||
OnError(Error::kConnectionFailed);
|
||||
return;
|
||||
@ -245,11 +245,11 @@ class ChannelMac : public Channel,
|
||||
// connected to |send_port_| becomes a dead name. This should be called as
|
||||
// soon as the Channel establishes both the send and receive ports.
|
||||
bool RequestSendDeadNameNotification() {
|
||||
base::mac::ScopedMachSendRight previous;
|
||||
base::apple::ScopedMachSendRight previous;
|
||||
kern_return_t kr = mach_port_request_notification(
|
||||
mach_task_self(), send_port_.get(), MACH_NOTIFY_DEAD_NAME, 0,
|
||||
receive_port_.get(), MACH_MSG_TYPE_MAKE_SEND_ONCE,
|
||||
base::mac::ScopedMachSendRight::Receiver(previous).get());
|
||||
base::apple::ScopedMachSendRight::Receiver(previous).get());
|
||||
if (kr != KERN_SUCCESS) {
|
||||
// If port is already a dead name (i.e. the receiver is already gone),
|
||||
// then the channel should be shut down by the caller.
|
||||
@ -306,7 +306,7 @@ class ChannelMac : public Channel,
|
||||
return false;
|
||||
}
|
||||
|
||||
send_port_ = base::mac::ScopedMachSendRight(message->msgh_remote_port);
|
||||
send_port_ = base::apple::ScopedMachSendRight(message->msgh_remote_port);
|
||||
|
||||
if (!RequestSendDeadNameNotification()) {
|
||||
send_port_.reset();
|
||||
@ -559,7 +559,7 @@ class ChannelMac : public Channel,
|
||||
sizeof(audit_token_t)) == 0) {
|
||||
DCHECK(notification->not_port == send_port_);
|
||||
// Release the notification's send right using this scoper.
|
||||
base::mac::ScopedMachSendRight notify_port(notification->not_port);
|
||||
base::apple::ScopedMachSendRight notify_port(notification->not_port);
|
||||
}
|
||||
OnError(Error::kDisconnected);
|
||||
return;
|
||||
@ -633,12 +633,12 @@ class ChannelMac : public Channel,
|
||||
switch (descriptor.disposition) {
|
||||
case MACH_MSG_TYPE_MOVE_SEND:
|
||||
incoming_handles_.emplace_back(
|
||||
base::mac::ScopedMachSendRight(descriptor.name));
|
||||
base::apple::ScopedMachSendRight(descriptor.name));
|
||||
descriptor.name = MACH_PORT_NULL;
|
||||
break;
|
||||
case MACH_MSG_TYPE_MOVE_RECEIVE:
|
||||
incoming_handles_.emplace_back(
|
||||
base::mac::ScopedMachReceiveRight(descriptor.name));
|
||||
base::apple::ScopedMachReceiveRight(descriptor.name));
|
||||
descriptor.name = MACH_PORT_NULL;
|
||||
break;
|
||||
default:
|
||||
@ -698,8 +698,8 @@ class ChannelMac : public Channel,
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
|
||||
|
||||
base::mac::ScopedMachReceiveRight receive_port_;
|
||||
base::mac::ScopedMachSendRight send_port_;
|
||||
base::apple::ScopedMachReceiveRight receive_port_;
|
||||
base::apple::ScopedMachSendRight send_port_;
|
||||
|
||||
// Whether to leak the above Mach ports when the channel is shut down.
|
||||
bool leak_handles_ = false;
|
||||
|
@ -649,7 +649,7 @@ TEST(ChannelTest, SendToDeadMachPortName) {
|
||||
get_send_name_refs();
|
||||
EXPECT_EQ(2u, send);
|
||||
EXPECT_EQ(0u, dead);
|
||||
base::mac::ScopedMachSendRight extra_send(send_name);
|
||||
base::apple::ScopedMachSendRight extra_send(send_name);
|
||||
|
||||
// Channel A gets created with the Mach send right from |platform_channel|.
|
||||
CallbackChannelDelegate delegate_a;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <mach/mach.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#endif
|
||||
|
||||
namespace mojo::core::ipcz_driver {
|
||||
@ -92,9 +92,9 @@ int fileport_makefd(mach_port_t);
|
||||
} // extern "C"
|
||||
|
||||
PlatformHandle MakeFDTransmissible(base::ScopedFD fd) {
|
||||
base::mac::ScopedMachSendRight port;
|
||||
base::apple::ScopedMachSendRight port;
|
||||
kern_return_t kr = fileport_makeport(
|
||||
fd.get(), base::mac::ScopedMachSendRight::Receiver(port).get());
|
||||
fd.get(), base::apple::ScopedMachSendRight::Receiver(port).get());
|
||||
if (kr != KERN_SUCCESS) {
|
||||
MACH_LOG(ERROR, kr) << "fileport_makeport";
|
||||
return {};
|
||||
|
@ -18,7 +18,7 @@
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#endif
|
||||
|
||||
namespace mojo {
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <windows.h>
|
||||
#include "base/win/scoped_handle.h"
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
@ -214,8 +214,8 @@ DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ReadPlatformSharedBuffer,
|
||||
auto platform_handle = zx::vmo(static_cast<zx_handle_t>(os_buffer.value));
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT, os_buffer.type);
|
||||
auto platform_handle =
|
||||
base::mac::ScopedMachSendRight(static_cast<mach_port_t>(os_buffer.value));
|
||||
auto platform_handle = base::apple::ScopedMachSendRight(
|
||||
static_cast<mach_port_t>(os_buffer.value));
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR, os_buffer.type);
|
||||
auto platform_handle = base::ScopedFD(static_cast<int>(os_buffer.value));
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <servers/bootstrap.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "mojo/public/cpp/platform/platform_channel.h"
|
||||
@ -36,10 +36,10 @@ PlatformChannelServerEndpoint NamedPlatformChannel::CreateServerEndpoint(
|
||||
DCHECK_LT(bootstrap_name.length(),
|
||||
static_cast<size_t>(BOOTSTRAP_MAX_NAME_LEN));
|
||||
|
||||
base::mac::ScopedMachReceiveRight receive_right;
|
||||
base::apple::ScopedMachReceiveRight receive_right;
|
||||
kern_return_t kr = bootstrap_check_in(
|
||||
bootstrap_port, bootstrap_name.c_str(),
|
||||
base::mac::ScopedMachReceiveRight::Receiver(receive_right).get());
|
||||
base::apple::ScopedMachReceiveRight::Receiver(receive_right).get());
|
||||
if (kr != KERN_SUCCESS) {
|
||||
BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_check_in " << bootstrap_name;
|
||||
return PlatformChannelServerEndpoint();
|
||||
@ -61,10 +61,10 @@ PlatformChannelServerEndpoint NamedPlatformChannel::CreateServerEndpoint(
|
||||
// static
|
||||
PlatformChannelEndpoint NamedPlatformChannel::CreateClientEndpoint(
|
||||
const Options& options) {
|
||||
base::mac::ScopedMachSendRight send_right;
|
||||
base::apple::ScopedMachSendRight send_right;
|
||||
kern_return_t kr = bootstrap_look_up(
|
||||
bootstrap_port, options.server_name.c_str(),
|
||||
base::mac::ScopedMachSendRight::Receiver(send_right).get());
|
||||
base::apple::ScopedMachSendRight::Receiver(send_right).get());
|
||||
if (kr != KERN_SUCCESS) {
|
||||
BOOTSTRAP_VLOG(1, kr) << "bootstrap_look_up " << options.server_name;
|
||||
return PlatformChannelEndpoint();
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <mach/port.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_NACL)
|
||||
@ -110,11 +110,11 @@ void CreateChannel(PlatformHandle* local_endpoint,
|
||||
// handshake with its peer to establish two sets of Mach receive and send
|
||||
// rights. The handshake process starts with the creation of one
|
||||
// PlatformChannel endpoint.
|
||||
base::mac::ScopedMachReceiveRight receive;
|
||||
base::mac::ScopedMachSendRight send;
|
||||
base::apple::ScopedMachReceiveRight receive;
|
||||
base::apple::ScopedMachSendRight send;
|
||||
// The mpl_qlimit specified here should stay in sync with
|
||||
// NamedPlatformChannel.
|
||||
CHECK(base::mac::CreateMachPort(&receive, &send, MACH_PORT_QLIMIT_LARGE));
|
||||
CHECK(base::apple::CreateMachPort(&receive, &send, MACH_PORT_QLIMIT_LARGE));
|
||||
|
||||
// In a reverse of Mach messaging semantics, in Mojo the "local" endpoint is
|
||||
// the send right, while the "remote" end is the receive right.
|
||||
|
@ -18,8 +18,8 @@
|
||||
#if BUILDFLAG(MOJO_USE_APPLE_CHANNEL)
|
||||
#include <mach/port.h>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/mac/mach_port_rendezvous.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
#include <lib/zx/handle.h>
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
@ -102,7 +102,7 @@ void PlatformChannelEndpoint::PrepareToPass(HandlePassingInfo& info,
|
||||
value = base::NumberToString(mapped_fd);
|
||||
#elif BUILDFLAG(MOJO_USE_APPLE_CHANNEL)
|
||||
DCHECK(platform_handle().is_mach_receive());
|
||||
base::mac::ScopedMachReceiveRight receive_right =
|
||||
base::apple::ScopedMachReceiveRight receive_right =
|
||||
TakePlatformHandle().TakeMachReceiveRight();
|
||||
base::MachPortsForRendezvous::key_type rendezvous_key = 0;
|
||||
do {
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <mach/vm_map.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
@ -72,17 +72,17 @@ zx::handle CloneHandle(const zx::handle& handle) {
|
||||
return std::move(dupe);
|
||||
}
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedMachSendRight CloneMachPort(
|
||||
const base::mac::ScopedMachSendRight& mach_port) {
|
||||
base::apple::ScopedMachSendRight CloneMachPort(
|
||||
const base::apple::ScopedMachSendRight& mach_port) {
|
||||
DCHECK(mach_port.is_valid());
|
||||
|
||||
kern_return_t kr = mach_port_mod_refs(mach_task_self(), mach_port.get(),
|
||||
MACH_PORT_RIGHT_SEND, 1);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
MACH_DLOG(ERROR, kr) << "mach_port_mod_refs";
|
||||
return base::mac::ScopedMachSendRight();
|
||||
return base::apple::ScopedMachSendRight();
|
||||
}
|
||||
return base::mac::ScopedMachSendRight(mach_port.get());
|
||||
return base::apple::ScopedMachSendRight(mach_port.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -108,9 +108,9 @@ PlatformHandle::PlatformHandle(base::win::ScopedHandle handle)
|
||||
PlatformHandle::PlatformHandle(zx::handle handle)
|
||||
: type_(Type::kHandle), handle_(std::move(handle)) {}
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
PlatformHandle::PlatformHandle(base::mac::ScopedMachSendRight mach_port)
|
||||
PlatformHandle::PlatformHandle(base::apple::ScopedMachSendRight mach_port)
|
||||
: type_(Type::kMachSend), mach_send_(std::move(mach_port)) {}
|
||||
PlatformHandle::PlatformHandle(base::mac::ScopedMachReceiveRight mach_port)
|
||||
PlatformHandle::PlatformHandle(base::apple::ScopedMachReceiveRight mach_port)
|
||||
: type_(Type::kMachReceive), mach_receive_(std::move(mach_port)) {}
|
||||
#endif
|
||||
|
||||
@ -210,10 +210,10 @@ PlatformHandle PlatformHandle::FromMojoPlatformHandle(
|
||||
return PlatformHandle(zx::handle(handle->value));
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
if (handle->type == MOJO_PLATFORM_HANDLE_TYPE_MACH_SEND_RIGHT) {
|
||||
return PlatformHandle(base::mac::ScopedMachSendRight(
|
||||
return PlatformHandle(base::apple::ScopedMachSendRight(
|
||||
static_cast<mach_port_t>(handle->value)));
|
||||
} else if (handle->type == MOJO_PLATFORM_HANDLE_TYPE_MACH_RECEIVE_RIGHT) {
|
||||
return PlatformHandle(base::mac::ScopedMachReceiveRight(
|
||||
return PlatformHandle(base::apple::ScopedMachReceiveRight(
|
||||
static_cast<mach_port_t>(handle->value)));
|
||||
}
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
#include <lib/zx/handle.h>
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|
||||
@ -62,8 +62,8 @@ class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformHandle {
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
explicit PlatformHandle(zx::handle handle);
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
explicit PlatformHandle(base::mac::ScopedMachSendRight mach_port);
|
||||
explicit PlatformHandle(base::mac::ScopedMachReceiveRight mach_port);
|
||||
explicit PlatformHandle(base::apple::ScopedMachSendRight mach_port);
|
||||
explicit PlatformHandle(base::apple::ScopedMachReceiveRight mach_port);
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|
||||
@ -140,10 +140,10 @@ class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformHandle {
|
||||
|
||||
bool is_valid_mach_send() const { return mach_send_.is_valid(); }
|
||||
bool is_mach_send() const { return type_ == Type::kMachSend; }
|
||||
const base::mac::ScopedMachSendRight& GetMachSendRight() const {
|
||||
const base::apple::ScopedMachSendRight& GetMachSendRight() const {
|
||||
return mach_send_;
|
||||
}
|
||||
base::mac::ScopedMachSendRight TakeMachSendRight() {
|
||||
base::apple::ScopedMachSendRight TakeMachSendRight() {
|
||||
if (type_ == Type::kMachSend)
|
||||
type_ = Type::kNone;
|
||||
return std::move(mach_send_);
|
||||
@ -154,10 +154,10 @@ class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformHandle {
|
||||
|
||||
bool is_valid_mach_receive() const { return mach_receive_.is_valid(); }
|
||||
bool is_mach_receive() const { return type_ == Type::kMachReceive; }
|
||||
const base::mac::ScopedMachReceiveRight& GetMachReceiveRight() const {
|
||||
const base::apple::ScopedMachReceiveRight& GetMachReceiveRight() const {
|
||||
return mach_receive_;
|
||||
}
|
||||
base::mac::ScopedMachReceiveRight TakeMachReceiveRight() {
|
||||
base::apple::ScopedMachReceiveRight TakeMachReceiveRight() {
|
||||
if (type_ == Type::kMachReceive)
|
||||
type_ = Type::kNone;
|
||||
return std::move(mach_receive_);
|
||||
@ -223,8 +223,8 @@ class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformHandle {
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
zx::handle handle_;
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedMachSendRight mach_send_;
|
||||
base::mac::ScopedMachReceiveRight mach_receive_;
|
||||
base::apple::ScopedMachSendRight mach_send_;
|
||||
base::apple::ScopedMachReceiveRight mach_receive_;
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <mach/mach_host.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/mac/scoped_mach_vm.h"
|
||||
#include "base/system/sys_info.h"
|
||||
#include "services/device/compute_pressure/core_times.h"
|
||||
@ -36,7 +36,7 @@ bool HostProcessorInfoScanner::Update() {
|
||||
}
|
||||
|
||||
natural_t number_of_processors;
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
mach_msg_type_number_t type;
|
||||
processor_cpu_load_info_data_t* cpu_infos;
|
||||
|
||||
|
@ -44,7 +44,7 @@ SendablePort ConvertPort(const MachPortType& port_proto) {
|
||||
SendablePort port;
|
||||
kern_return_t kr = mach_port_allocate(
|
||||
mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
|
||||
base::mac::ScopedMachReceiveRight::Receiver(port.receive_right).get());
|
||||
base::apple::ScopedMachReceiveRight::Receiver(port.receive_right).get());
|
||||
MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_port_allocate";
|
||||
|
||||
port.name = port.receive_right.get();
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "testing/libfuzzer/fuzzers/mach/mach_message.pb.h"
|
||||
|
||||
@ -23,8 +23,8 @@ struct SendablePort {
|
||||
mach_msg_type_name_t disposition = 0;
|
||||
MachPortType proto_type = static_cast<MachPortType>(-1);
|
||||
|
||||
base::mac::ScopedMachSendRight send_right;
|
||||
base::mac::ScopedMachReceiveRight receive_right;
|
||||
base::apple::ScopedMachSendRight send_right;
|
||||
base::apple::ScopedMachReceiveRight receive_right;
|
||||
};
|
||||
|
||||
// Holds the buffer allocation and port references for a message to be sent.
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <mach/mach_vm.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/time/time.h"
|
||||
#include "tools/memory/simulator/utils.h"
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
#include "base/apple/mach_logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/apple/scoped_mach_port.h"
|
||||
#include "base/time/time.h"
|
||||
#include "tools/memory/simulator/utils.h"
|
||||
|
||||
@ -50,7 +50,7 @@ std::map<std::string, double> SystemMetricsProviderMac::GetMetricValues(
|
||||
|
||||
struct host_basic_info hostinfo;
|
||||
mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
|
||||
base::mac::ScopedMachSendRight host(mach_host_self());
|
||||
base::apple::ScopedMachSendRight host(mach_host_self());
|
||||
int result = host_info(host.get(), HOST_BASIC_INFO,
|
||||
reinterpret_cast<host_info_t>(&hostinfo), &count);
|
||||
CHECK_EQ(result, KERN_SUCCESS);
|
||||
|
@ -45,7 +45,7 @@ gfx::mojom::GpuMemoryBufferPlatformHandlePtr StructTraits<
|
||||
IOSurfaceCreateMachPort(handle.io_surface.get()));
|
||||
return gfx::mojom::GpuMemoryBufferPlatformHandle::NewMachPort(
|
||||
mojo::PlatformHandle(
|
||||
base::mac::RetainMachSendRight(io_surface_mach_port.get())));
|
||||
base::apple::RetainMachSendRight(io_surface_mach_port.get())));
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
|
@ -17,7 +17,7 @@ StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>::content(
|
||||
if (ca_layer_params.io_surface_mach_port) {
|
||||
DCHECK(!ca_layer_params.ca_context_id);
|
||||
return gfx::mojom::CALayerContent::NewIoSurfaceMachPort(
|
||||
mojo::PlatformHandle(base::mac::RetainMachSendRight(
|
||||
mojo::PlatformHandle(base::apple::RetainMachSendRight(
|
||||
ca_layer_params.io_surface_mach_port.get())));
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user