Chromium Code Reviews| Index: components/browser_watcher/watcher_client_win.h |
| diff --git a/components/browser_watcher/watcher_client_win.h b/components/browser_watcher/watcher_client_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1e82342ad27851b91a9dc2031f4c52d2668f37ca |
| --- /dev/null |
| +++ b/components/browser_watcher/watcher_client_win.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2014 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 COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ |
| +#define COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ |
| + |
| +#include "base/command_line.h" |
| +#include "base/files/file_path.h" |
|
erikwright (departed)
2014/11/14 19:46:09
not used
Sigurður Ásgeirsson
2014/11/17 15:26:58
Done.
|
| +#include "base/macros.h" |
| +#include "base/process/process_handle.h" |
| +#include "base/win/scoped_handle.h" |
| + |
| +namespace browser_watcher { |
| + |
| +// An interface class to take care of the details in launching a browser |
| +// watch process. |
| +class WatcherClient { |
| + public: |
| + // Constructs a watcher client with a |base_command_line|, which should be |
| + // a command line sufficient to invoke the watcher process. This command |
| + // line will be augmented with the value of the inherited handle. |
| + explicit WatcherClient(const base::CommandLine& base_command_line); |
| + |
| + // Launches the watcher process. |
| + void LaunchWatcher(); |
| + |
| + // Accessors, exposed only for testing. |
| + bool use_legacy_launch() const { return use_legacy_launch_; } |
| + void set_use_legacy_launch(bool use_legacy_launch) { |
| + use_legacy_launch_ = use_legacy_launch; |
| + } |
| + base::ProcessHandle process() const { return process_.Get(); } |
| + |
| + private: |
| + // Launches |cmd_line| such that the child process is able to inherit |
| + // |handle|. If |use_legacy_launch_| is true, this uses a non-threadsafe |
| + // legacy launch mode that's compatible with Windows XP. |
| + // Returns a handle to the child process. |
| + base::win::ScopedHandle LaunchWatcherProcess( |
| + const base::CommandLine& cmd_line, base::ProcessHandle self_handle); |
| + |
| + // If true, the watcher process will be launched with XP legacy handle |
| + // inheritance. This is not thread safe and can leak random handles into the |
| + // child process, but it's the best we can do on XP. |
| + bool use_legacy_launch_; |
| + |
| + // The base command line passed to the constructor. |
| + base::CommandLine base_command_line_; |
| + |
| + // A handle to the launched watcher process. Valid after a successful |
| + // LaunchWatcher() call. |
| + base::win::ScopedHandle process_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WatcherClient); |
| +}; |
| + |
| +} // namespace browser_watcher |
| + |
| +#endif // COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ |