Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: ipc/ipc_channel_handle.h

Issue 2484943004: Remove unused parts of IPC::ChannelHandle. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_channel_common.cc ('k') | ipc/ipc_channel_nacl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "mojo/public/cpp/system/message_pipe.h" 11 #include "mojo/public/cpp/system/message_pipe.h"
12 12
13 #if defined(OS_POSIX) 13 #if defined(OS_NACL_SFI)
14 #include "base/file_descriptor_posix.h" 14 #include "base/file_descriptor_posix.h"
15 #elif defined(OS_WIN) 15 #endif // defined (OS_NACL_SFI)
16 #include <windows.h>
17 #endif // defined (OS_WIN)
18
19 // On Windows, any process can create an IPC channel and others can fetch
20 // it by name. We pass around the channel names over IPC.
21 // On Windows the initialization of ChannelHandle with an existing pipe
22 // handle is provided for convenience.
23 // NOTE: A ChannelHandle with a pipe handle Will NOT be marshalled over IPC.
24
25 // On POSIX, we instead pass around handles to channel endpoints via IPC.
26 // When it's time to IPC a new channel endpoint around, we send both the
27 // channel name as well as a base::FileDescriptor, which is itself a special
28 // type that knows how to copy a socket endpoint over IPC.
29 //
30 // In sum, this data structure can be used to pass channel information by name
31 // in both Windows and Posix. When passing a handle to a channel over IPC,
32 // use this data structure only for POSIX.
33 16
34 namespace IPC { 17 namespace IPC {
35 18
19 // Note that serialization for this object is defined in the ParamTraits
20 // template specialization in ipc_message_utils.h.
21 #if defined(OS_NACL_SFI)
36 struct ChannelHandle { 22 struct ChannelHandle {
37 // Note that serialization for this object is defined in the ParamTraits
38 // template specialization in ipc_message_utils.h.
39 ChannelHandle() {} 23 ChannelHandle() {}
40 // The name that is passed in should be an absolute path for Posix. 24 explicit ChannelHandle(const base::FileDescriptor& s) : socket(s) {}
41 // Otherwise there may be a problem in IPC communication between 25
42 // processes with different working directories. 26 base::FileDescriptor socket;
43 ChannelHandle(const std::string& n) : name(n) {} 27 };
44 ChannelHandle(const char* n) : name(n) {} 28 #else
45 #if defined(OS_WIN) 29 struct ChannelHandle {
46 explicit ChannelHandle(HANDLE h) : pipe(h) {} 30 ChannelHandle() {}
47 #elif defined(OS_POSIX)
48 ChannelHandle(const std::string& n, const base::FileDescriptor& s)
49 : name(n), socket(s) {}
50 #endif // defined(OS_POSIX)
51 ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {} 31 ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {}
52 32
53 bool is_mojo_channel_handle() const { 33 bool is_mojo_channel_handle() const { return mojo_handle.is_valid(); }
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() && name.empty();
62 }
63 34
64 std::string name;
65 #if defined(OS_POSIX)
66 base::FileDescriptor socket;
67 #elif defined(OS_WIN)
68 // A simple container to automatically initialize pipe handle
69 struct PipeHandle {
70 PipeHandle() : handle(NULL) {}
71 PipeHandle(HANDLE h) : handle(h) {}
72 HANDLE handle;
73 };
74 PipeHandle pipe;
75 #endif // defined (OS_WIN)
76 mojo::MessagePipeHandle mojo_handle; 35 mojo::MessagePipeHandle mojo_handle;
77 }; 36 };
37 #endif // defined(OS_NACL_SFI)
78 38
79 } // namespace IPC 39 } // namespace IPC
80 40
81 #endif // IPC_IPC_CHANNEL_HANDLE_H_ 41 #endif // IPC_IPC_CHANNEL_HANDLE_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_common.cc ('k') | ipc/ipc_channel_nacl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698