| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ | 5 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ |
| 6 #define COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ | 6 #define COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // Constructs a watcher client that launches its watcher process using the | 26 // Constructs a watcher client that launches its watcher process using the |
| 27 // command line generated by |command_line_generator|. | 27 // command line generated by |command_line_generator|. |
| 28 explicit WatcherClient(const CommandLineGenerator& command_line_generator); | 28 explicit WatcherClient(const CommandLineGenerator& command_line_generator); |
| 29 | 29 |
| 30 // Launches the watcher process such that the child process is able to inherit | 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 | 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. | 32 // a non-threadsafe legacy launch mode that's compatible with Windows XP. |
| 33 void LaunchWatcher(); | 33 void LaunchWatcher(); |
| 34 | 34 |
| 35 void AddInheritedHandle(HANDLE handle); |
| 36 |
| 37 const base::Process& process() const { return process_; } |
| 38 |
| 35 // Accessors, exposed only for testing. | 39 // Accessors, exposed only for testing. |
| 36 bool use_legacy_launch() const { return use_legacy_launch_; } | 40 bool use_legacy_launch() const { return use_legacy_launch_; } |
| 37 void set_use_legacy_launch(bool use_legacy_launch) { | 41 void set_use_legacy_launch(bool use_legacy_launch) { |
| 38 use_legacy_launch_ = use_legacy_launch; | 42 use_legacy_launch_ = use_legacy_launch; |
| 39 } | 43 } |
| 40 base::ProcessHandle process() const { return process_.Handle(); } | |
| 41 | 44 |
| 42 private: | 45 private: |
| 43 // If true, the watcher process will be launched with XP legacy handle | 46 // 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 | 47 // 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. | 48 // child process, but it's the best we can do on XP. |
| 46 bool use_legacy_launch_; | 49 bool use_legacy_launch_; |
| 47 | 50 |
| 48 // The CommandLineGenerator passed to the constructor. | 51 // The CommandLineGenerator passed to the constructor. |
| 49 CommandLineGenerator command_line_generator_; | 52 CommandLineGenerator command_line_generator_; |
| 50 | 53 |
| 51 // A handle to the launched watcher process. Valid after a successful | 54 // A handle to the launched watcher process. Valid after a successful |
| 52 // LaunchWatcher() call. | 55 // LaunchWatcher() call. |
| 53 base::Process process_; | 56 base::Process process_; |
| 54 | 57 |
| 58 std::vector<HANDLE> inherited_handles_; |
| 59 |
| 55 DISALLOW_COPY_AND_ASSIGN(WatcherClient); | 60 DISALLOW_COPY_AND_ASSIGN(WatcherClient); |
| 56 }; | 61 }; |
| 57 | 62 |
| 58 } // namespace browser_watcher | 63 } // namespace browser_watcher |
| 59 | 64 |
| 60 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ | 65 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ |
| OLD | NEW |