Chromium Code Reviews| Index: ipc/ipc_channel_handle.h |
| diff --git a/ipc/ipc_channel_handle.h b/ipc/ipc_channel_handle.h |
| index ba034cca23b87b51557d6f3e53ab992ee0716e79..96832d0060553a2419916feeece17700526f7cae 100644 |
| --- a/ipc/ipc_channel_handle.h |
| +++ b/ipc/ipc_channel_handle.h |
| @@ -13,16 +13,24 @@ |
| #if defined(OS_POSIX) |
| #include "base/file_descriptor_posix.h" |
| #endif |
| +#if defined(OS_WIN) |
| +#include <windows.h> |
| +#endif // defined (OS_WIN) |
| // 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 Windows the initialization of ChannelHandle with an existing pipe |
| +// handle is provided for convenience. |
| +// NOTE: A ChannelHandle with a pipe handle Will NOT be marshalled 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. |
| +// In sum, this data structure can be used to pass channel information by name |
| +// in both Windows and Posix. When passing a handle to a channel over IPC, |
| +// use this data structure only for POSIX. |
| namespace IPC { |
| @@ -35,6 +43,9 @@ struct ChannelHandle { |
| // processes with different working directories. |
| ChannelHandle(const std::string& n) : name(n) {} |
| ChannelHandle(const char* n) : name(n) {} |
|
cpu_(ooo_6.6-7.5)
2012/01/20 22:22:25
I worry that now we have a const char* ctor and a
|
| +#if defined(OS_WIN) |
| + ChannelHandle(HANDLE h) : pipe(h) {} |
| +#endif // defined (OS_WIN) |
| #if defined(OS_POSIX) |
| ChannelHandle(const std::string& n, const base::FileDescriptor& s) |
| : name(n), socket(s) {} |
| @@ -44,7 +55,15 @@ struct ChannelHandle { |
| #if defined(OS_POSIX) |
| base::FileDescriptor socket; |
| #endif // defined(OS_POSIX) |
| - |
| +#if defined(OS_WIN) |
| + // A simple container to automatically initialize pipe handle |
| + struct PipeHandle { |
| + PipeHandle() : handle(NULL) {} |
| + PipeHandle(HANDLE h) : handle(h) {} |
| + HANDLE handle; |
| + }; |
| + PipeHandle pipe; |
| +#endif // defined (OS_WIN) |
| }; |
| } // namespace IPC |