summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2015-12-29 15:42:18 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-29 23:43:33 +0000
commit9e1ffaa2e70f528ac6f879d5074954c1a4b96cb5 (patch)
treed5de9d7630dbffcac9d00c8f750c6b7bd8afcccd /ipc
parent6ccca5659c74bed2a307cde209f2579fc2554db9 (diff)
downloadchromium_src-9e1ffaa2e70f528ac6f879d5074954c1a4b96cb5.zip
chromium_src-9e1ffaa2e70f528ac6f879d5074954c1a4b96cb5.tar.gz
chromium_src-9e1ffaa2e70f528ac6f879d5074954c1a4b96cb5.tar.bz2
Remoting: Remove references to POSIX shared memory.
https://codereview.chromium.org/1509723003/ removed all dependencies on the implementation of shared memory. This CL removes the remaining references. BUG=547247 Review URL: https://codereview.chromium.org/1509063003 Cr-Commit-Position: refs/heads/master@{#367117}
Diffstat (limited to 'ipc')
-rw-r--r--ipc/attachment_broker_privileged.cc25
-rw-r--r--ipc/attachment_broker_privileged.h5
2 files changed, 30 insertions, 0 deletions
diff --git a/ipc/attachment_broker_privileged.cc b/ipc/attachment_broker_privileged.cc
index 2b14217..85c1ac9 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());
diff --git a/ipc/attachment_broker_privileged.h b/ipc/attachment_broker_privileged.h
index ec600b7..686bb9d 100644
--- a/ipc/attachment_broker_privileged.h
+++ b/ipc/attachment_broker_privileged.h
@@ -42,6 +42,11 @@ class IPC_EXPORT AttachmentBrokerPrivileged : public IPC::AttachmentBroker {
static void CreateBrokerIfNeeded();
#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+ // Similar to CreateBrokerIfNeeded(), but useful for single process unit tests
+ // that don't need real attachment brokering, and don't want to deal with
+ // setting up a fake PortProvider.
+ static void CreateBrokerForSingleProcessTests();
+
// AttachmentBroker overrides.
void RegisterCommunicationChannel(Endpoint* endpoint) override;
void DeregisterCommunicationChannel(Endpoint* endpoint) override;