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

Side by Side Diff: ipc/ipc_channel_factory.h

Issue 12386010: Implement IPC::ChannelFactory, a class that accept()s on a UNIX socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: un-revert fix to tests Created 7 years, 9 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_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IPC_IPC_CHANNEL_FACTORY_H_
6 #define IPC_IPC_CHANNEL_FACTORY_H_
7
8 #include "base/files/file_path.h"
9 #include "base/message_loop.h"
10 #include "ipc/ipc_channel_handle.h"
11 #include "ipc/ipc_export.h"
12
13 namespace IPC {
14
15 // A ChannelFactory listens on a UNIX domain socket. When a client connects to
16 // the socket, it accept()s the connection and passes the new FD to the
17 // delegate. The delegate is then responsible for creating a new IPC::Channel
18 // for the FD.
19 class IPC_EXPORT ChannelFactory : public MessageLoopForIO::Watcher {
20 public:
21 class Delegate {
22 public:
23 // Called when a client connects to the factory. It is the delegate's
24 // responsibility to create an IPC::Channel for the handle, or else close
25 // the file descriptor contained therein.
26 virtual void OnClientConnected(const ChannelHandle& handle) = 0;
27
28 // Called when an error occurs and the channel is closed.
29 virtual void OnListenError() = 0;
30 };
31
32 ChannelFactory(const base::FilePath& path, Delegate* delegate);
33
34 virtual ~ChannelFactory();
35
36 // Call this to start listening on the socket.
37 bool Listen();
38
39 // Close and unlink the socket, and stop accepting connections.
40 void Close();
41
42 private:
43 bool CreateSocket();
44 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
45 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
46
47 MessageLoopForIO::FileDescriptorWatcher server_listen_connection_watcher_;
48 base::FilePath path_;
49 Delegate* delegate_;
50 int listen_fd_;
51
52 DISALLOW_COPY_AND_ASSIGN(ChannelFactory);
53 };
54
55 } // namespace IPC
56
57 #endif // IPC_IPC_CHANNEL_FACTORY_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_channel_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698