summaryrefslogtreecommitdiff
path: root/ipc/ipc_channel_handle.h
diff options
context:
space:
mode:
authorHyungKyu Song <hk76.song@samsung.com>2013-02-15 15:53:36 (GMT)
committerHyungKyu Song <hk76.song@samsung.com>2013-02-15 15:53:36 (GMT)
commit74e42fb0242c25c1fa46e45fcf04e3c88ab40620 (patch)
treeebbbe8a8120031a0a1340161064b1e1a2b2bc2ef /ipc/ipc_channel_handle.h
parent98fbfad8ece16f88391165f4ad849e87e246bbdb (diff)
downloadchromium-74e42fb0242c25c1fa46e45fcf04e3c88ab40620.zip
chromium-74e42fb0242c25c1fa46e45fcf04e3c88ab40620.tar.gz
chromium-74e42fb0242c25c1fa46e45fcf04e3c88ab40620.tar.bz2
Diffstat (limited to 'ipc/ipc_channel_handle.h')
-rw-r--r--ipc/ipc_channel_handle.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/ipc/ipc_channel_handle.h b/ipc/ipc_channel_handle.h
new file mode 100644
index 0000000..ba034cc
--- /dev/null
+++ b/ipc/ipc_channel_handle.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 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 IPC_IPC_CHANNEL_HANDLE_H_
+#define IPC_IPC_CHANNEL_HANDLE_H_
+#pragma once
+
+#include <string>
+
+#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.
+ ChannelHandle() {}
+ // The name that is passed in should be an absolute path for Posix.
+ // Otherwise there may be a problem in IPC communication between
+ // processes with different working directories.
+ ChannelHandle(const std::string& n) : name(n) {}
+ ChannelHandle(const char* n) : name(n) {}
+#if defined(OS_POSIX)
+ ChannelHandle(const std::string& n, const base::FileDescriptor& s)
+ : name(n), socket(s) {}
+#endif // defined(OS_POSIX)
+
+ std::string name;
+#if defined(OS_POSIX)
+ base::FileDescriptor socket;
+#endif // defined(OS_POSIX)
+
+};
+
+} // namespace IPC
+
+#endif // IPC_IPC_CHANNEL_HANDLE_H_