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

Side by Side Diff: ipc/ipc_channel_posix.h

Issue 320433002: IPC::Channel: Reduce POSIX specific API surface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Landig 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.h ('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 ChannelPosix : public Channel, 52 class IPC_EXPORT ChannelPosix : public Channel,
53 public internal::ChannelReader, 53 public internal::ChannelReader,
54 public base::MessageLoopForIO::Watcher { 54 public base::MessageLoopForIO::Watcher {
55 public: 55 public:
56 // Mirror methods of Channel, see ipc_channel.h for description.
57 ChannelPosix(const IPC::ChannelHandle& channel_handle, Mode mode, 56 ChannelPosix(const IPC::ChannelHandle& channel_handle, Mode mode,
58 Listener* listener); 57 Listener* listener);
59 virtual ~ChannelPosix(); 58 virtual ~ChannelPosix();
60 59
61 // Channel implementation 60 // Channel implementation
62 virtual bool Connect() OVERRIDE; 61 virtual bool Connect() OVERRIDE;
63 virtual void Close() OVERRIDE; 62 virtual void Close() OVERRIDE;
64 virtual bool Send(Message* message) OVERRIDE; 63 virtual bool Send(Message* message) OVERRIDE;
65 virtual base::ProcessId GetPeerPID() const OVERRIDE; 64 virtual base::ProcessId GetPeerPID() const OVERRIDE;
66 virtual int GetClientFileDescriptor() const OVERRIDE; 65 virtual int GetClientFileDescriptor() const OVERRIDE;
67 virtual int TakeClientFileDescriptor() OVERRIDE; 66 virtual int TakeClientFileDescriptor() OVERRIDE;
68 virtual bool AcceptsConnections() const OVERRIDE; 67
69 virtual bool HasAcceptedConnection() const OVERRIDE; 68 // Returns true if the channel supports listening for connections.
70 virtual bool GetPeerEuid(uid_t* peer_euid) const OVERRIDE; 69 bool AcceptsConnections() const;
71 virtual void ResetToAcceptingConnectionState() OVERRIDE; 70
71 // Returns true if the channel supports listening for connections and is
72 // currently connected.
73 bool HasAcceptedConnection() const;
74
75 // Closes any currently connected socket, and returns to a listening state
76 // for more connections.
77 void ResetToAcceptingConnectionState();
78
79 // Returns true if the peer process' effective user id can be determined, in
80 // which case the supplied peer_euid is updated with it.
81 bool GetPeerEuid(uid_t* peer_euid) const;
72 82
73 void CloseClientFileDescriptor(); 83 void CloseClientFileDescriptor();
74 84
75 static bool IsNamedServerInitialized(const std::string& channel_id); 85 static bool IsNamedServerInitialized(const std::string& channel_id);
76 #if defined(OS_LINUX) 86 #if defined(OS_LINUX)
77 static void SetGlobalPid(int pid); 87 static void SetGlobalPid(int pid);
78 #endif // OS_LINUX 88 #endif // OS_LINUX
79 89
80 private: 90 private:
81 bool CreatePipe(const IPC::ChannelHandle& channel_handle); 91 bool CreatePipe(const IPC::ChannelHandle& channel_handle);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // If non-zero, overrides the process ID sent in the hello message. 216 // If non-zero, overrides the process ID sent in the hello message.
207 static int global_pid_; 217 static int global_pid_;
208 #endif // OS_LINUX 218 #endif // OS_LINUX
209 219
210 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); 220 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix);
211 }; 221 };
212 222
213 } // namespace IPC 223 } // namespace IPC
214 224
215 #endif // IPC_IPC_CHANNEL_POSIX_H_ 225 #endif // IPC_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698