Andreea Costinas | 41e0644 | 2020-03-09 09:41:51 +0100 | [diff] [blame^] | 1 | // Copyright 2020 The Chromium OS 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 | #ifndef SYSTEM_PROXY_SERVER_PROXY_H_ |
| 5 | #define SYSTEM_PROXY_SERVER_PROXY_H_ |
| 6 | |
| 7 | #include <memory> |
| 8 | |
| 9 | #include <base/callback_forward.h> |
| 10 | #include <base/files/file_descriptor_watcher_posix.h> |
| 11 | #include <brillo/asynchronous_signal_handler.h> |
| 12 | |
| 13 | namespace system_proxy { |
| 14 | |
| 15 | // ServerProxy listens for connections from the host (system services, ARC++ |
| 16 | // apps) and sets-up connections to the remote server. |
| 17 | class ServerProxy { |
| 18 | public: |
| 19 | explicit ServerProxy(base::OnceClosure quit_closure); |
| 20 | ServerProxy(const ServerProxy&) = delete; |
| 21 | ServerProxy& operator=(const ServerProxy&) = delete; |
| 22 | ~ServerProxy(); |
| 23 | |
| 24 | void Init(); |
| 25 | |
| 26 | private: |
| 27 | void HandleStdinReadable(); |
| 28 | bool HandleSignal(const struct signalfd_siginfo& siginfo); |
| 29 | |
| 30 | base::OnceClosure quit_closure_; |
| 31 | std::unique_ptr<base::FileDescriptorWatcher::Controller> stdin_watcher_; |
| 32 | brillo::AsynchronousSignalHandler signal_handler_; |
| 33 | }; |
| 34 | } // namespace system_proxy |
| 35 | |
| 36 | #endif // SYSTEM_PROXY_SERVER_PROXY_H_ |