summaryrefslogtreecommitdiffstats
path: root/chrome/common/ipc_channel_handle.h
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-19 20:50:09 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-19 20:50:09 +0000
commit255a9f6c6f6db2a95fec78c6c2f2c504c655e733 (patch)
tree471d21ae7e41cc2e33a491a5309b3ea77430ebca /chrome/common/ipc_channel_handle.h
parent04b74d13d927794495a1a3a1b89d67f85a104e12 (diff)
downloadchromium_src-255a9f6c6f6db2a95fec78c6c2f2c504c655e733.zip
chromium_src-255a9f6c6f6db2a95fec78c6c2f2c504c655e733.tar.gz
chromium_src-255a9f6c6f6db2a95fec78c6c2f2c504c655e733.tar.bz2
posix: two related changes to make plugin IPC work on POSIX.
* use a new ChannelHandle type when passing IPC channels over IPC The current POSIX code assumes that one end of a channel is always a new child process (a renderer). For plugins we need to be able to construct channels between each of the browser, plugin, and renderer. This change augments the messages related to creating channels to allow passing in a base::FileDescriptor containing the socket. The intent is that the browser process, as the initial interchange between plugin and renderer, creates the socketpair() on their behalf and hands each their respective end of the connection. * register channel endpoint names in the global pipe map The plugin code assumes it can map from a string to a channel endpoint at basically any time. So whenever we get a channel endpoint over IPC, we install it in a global map of channel endpoints. Review URL: http://codereview.chromium.org/113157 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_channel_handle.h')
-rw-r--r--chrome/common/ipc_channel_handle.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/common/ipc_channel_handle.h b/chrome/common/ipc_channel_handle.h
new file mode 100644
index 0000000..2bb6380
--- /dev/null
+++ b/chrome/common/ipc_channel_handle.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 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.
+
+#ifndef CHROME_COMMON_IPC_CHANNEL_HANDLE_H_
+#define CHROME_COMMON_IPC_CHANNEL_HANDLE_H_
+
+#include "build/build_config.h"
+
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#endif
+
+// On Windows, any process can create an IPC channel and others can fetch
+// it by name. We pass around the channel names over IPC.
+// On POSIX, we instead pass around handles to channel endpoints via IPC.
+// When it's time to IPC a new channel endpoint around, we send both the
+// channel name as well as a base::FileDescriptor, which is itself a special
+// type that knows how to copy a socket endpoint over IPC.
+//
+// In sum, when passing a handle to a channel over IPC, use this data structure
+// to work on both Windows and POSIX.
+
+namespace IPC {
+
+struct ChannelHandle {
+ // Note that serialization for this object is defined in the ParamTraits
+ // template specialization in ipc_message_utils.h.
+ std::string name;
+#if defined(OS_POSIX)
+ base::FileDescriptor socket;
+#endif
+
+ ChannelHandle() {}
+#if defined(OS_POSIX)
+ ChannelHandle(const std::string& n, const base::FileDescriptor& s)
+ : name(n), socket(s) {}
+#else
+ ChannelHandle(const std::string& n) : name(n) {}
+#endif
+};
+
+} // namespace IPC
+
+#endif // CHROME_COMMON_IPC_CHANNEL_HANDLE_H_