Chromium Code Reviews| 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 <windows.h> | |
|
erikwright (departed)
2014/11/14 19:46:10
not used
Sigurður Ásgeirsson
2014/11/17 15:26:58
Done.
| |
| 8 | |
| 9 #include "base/macros.h" | |
| 10 #include "base/process/process_handle.h" | |
| 11 #include "base/strings/string16.h" | |
| 12 #include "base/time/time.h" | |
| 13 #include "base/win/scoped_handle.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class CommandLine; | |
| 17 } | |
| 18 | |
| 19 namespace browser_watcher { | |
| 20 | |
| 21 // Watches for the exit code of a process and records it in a given registry | |
| 22 // location. | |
| 23 class ExitCodeWatcher { | |
| 24 public: | |
| 25 // Initialize the watcher with a registry path. | |
| 26 explicit ExitCodeWatcher(const wchar_t* registry_path); | |
|
erikwright (departed)
2014/11/14 19:46:10
It seems relatively unusual to pass around char bu
Sigurður Ásgeirsson
2014/11/17 15:26:58
Done.
| |
| 27 | |
|
erikwright (departed)
2014/11/14 19:46:10
an explicit out-of-line destructor is required.
Sigurður Ásgeirsson
2014/11/17 15:26:58
Sure, why?
erikwright (departed)
2014/11/17 15:35:17
The default destructor will be inlined, which viol
| |
| 28 // Initializes from arguments on |cmd_line|, returns true on success. | |
| 29 // This function expects the process handle indicated in |cmd_line| to be open | |
| 30 // with sufficient privilege to wait and retrieve the process exit code. | |
| 31 // It checks the handle for validity and takes ownership of it. | |
| 32 // The intent is for this handle to be inherited into the watcher process | |
| 33 // hosting the instance of this class. | |
| 34 bool ParseArguments(const base::CommandLine& cmd_line); | |
| 35 | |
| 36 // Waits for the process to exit and records its exit code in registry. | |
| 37 // This is a blocking call. | |
| 38 void WaitForExit(); | |
| 39 | |
| 40 base::ProcessHandle process() const { return process_.Get(); } | |
| 41 | |
| 42 private: | |
| 43 // The registry path the exit codes are written to. | |
| 44 base::string16 registry_path_; | |
| 45 | |
| 46 // Handle to the process we wait for and it's creation time. | |
|
erikwright (departed)
2014/11/14 19:46:10
it's -> its
But this comment is unnerving in its
Sigurður Ásgeirsson
2014/11/17 15:26:58
:)
| |
| 47 base::win::ScopedHandle process_; | |
| 48 base::ProcessId process_pid_; | |
| 49 base::Time process_creation_time_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(ExitCodeWatcher); | |
| 52 }; | |
| 53 | |
| 54 } // namespace browser_watcher | |
| 55 | |
| 56 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_WIN_H_ | |
| OLD | NEW |