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

Side by Side Diff: ipc/ipc_channel_posix.h

Issue 5598010: Convert over to channel handles (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed up bad whitespace Created 10 years 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
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 #pragma once 7 #pragma once
8 8
9 #include "ipc/ipc_channel.h" 9 #include "ipc/ipc_channel.h"
10 10
11 #include <sys/socket.h> // for CMSG macros 11 #include <sys/socket.h> // for CMSG macros
12 12
13 #include <queue> 13 #include <queue>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "ipc/file_descriptor_set_posix.h" 18 #include "ipc/file_descriptor_set_posix.h"
19 19
20 namespace IPC { 20 namespace IPC {
21 21
22 // Store that channel name |name| is available via socket |socket|.
23 // Used when the channel has been precreated by another process on
24 // our behalf and they've just shipped us the socket.
25 void AddChannelSocket(const std::string& name, int socket);
26
27 // Remove the channel name mapping, and close the corresponding socket.
28 void RemoveAndCloseChannelSocket(const std::string& name);
29
30 // Returns true if a channel named |name| is available.
31 bool ChannelSocketExists(const std::string& name);
32
33 // Construct a socket pair appropriate for IPC: UNIX domain, nonblocking.
34 // Returns false on error.
35 bool SocketPair(int* fd1, int* fd2);
36
37 // An implementation of ChannelImpl for POSIX systems that works via 22 // An implementation of ChannelImpl for POSIX systems that works via
38 // socketpairs. See the .cc file for an overview of the implementation. 23 // socketpairs. See the .cc file for an overview of the implementation.
39 class Channel::ChannelImpl : public MessageLoopForIO::Watcher { 24 class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
40 public: 25 public:
41 // Mirror methods of Channel, see ipc_channel.h for description. 26 // Mirror methods of Channel, see ipc_channel.h for description.
42 ChannelImpl(const std::string& channel_id, Mode mode, Listener* listener); 27 ChannelImpl(const IPC::ChannelHandle &channel_handle, Mode mode,
brettw 2010/12/08 22:49:27 Be sure to check these other places as well.
28 Listener* listener);
43 ~ChannelImpl(); 29 ~ChannelImpl();
44 bool Connect(); 30 bool Connect();
45 void Close(); 31 void Close();
46 void set_listener(Listener* listener) { listener_ = listener; } 32 void set_listener(Listener* listener) { listener_ = listener; }
47 bool Send(Message* message); 33 bool Send(Message* message);
48 int GetClientFileDescriptor() const; 34 int GetClientFileDescriptor() const;
49 35
50 private: 36 private:
51 bool CreatePipe(const std::string& channel_id, Mode mode); 37 bool CreatePipe(const IPC::ChannelHandle &channel_handle, Mode mode);
52 38
53 bool ProcessIncomingMessages(); 39 bool ProcessIncomingMessages();
54 bool ProcessOutgoingMessages(); 40 bool ProcessOutgoingMessages();
55 41
56 // MessageLoopForIO::Watcher implementation. 42 // MessageLoopForIO::Watcher implementation.
57 virtual void OnFileCanReadWithoutBlocking(int fd); 43 virtual void OnFileCanReadWithoutBlocking(int fd);
58 virtual void OnFileCanWriteWithoutBlocking(int fd); 44 virtual void OnFileCanWriteWithoutBlocking(int fd);
59 45
60 Mode mode_; 46 Mode mode_;
61 47
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bool waiting_connect_; 117 bool waiting_connect_;
132 118
133 ScopedRunnableMethodFactory<ChannelImpl> factory_; 119 ScopedRunnableMethodFactory<ChannelImpl> factory_;
134 120
135 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); 121 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
136 }; 122 };
137 123
138 } // namespace IPC 124 } // namespace IPC
139 125
140 #endif // IPC_IPC_CHANNEL_POSIX_H_ 126 #endif // IPC_IPC_CHANNEL_POSIX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698