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

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: comments 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
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
12 namespace IPC {
13
14 // A ChannelFactory listens on a UNIX domain socket and passes new FDs to its
15 // delegate whenever a client tries to connect. It is the delegate's
16 // responsibility to create an IPC::Channel from the given FD.
17 class ChannelFactory : public MessageLoopForIO::Watcher {
18 public:
19 class Delegate {
20 public:
21 // Called when a client connects to the factory. It is the delegate's
22 // responsibility to create an IPC::Channel for the handle, or else close
23 // the file descriptor contained therein.
24 virtual void OnClientConnected(const ChannelHandle& handle) = 0;
25
26 // Called when an error occurs and the channel is closed.
27 virtual void OnListenError() = 0;
28 };
29
30 ChannelFactory(const base::FilePath& path, Delegate* delegate);
31
32 virtual ~ChannelFactory();
33
34 // Call this to start listening on the socket.
35 bool Listen();
36
37 // Close and unlink the socket, and stop accepting connections.
38 void Close();
39
40 private:
41 bool CreatePipe();
42 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
43 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {}
44
45 MessageLoopForIO::FileDescriptorWatcher server_listen_connection_watcher_;
46 base::FilePath path_;
47 Delegate* delegate_;
48 int listen_pipe_;
49
50 DISALLOW_COPY_AND_ASSIGN(ChannelFactory);
51 };
52
53 }
Mark Mentovai 2013/03/01 03:19:17 } // namespace IPC I already mentioned that.
54
55 #endif // IPC_IPC_CHANNEL_FACTORY_H_
OLDNEW
« no previous file with comments | « ipc/ipc.gypi ('k') | ipc/ipc_channel_factory.cc » ('j') | ipc/ipc_channel_factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698