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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/app/chrome_watcher_client_win.h
diff --git a/chrome/app/chrome_watcher_client_win.h b/chrome/app/chrome_watcher_client_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..f557273523351d15695465201d9a3bd891103692
--- /dev/null
+++ b/chrome/app/chrome_watcher_client_win.h
@@ -0,0 +1,66 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_APP_CHROME_WATCHER_CLIENT_WIN_H_
+#define CHROME_APP_CHROME_WATCHER_CLIENT_WIN_H_
+
+#include <windows.h>
+
+#include "base/callback.h"
+#include "base/command_line.h"
+#include "base/macros.h"
+#include "base/process/process.h"
+#include "base/win/scoped_handle.h"
+
+namespace base {
+class TimeDelta;
+} // namespace base
+
+// Launches a Chrome watcher process and permits the client to wait until the
+// process is fully initialized.
+class ChromeWatcherClient {
+ public:
+ // A CommandLineGenerator generates command lines that will launch a separate
+ // process and pass the supplied HANDLE values to WatcherMain in that process.
+ // The first HANDLE is an event that should be signaled when the watcher
+ // process is fully initialized. The second HANDLE is the process that the
+ // watcher process should watch.
+ // The process will be launched such that the HANDLEs are inherited by the
+ // new process.
+ typedef base::Callback<base::CommandLine(HANDLE, HANDLE)>
+ CommandLineGenerator;
+
+ // Constructs an instance that launches its watcher process using the command
+ // line generated by |command_line_generator|.
+ explicit ChromeWatcherClient(
+ const CommandLineGenerator& command_line_generator);
+
+ ~ChromeWatcherClient();
+
+ // Launches the watcher process such that the child process is able to inherit
+ // a handle to the current process. Returns true if the process is
+ // successfully launched.
+ bool LaunchWatcher();
+
+ // Blocks until the process, previously launched by LaunchWatcher, is either
+ // fully initialized or has terminated. Returns true if the process
+ // successfully initializes. May be called multiple times.
+ bool EnsureInitialized();
+
+ // Waits for the process to exit. Returns true on success. It is up to the
+ // client to somehow signal the process to exit.
+ bool WaitForExit(int* exit_code);
+
+ // Same as WaitForExit() but only waits for up to |timeout|.
+ 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.
+
+ private:
+ CommandLineGenerator command_line_generator_;
+ base::win::ScopedHandle on_initialized_event_;
+ base::Process process_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeWatcherClient);
+};
+
+#endif // CHROME_APP_CHROME_WATCHER_CLIENT_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698