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

Side by Side Diff: chrome/app/chrome_watcher_client_win.h

Issue 886613002: Introduce the ability to wait for the watcher process to initialize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some comments. Created 5 years, 10 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
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698