OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IPC_IPC_CHANNEL_HANDLE_H_ | 5 #ifndef IPC_IPC_CHANNEL_HANDLE_H_ |
6 #define IPC_IPC_CHANNEL_HANDLE_H_ | 6 #define IPC_IPC_CHANNEL_HANDLE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 ChannelHandle(const std::string& n) : name(n) {} | 43 ChannelHandle(const std::string& n) : name(n) {} |
44 ChannelHandle(const char* n) : name(n) {} | 44 ChannelHandle(const char* n) : name(n) {} |
45 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
46 explicit ChannelHandle(HANDLE h) : pipe(h) {} | 46 explicit ChannelHandle(HANDLE h) : pipe(h) {} |
47 #elif defined(OS_POSIX) | 47 #elif defined(OS_POSIX) |
48 ChannelHandle(const std::string& n, const base::FileDescriptor& s) | 48 ChannelHandle(const std::string& n, const base::FileDescriptor& s) |
49 : name(n), socket(s) {} | 49 : name(n), socket(s) {} |
50 #endif // defined(OS_POSIX) | 50 #endif // defined(OS_POSIX) |
51 ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {} | 51 ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {} |
52 | 52 |
53 bool is_mojo_channel_handle() const { | |
54 #if defined(OS_WIN) | |
55 if (pipe.handle) | |
56 return false; | |
57 #elif defined(OS_POSIX) | |
58 if (socket.fd != -1) | |
59 return false; | |
60 #endif // defined(OS_POSIX) | |
61 return mojo_handle.is_valid(); | |
Mark Seaborn
2016/10/17 21:28:26
How about also: "&& name.empty()"
Sam McNally
2016/10/17 23:01:17
Done.
| |
62 } | |
63 | |
53 std::string name; | 64 std::string name; |
54 #if defined(OS_POSIX) | 65 #if defined(OS_POSIX) |
55 base::FileDescriptor socket; | 66 base::FileDescriptor socket; |
56 #elif defined(OS_WIN) | 67 #elif defined(OS_WIN) |
57 // A simple container to automatically initialize pipe handle | 68 // A simple container to automatically initialize pipe handle |
58 struct PipeHandle { | 69 struct PipeHandle { |
59 PipeHandle() : handle(NULL) {} | 70 PipeHandle() : handle(NULL) {} |
60 PipeHandle(HANDLE h) : handle(h) {} | 71 PipeHandle(HANDLE h) : handle(h) {} |
61 HANDLE handle; | 72 HANDLE handle; |
62 }; | 73 }; |
63 PipeHandle pipe; | 74 PipeHandle pipe; |
64 #endif // defined (OS_WIN) | 75 #endif // defined (OS_WIN) |
65 mojo::MessagePipeHandle mojo_handle; | 76 mojo::MessagePipeHandle mojo_handle; |
66 }; | 77 }; |
67 | 78 |
68 } // namespace IPC | 79 } // namespace IPC |
69 | 80 |
70 #endif // IPC_IPC_CHANNEL_HANDLE_H_ | 81 #endif // IPC_IPC_CHANNEL_HANDLE_H_ |
OLD | NEW |