Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ | |
| 6 #define COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ | |
| 7 | |
| 8 #include "base/command_line.h" | |
| 9 #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.
| |
| 10 #include "base/macros.h" | |
| 11 #include "base/process/process_handle.h" | |
| 12 #include "base/win/scoped_handle.h" | |
| 13 | |
| 14 namespace browser_watcher { | |
| 15 | |
| 16 // An interface class to take care of the details in launching a browser | |
| 17 // watch process. | |
| 18 class WatcherClient { | |
| 19 public: | |
| 20 // Constructs a watcher client with a |base_command_line|, which should be | |
| 21 // a command line sufficient to invoke the watcher process. This command | |
| 22 // line will be augmented with the value of the inherited handle. | |
| 23 explicit WatcherClient(const base::CommandLine& base_command_line); | |
| 24 | |
| 25 // Launches the watcher process. | |
| 26 void LaunchWatcher(); | |
| 27 | |
| 28 // Accessors, exposed only for testing. | |
| 29 bool use_legacy_launch() const { return use_legacy_launch_; } | |
| 30 void set_use_legacy_launch(bool use_legacy_launch) { | |
| 31 use_legacy_launch_ = use_legacy_launch; | |
| 32 } | |
| 33 base::ProcessHandle process() const { return process_.Get(); } | |
| 34 | |
| 35 private: | |
| 36 // Launches |cmd_line| such that the child process is able to inherit | |
| 37 // |handle|. If |use_legacy_launch_| is true, this uses a non-threadsafe | |
| 38 // legacy launch mode that's compatible with Windows XP. | |
| 39 // Returns a handle to the child process. | |
| 40 base::win::ScopedHandle LaunchWatcherProcess( | |
| 41 const base::CommandLine& cmd_line, base::ProcessHandle self_handle); | |
| 42 | |
| 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_; | |
| 47 | |
| 48 // The base command line passed to the constructor. | |
| 49 base::CommandLine base_command_line_; | |
| 50 | |
| 51 // A handle to the launched watcher process. Valid after a successful | |
| 52 // LaunchWatcher() call. | |
| 53 base::win::ScopedHandle process_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(WatcherClient); | |
| 56 }; | |
| 57 | |
| 58 } // namespace browser_watcher | |
| 59 | |
| 60 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ | |
| OLD | NEW |