| Index: ipc/attachment_broker_privileged.cc
|
| diff --git a/ipc/attachment_broker_privileged.cc b/ipc/attachment_broker_privileged.cc
|
| index 2b14217b7c352e40e973448a3b84c1ea1798e46e..85c1ac949cd858704effd0cb8dba4b4cb6ffefaf 100644
|
| --- a/ipc/attachment_broker_privileged.cc
|
| +++ b/ipc/attachment_broker_privileged.cc
|
| @@ -16,6 +16,9 @@
|
| #endif
|
|
|
| #if defined(OS_MACOSX) && !defined(OS_IOS)
|
| +#include <mach/mach.h>
|
| +
|
| +#include "base/process/port_provider_mac.h"
|
| #include "ipc/attachment_broker_privileged_mac.h"
|
| #endif
|
|
|
| @@ -24,6 +27,19 @@ namespace IPC {
|
| namespace {
|
|
|
| #if defined(OS_MACOSX) && !defined(OS_IOS)
|
| +
|
| +// A fake port provider that does nothing. Intended for single process unit
|
| +// tests.
|
| +class FakePortProvider : public base::PortProvider {
|
| + mach_port_t TaskForPid(base::ProcessHandle process) const override {
|
| + DCHECK_EQ(process, getpid());
|
| + return mach_task_self();
|
| + }
|
| +};
|
| +
|
| +base::LazyInstance<FakePortProvider>::Leaky
|
| + g_fake_port_provider = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| // Passed as a constructor parameter to AttachmentBrokerPrivilegedMac.
|
| base::PortProvider* g_port_provider = nullptr;
|
| #endif // defined(OS_MACOSX) && !defined(OS_IOS)
|
| @@ -86,6 +102,15 @@ void AttachmentBrokerPrivileged::CreateBrokerIfNeeded() {
|
| }
|
| #endif // defined(OS_MACOSX) && !defined(OS_IOS)
|
|
|
| +// static
|
| +void AttachmentBrokerPrivileged::CreateBrokerForSingleProcessTests() {
|
| +#if defined(OS_MACOSX) && !defined(OS_IOS)
|
| + CreateBrokerIfNeeded(&g_fake_port_provider.Get());
|
| +#else
|
| + CreateBrokerIfNeeded();
|
| +#endif // defined(OS_MACOSX) && !defined(OS_IOS)
|
| +}
|
| +
|
| void AttachmentBrokerPrivileged::RegisterCommunicationChannel(
|
| Endpoint* endpoint) {
|
| base::AutoLock auto_lock(*get_lock());
|
|
|