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

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: Review feedback. 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/time/time.h"
15 #include "base/win/scoped_handle.h"
16
17 // Launches a Chrome watcher process and permits the client to wait until the
18 // process is fully initialized.
19 class ChromeWatcherClient {
20 public:
21 // A CommandLineGenerator generates command lines that will launch a separate
22 // process and pass the supplied HANDLE values to WatcherMain in that process.
23 // The first HANDLE is the process that the watcher process should watch. The
24 // second HANDLE is an event that should be signaled when the watcher process
25 // is fully initialized. The process will be launched such that the HANDLEs
26 // are inherited by the new process.
27 typedef base::Callback<base::CommandLine(HANDLE, HANDLE)>
28 CommandLineGenerator;
29
30 // Constructs an instance that launches its watcher process using the command
31 // line generated by |command_line_generator|.
32 explicit ChromeWatcherClient(
33 const CommandLineGenerator& command_line_generator);
34
35 ~ChromeWatcherClient();
36
37 // Launches the watcher process such that the child process is able to inherit
38 // a handle to the current process. Returns true if the process is
39 // successfully launched.
40 bool LaunchWatcher();
41
42 // Blocks until the process, previously launched by LaunchWatcher, is either
43 // fully initialized or has terminated. Returns true if the process
44 // successfully initializes. May be called multiple times.
45 bool EnsureInitialized();
46
47 // Waits for the process to exit. Returns true on success. It is up to the
48 // client to somehow signal the process to exit.
49 bool WaitForExit(int* exit_code);
50
51 // Same as WaitForExit() but only waits for up to |timeout|.
52 bool WaitForExitWithTimeout(base::TimeDelta timeout, int* exit_code);
53
54 private:
55 CommandLineGenerator command_line_generator_;
56 base::win::ScopedHandle on_initialized_event_;
57 base::Process process_;
58
59 DISALLOW_COPY_AND_ASSIGN(ChromeWatcherClient);
60 };
61
62 #endif // CHROME_APP_CHROME_WATCHER_CLIENT_WIN_H_
OLDNEW
« no previous file with comments | « chrome/app/chrome_watcher_client_unittest_win.cc ('k') | chrome/app/chrome_watcher_client_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698