OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 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 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_WIN_H_ | |
5 #define COMPONENTS_BROWSER_WATCHER_WATCHER_WIN_H_ | |
6 | |
7 #include "base/macros.h" | |
8 #include "base/process/process_handle.h" | |
9 #include "base/strings/string16.h" | |
10 #include "base/time/time.h" | |
11 #include "base/win/scoped_handle.h" | |
12 | |
13 namespace base { | |
14 class CommandLine; | |
15 } | |
16 | |
17 namespace browser_watcher { | |
18 | |
19 // Watches for the exit code of a process and records it in a given registry | |
20 // location. | |
21 class ExitCodeWatcher { | |
22 public: | |
23 // Initialize the watcher with a registry path. | |
24 explicit ExitCodeWatcher(const base::char16* registry_path); | |
25 ~ExitCodeWatcher(); | |
26 | |
27 // Initializes from arguments on |cmd_line|, returns true on success. | |
28 // This function expects the process handle indicated in |cmd_line| to be open | |
29 // with sufficient privilege to wait and retrieve the process exit code. | |
30 // It checks the handle for validity and takes ownership of it. | |
31 // The intent is for this handle to be inherited into the watcher process | |
32 // hosting the instance of this class. | |
erikwright (departed)
2014/11/17 18:12:30
Once you have exposed the flag as a public static
Sigurður Ásgeirsson
2014/11/17 21:27:12
Done.
| |
33 bool ParseArguments(const base::CommandLine& cmd_line); | |
34 | |
35 // Waits for the process to exit and records its exit code in registry. | |
36 // This is a blocking call. | |
37 void WaitForExit(); | |
38 | |
39 base::ProcessHandle process() const { return process_.Get(); } | |
40 | |
41 private: | |
42 // The registry path the exit codes are written to. | |
43 base::string16 registry_path_; | |
44 | |
45 // Handle, PID, and creation time of the watched process. | |
46 base::win::ScopedHandle process_; | |
47 base::ProcessId process_pid_; | |
48 base::Time process_creation_time_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(ExitCodeWatcher); | |
51 }; | |
52 | |
53 } // namespace browser_watcher | |
54 | |
55 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_WIN_H_ | |
OLD | NEW |