Correctly track texture cleared state for sharing
[chromium-blink-merge.git] / components / browser_watcher / watcher_client_win.h
blob5ae3c96f2a4393caf5e5fc7a01cd6ba4fef76d88
1 // Copyright (c) 2014 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.
5 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_
6 #define COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/process/process.h"
12 namespace base {
13 class CommandLine;
14 } // namespace base
16 namespace browser_watcher {
18 // An interface class to take care of the details in launching a browser
19 // watch process.
20 class WatcherClient {
21 public:
22 // A CommandLineGenerator generates command lines that will launch a separate
23 // process and pass the supplied HANDLE to ExitCodeWatcher in that process.
24 typedef base::Callback<base::CommandLine(HANDLE)> CommandLineGenerator;
26 // Constructs a watcher client that launches its watcher process using the
27 // command line generated by |command_line_generator|.
28 explicit WatcherClient(const CommandLineGenerator& command_line_generator);
30 // Launches the watcher process such that the child process is able to inherit
31 // a handle to the current process. If use_legacy_launch() is true, this uses
32 // a non-threadsafe legacy launch mode that's compatible with Windows XP.
33 void LaunchWatcher();
35 // Accessors, exposed only for testing.
36 bool use_legacy_launch() const { return use_legacy_launch_; }
37 void set_use_legacy_launch(bool use_legacy_launch) {
38 use_legacy_launch_ = use_legacy_launch;
40 base::ProcessHandle process() const { return process_.Handle(); }
42 private:
43 // If true, the watcher process will be launched with XP legacy handle
44 // inheritance. This is not thread safe and can leak random handles into the
45 // child process, but it's the best we can do on XP.
46 bool use_legacy_launch_;
48 // The CommandLineGenerator passed to the constructor.
49 CommandLineGenerator command_line_generator_;
51 // A handle to the launched watcher process. Valid after a successful
52 // LaunchWatcher() call.
53 base::Process process_;
55 DISALLOW_COPY_AND_ASSIGN(WatcherClient);
58 } // namespace browser_watcher
60 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_