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

Side by Side Diff: chrome/browser/apps/app_shim/unix_domain_socket_acceptor.h

Issue 2295063002: Use ChannelMojo between app shims and the browser process. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ 5 #ifndef CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_
6 #define CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ 6 #define CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "ipc/ipc_channel_handle.h" 11 #include "mojo/edk/embedder/named_platform_handle.h"
12 #include "mojo/edk/embedder/scoped_platform_handle.h"
12 13
13 namespace apps { 14 namespace apps {
14 15
15 // A UnixDomainSocketAcceptor listens on a UNIX domain socket. When a 16 // A UnixDomainSocketAcceptor listens on a UNIX domain socket. When a
16 // client connects to the socket, it accept()s the connection and 17 // client connects to the socket, it accept()s the connection and
17 // passes the new FD to the delegate. The delegate is then responsible 18 // passes the new FD to the delegate. The delegate is then responsible
18 // for creating a new IPC::Channel for the FD. 19 // for creating a new IPC::Channel for the FD.
19 class UnixDomainSocketAcceptor : public base::MessageLoopForIO::Watcher { 20 class UnixDomainSocketAcceptor : public base::MessageLoopForIO::Watcher {
20 public: 21 public:
21 class Delegate { 22 class Delegate {
22 public: 23 public:
23 // Called when a client connects to the factory. It is the delegate's 24 // 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 // responsibility to create an IPC::Channel for the handle, or else close
25 // the file descriptor contained therein. 26 // the file descriptor contained therein.
26 virtual void OnClientConnected(const IPC::ChannelHandle& handle) = 0; 27 virtual void OnClientConnected(mojo::edk::ScopedPlatformHandle handle) = 0;
27 28
28 // Called when an error occurs and the channel is closed. 29 // Called when an error occurs and the channel is closed.
29 virtual void OnListenError() = 0; 30 virtual void OnListenError() = 0;
30 }; 31 };
31 32
32 UnixDomainSocketAcceptor(const base::FilePath& path, Delegate* delegate); 33 UnixDomainSocketAcceptor(const base::FilePath& path, Delegate* delegate);
33 34
34 ~UnixDomainSocketAcceptor() override; 35 ~UnixDomainSocketAcceptor() override;
35 36
36 // Call this to start listening on the socket. 37 // Call this to start listening on the socket.
37 bool Listen(); 38 bool Listen();
38 39
39 // Close and unlink the socket, and stop accepting connections. 40 // Close and unlink the socket, and stop accepting connections.
40 void Close(); 41 void Close();
41 42
42 private: 43 private:
43 bool CreateSocket();
44 void OnFileCanReadWithoutBlocking(int fd) override; 44 void OnFileCanReadWithoutBlocking(int fd) override;
45 void OnFileCanWriteWithoutBlocking(int fd) override; 45 void OnFileCanWriteWithoutBlocking(int fd) override;
46 46
47 base::MessageLoopForIO::FileDescriptorWatcher 47 base::MessageLoopForIO::FileDescriptorWatcher
48 server_listen_connection_watcher_; 48 server_listen_connection_watcher_;
49 base::FilePath path_; 49 mojo::edk::NamedPlatformHandle named_pipe_;
50 Delegate* delegate_; 50 Delegate* delegate_;
51 int listen_fd_; 51 mojo::edk::ScopedPlatformHandle listen_handle_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(UnixDomainSocketAcceptor); 53 DISALLOW_COPY_AND_ASSIGN(UnixDomainSocketAcceptor);
54 }; 54 };
55 55
56 } // namespace apps 56 } // namespace apps
57 57
58 #endif // CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ 58 #endif // CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/apps/app_shim/app_shim_host_manager_mac.mm ('k') | chrome/browser/apps/app_shim/unix_domain_socket_acceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698