OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 TOOLS_ANDROID_FORWARDER2_DAEMON_H_ |
| 6 #define TOOLS_ANDROID_FORWARDER2_DAEMON_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/at_exit.h" |
| 11 #include "base/basictypes.h" |
| 12 |
| 13 namespace forwarder2 { |
| 14 |
| 15 class Daemon { |
| 16 public: |
| 17 // |pid_file_path| is the file path to which the daemon's PID will be written. |
| 18 // Note that a lock on the file is also acquired to guarantee that a single |
| 19 // instance of daemon is running. |
| 20 explicit Daemon(const std::string& pid_file_path); |
| 21 |
| 22 // Returns whether the daemon was successfully spawned. Use |is_daemon| to |
| 23 // distinguish the parent from the child (daemon) process. |
| 24 bool Spawn(bool* is_daemon); |
| 25 |
| 26 // Kills the daemon and blocks until it exited. |
| 27 bool Kill(); |
| 28 |
| 29 private: |
| 30 const std::string pid_file_path_; |
| 31 base::AtExitManager at_exit_manager; |
| 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(Daemon); |
| 34 }; |
| 35 |
| 36 } // namespace forwarder2 |
| 37 |
| 38 #endif // TOOLS_ANDROID_FORWARDER2_DAEMON_H_ |
OLD | NEW |