Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 CHROME_APP_CHROME_WATCHER_CLIENT_WIN_H_ | |
| 6 #define CHROME_APP_CHROME_WATCHER_CLIENT_WIN_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/command_line.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/process/process.h" | |
| 14 #include "base/win/scoped_handle.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class TimeDelta; | |
| 18 } // namespace base | |
| 19 | |
| 20 // Launches a Chrome watcher process and permits the client to wait until the | |
| 21 // process is fully initialized. | |
| 22 class ChromeWatcherClient { | |
| 23 public: | |
| 24 // A CommandLineGenerator generates command lines that will launch a separate | |
| 25 // process and pass the supplied HANDLE values to WatcherMain in that process. | |
| 26 // The first HANDLE is an event that should be signaled when the watcher | |
| 27 // process is fully initialized. The second HANDLE is the process that the | |
| 28 // watcher process should watch. | |
| 29 // The process will be launched such that the HANDLEs are inherited by the | |
| 30 // new process. | |
| 31 typedef base::Callback<base::CommandLine(HANDLE, HANDLE)> | |
| 32 CommandLineGenerator; | |
| 33 | |
| 34 // Constructs an instance that launches its watcher process using the command | |
| 35 // line generated by |command_line_generator|. | |
| 36 explicit ChromeWatcherClient( | |
| 37 const CommandLineGenerator& command_line_generator); | |
| 38 | |
| 39 ~ChromeWatcherClient(); | |
| 40 | |
| 41 // Launches the watcher process such that the child process is able to inherit | |
| 42 // a handle to the current process. Returns true if the process is | |
| 43 // successfully launched. | |
| 44 bool LaunchWatcher(); | |
| 45 | |
| 46 // Blocks until the process, previously launched by LaunchWatcher, is either | |
| 47 // fully initialized or has terminated. Returns true if the process | |
| 48 // successfully initializes. May be called multiple times. | |
| 49 bool EnsureInitialized(); | |
| 50 | |
| 51 // Waits for the process to exit. Returns true on success. It is up to the | |
| 52 // client to somehow signal the process to exit. | |
| 53 bool WaitForExit(int* exit_code); | |
| 54 | |
| 55 // Same as WaitForExit() but only waits for up to |timeout|. | |
| 56 bool WaitForExitWithTimeout(const base::TimeDelta& timeout, int* exit_code); | |
|
grt (UTC plus 2)
2015/02/03 21:20:45
i think TimeDelta is ordinarily passed by value (i
grt (UTC plus 2)
2015/02/04 03:04:47
my possibly flawed codesearch for uses of base::Ti
erikwright (departed)
2015/02/04 04:19:18
Sorry, just overlooked this the first time.
| |
| 57 | |
| 58 private: | |
| 59 CommandLineGenerator command_line_generator_; | |
| 60 base::win::ScopedHandle on_initialized_event_; | |
| 61 base::Process process_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(ChromeWatcherClient); | |
| 64 }; | |
| 65 | |
| 66 #endif // CHROME_APP_CHROME_WATCHER_CLIENT_WIN_H_ | |
| OLD | NEW |