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

Side by Side Diff: ipc/ipc_channel_posix.h

Issue 310293002: Make IPC::Channel polymorphic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt to fix build breakage Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel_nacl.cc ('k') | ipc/ipc_channel_posix.cc » ('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_POSIX_H_ 5 #ifndef IPC_IPC_CHANNEL_POSIX_H_
6 #define IPC_IPC_CHANNEL_POSIX_H_ 6 #define IPC_IPC_CHANNEL_POSIX_H_
7 7
8 #include "ipc/ipc_channel.h" 8 #include "ipc/ipc_channel.h"
9 9
10 #include <sys/socket.h> // for CMSG macros 10 #include <sys/socket.h> // for CMSG macros
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // this switch 'on' on the Mac as well. 42 // this switch 'on' on the Mac as well.
43 // 43 //
44 // The HELLO message from the client to the server is always sent using 44 // The HELLO message from the client to the server is always sent using
45 // sendmsg because it will contain the file descriptor that the server 45 // sendmsg because it will contain the file descriptor that the server
46 // needs to send file descriptors in later messages. 46 // needs to send file descriptors in later messages.
47 #define IPC_USES_READWRITE 1 47 #define IPC_USES_READWRITE 1
48 #endif 48 #endif
49 49
50 namespace IPC { 50 namespace IPC {
51 51
52 class Channel::ChannelImpl : public internal::ChannelReader, 52 class ChannelPosix : public Channel,
53 public base::MessageLoopForIO::Watcher { 53 public internal::ChannelReader,
54 public base::MessageLoopForIO::Watcher {
54 public: 55 public:
55 // Mirror methods of Channel, see ipc_channel.h for description. 56 // Mirror methods of Channel, see ipc_channel.h for description.
56 ChannelImpl(const IPC::ChannelHandle& channel_handle, Mode mode, 57 ChannelPosix(const IPC::ChannelHandle& channel_handle, Mode mode,
57 Listener* listener); 58 Listener* listener);
58 virtual ~ChannelImpl(); 59 virtual ~ChannelPosix();
59 bool Connect(); 60
60 void Close(); 61 // Channel implementation
61 bool Send(Message* message); 62 virtual bool Connect() OVERRIDE;
62 int GetClientFileDescriptor(); 63 virtual void Close() OVERRIDE;
63 int TakeClientFileDescriptor(); 64 virtual bool Send(Message* message) OVERRIDE;
65 virtual base::ProcessId GetPeerPID() const OVERRIDE;
66 virtual int GetClientFileDescriptor() const OVERRIDE;
67 virtual int TakeClientFileDescriptor() OVERRIDE;
68 virtual bool AcceptsConnections() const OVERRIDE;
69 virtual bool HasAcceptedConnection() const OVERRIDE;
70 virtual bool GetPeerEuid(uid_t* peer_euid) const OVERRIDE;
71 virtual void ResetToAcceptingConnectionState() OVERRIDE;
72
64 void CloseClientFileDescriptor(); 73 void CloseClientFileDescriptor();
65 bool AcceptsConnections() const; 74
66 bool HasAcceptedConnection() const;
67 bool GetPeerEuid(uid_t* peer_euid) const;
68 void ResetToAcceptingConnectionState();
69 base::ProcessId peer_pid() const { return peer_pid_; }
70 static bool IsNamedServerInitialized(const std::string& channel_id); 75 static bool IsNamedServerInitialized(const std::string& channel_id);
71 #if defined(OS_LINUX) 76 #if defined(OS_LINUX)
72 static void SetGlobalPid(int pid); 77 static void SetGlobalPid(int pid);
73 #endif // OS_LINUX 78 #endif // OS_LINUX
74 79
75 private: 80 private:
76 bool CreatePipe(const IPC::ChannelHandle& channel_handle); 81 bool CreatePipe(const IPC::ChannelHandle& channel_handle);
77 82
78 bool ProcessOutgoingMessages(); 83 bool ProcessOutgoingMessages();
79 84
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // File descriptor we're listening on for new connections if we listen 142 // File descriptor we're listening on for new connections if we listen
138 // for connections. 143 // for connections.
139 int server_listen_pipe_; 144 int server_listen_pipe_;
140 145
141 // The pipe used for communication. 146 // The pipe used for communication.
142 int pipe_; 147 int pipe_;
143 148
144 // For a server, the client end of our socketpair() -- the other end of our 149 // For a server, the client end of our socketpair() -- the other end of our
145 // pipe_ that is passed to the client. 150 // pipe_ that is passed to the client.
146 int client_pipe_; 151 int client_pipe_;
147 base::Lock client_pipe_lock_; // Lock that protects |client_pipe_|. 152 mutable base::Lock client_pipe_lock_; // Lock that protects |client_pipe_|.
148 153
149 #if defined(IPC_USES_READWRITE) 154 #if defined(IPC_USES_READWRITE)
150 // Linux/BSD use a dedicated socketpair() for passing file descriptors. 155 // Linux/BSD use a dedicated socketpair() for passing file descriptors.
151 int fd_pipe_; 156 int fd_pipe_;
152 int remote_fd_pipe_; 157 int remote_fd_pipe_;
153 #endif 158 #endif
154 159
155 // The "name" of our pipe. On Windows this is the global identifier for 160 // The "name" of our pipe. On Windows this is the global identifier for
156 // the pipe. On POSIX it's used as a key in a local map of file descriptors. 161 // the pipe. On POSIX it's used as a key in a local map of file descriptors.
157 std::string pipe_name_; 162 std::string pipe_name_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 #endif 200 #endif
196 201
197 // True if we are responsible for unlinking the unix domain socket file. 202 // True if we are responsible for unlinking the unix domain socket file.
198 bool must_unlink_; 203 bool must_unlink_;
199 204
200 #if defined(OS_LINUX) 205 #if defined(OS_LINUX)
201 // If non-zero, overrides the process ID sent in the hello message. 206 // If non-zero, overrides the process ID sent in the hello message.
202 static int global_pid_; 207 static int global_pid_;
203 #endif // OS_LINUX 208 #endif // OS_LINUX
204 209
205 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelImpl); 210 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix);
206 }; 211 };
207 212
208 } // namespace IPC 213 } // namespace IPC
209 214
210 #endif // IPC_IPC_CHANNEL_POSIX_H_ 215 #endif // IPC_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_nacl.cc ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698