Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 the FDs that get | |
| 15 // created when a client connects to its delegate. It is the delegate's | |
|
palmer
2013/03/06 00:59:21
"FDs that get created" — by whom?
Passes the FDs
jeremya
2013/03/06 05:03:18
Updated the comment :)
| |
| 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(); | |
|
Mark Mentovai
2013/03/05 20:08:03
This “pipe” business is a little bit misleading. I
jeremya
2013/03/06 05:03:18
Done. s/pipe/fd/g, s/CreatePipe/CreateSocket
| |
| 42 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | |
| 43 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {} | |
|
Mark Mentovai
2013/03/05 20:08:03
Inlining this (empty) function here seems like mor
jeremya
2013/03/06 05:03:18
Done.
| |
| 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/05 20:08:03
} // namespace IPC
jeremya
2013/03/06 05:03:18
Done.
| |
| 54 | |
| 55 #endif // IPC_IPC_CHANNEL_FACTORY_H_ | |
| OLD | NEW |