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

Side by Side Diff: components/arc/standalone/service_helper.h

Issue 2391743002: Use FileDescriptorWatcher in ServiceHelper. (Closed)
Patch Set: self-review Created 4 years, 2 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
« no previous file with comments | « no previous file | components/arc/standalone/service_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_ARC_STANDALONE_SERVICE_HELPER_H_ 5 #ifndef COMPONENTS_ARC_STANDALONE_SERVICE_HELPER_H_
6 #define COMPONENTS_ARC_STANDALONE_SERVICE_HELPER_H_ 6 #define COMPONENTS_ARC_STANDALONE_SERVICE_HELPER_H_
7 7
8 #include <signal.h> 8 #include <signal.h>
9 9
10 #include <memory>
11
12 #include "base/files/file_descriptor_watcher_posix.h"
10 #include "base/files/scoped_file.h" 13 #include "base/files/scoped_file.h"
11 #include "base/message_loop/message_loop.h"
12 14
13 namespace arc { 15 namespace arc {
14 16
15 // Helper class to set up service-like processes. 17 // Helper class to set up service-like processes.
16 class ServiceHelper : public base::MessageLoopForIO::Watcher { 18 class ServiceHelper {
17 public: 19 public:
18 ServiceHelper(); 20 ServiceHelper();
19 ~ServiceHelper() override; 21 ~ServiceHelper();
20 22
21 // Must be called after message loop instantiation. 23 // Must be called after message loop instantiation.
22 void Init(const base::Closure& closure); 24 void Init(const base::Closure& closure);
23 25
24 // MessageLoopForIO::Watcher 26 private:
25 void OnFileCanReadWithoutBlocking(int fd) override; 27 void OnFileCanReadWithoutBlocking();
26 void OnFileCanWriteWithoutBlocking(int fd) override;
27 28
28 private:
29 static void TerminationHandler(int /* signum */); 29 static void TerminationHandler(int /* signum */);
30 30
31 // Static variable to guarantee instantiated only once per process. 31 // Static variable to guarantee instantiated only once per process.
32 static ServiceHelper* self_; 32 static ServiceHelper* self_;
33 33
34 base::Closure closure_; 34 base::Closure closure_;
35 base::ScopedFD read_fd_; 35 base::ScopedFD read_fd_;
36 base::ScopedFD write_fd_; 36 base::ScopedFD write_fd_;
37 base::MessageLoopForIO::FileDescriptorWatcher watcher_; 37 std::unique_ptr<base::FileDescriptorWatcher::Controller> watch_controller_;
38 struct sigaction old_sigint_; 38 struct sigaction old_sigint_;
39 struct sigaction old_sigterm_; 39 struct sigaction old_sigterm_;
40 40
41 DISALLOW_COPY_AND_ASSIGN(ServiceHelper); 41 DISALLOW_COPY_AND_ASSIGN(ServiceHelper);
42 }; 42 };
43 43
44 } // namespace arc 44 } // namespace arc
45 45
46 #endif // COMPONENTS_ARC_STANDALONE_SERVICE_HELPER_H_ 46 #endif // COMPONENTS_ARC_STANDALONE_SERVICE_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/standalone/service_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698