diff options
author | rvargas <rvargas@chromium.org> | 2014-12-10 10:40:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-10 18:40:55 +0000 |
commit | 42ba4693fb38d3d732085ceb2f517e4c0f2ae511 (patch) | |
tree | 2a9e9c4db93d7ab21f71878de723640b7d8daf1a /components | |
parent | eac795ddc1f52d14fdfb9a7eb193459f5766d27b (diff) | |
download | chromium_src-42ba4693fb38d3d732085ceb2f517e4c0f2ae511.zip chromium_src-42ba4693fb38d3d732085ceb2f517e4c0f2ae511.tar.gz chromium_src-42ba4693fb38d3d732085ceb2f517e4c0f2ae511.tar.bz2 |
Update browser_watcher to use the new version of LaunchProcess.
BUG=417532
Review URL: https://codereview.chromium.org/791663003
Cr-Commit-Position: refs/heads/master@{#307737}
Diffstat (limited to 'components')
-rw-r--r-- | components/browser_watcher/watcher_client_win.cc | 25 | ||||
-rw-r--r-- | components/browser_watcher/watcher_client_win.h | 11 |
2 files changed, 16 insertions, 20 deletions
diff --git a/components/browser_watcher/watcher_client_win.cc b/components/browser_watcher/watcher_client_win.cc index 84b1ee57..ee654e7 100644 --- a/components/browser_watcher/watcher_client_win.cc +++ b/components/browser_watcher/watcher_client_win.cc @@ -16,8 +16,8 @@ namespace browser_watcher { namespace { -base::win::ScopedHandle OpenOwnProcessInheritable() { - return base::win::ScopedHandle( +base::Process OpenOwnProcessInheritable() { + return base::Process( ::OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, TRUE, // Ineritable handle. base::GetCurrentProcId())); @@ -33,12 +33,11 @@ void AddHandleArgument(base::ProcessHandle handle, WatcherClient::WatcherClient(const base::CommandLine& base_command_line) : use_legacy_launch_(base::win::GetVersion() < base::win::VERSION_VISTA), - base_command_line_(base_command_line), - process_(base::kNullProcessHandle) { + base_command_line_(base_command_line) { } -base::win::ScopedHandle WatcherClient::LaunchWatcherProcess( - const base::CommandLine& cmd_line, base::ProcessHandle handle) { +void WatcherClient::LaunchWatcherProcess(const base::CommandLine& cmd_line, + base::Process self) { base::HandlesToInheritVector to_inherit; base::LaunchOptions options; options.start_hidden = true; @@ -48,28 +47,26 @@ base::win::ScopedHandle WatcherClient::LaunchWatcherProcess( } else { // Launch the child process inheriting only |handle| on // Vista and better. - to_inherit.push_back(handle); + to_inherit.push_back(self.Handle()); options.handles_to_inherit = &to_inherit; } - base::ProcessHandle process = base::kNullProcessHandle; - if (!base::LaunchProcess(cmd_line, options, &process)) + process_ = base::LaunchProcess(cmd_line, options); + if (!process_.IsValid()) LOG(ERROR) << "Failed to launch browser watcher."; - - return base::win::ScopedHandle(process); } void WatcherClient::LaunchWatcher() { DCHECK(!process_.IsValid()); // Build the command line for the watcher process. - base::win::ScopedHandle self(OpenOwnProcessInheritable()); + base::Process self = OpenOwnProcessInheritable(); DCHECK(self.IsValid()); base::CommandLine cmd_line(base_command_line_); - AddHandleArgument(self.Get(), &cmd_line); + AddHandleArgument(self.Handle(), &cmd_line); // Launch it. - process_ = LaunchWatcherProcess(cmd_line, self.Get()); + LaunchWatcherProcess(cmd_line, self.Pass()); } } // namespace browser_watcher diff --git a/components/browser_watcher/watcher_client_win.h b/components/browser_watcher/watcher_client_win.h index 125811b..11caed8 100644 --- a/components/browser_watcher/watcher_client_win.h +++ b/components/browser_watcher/watcher_client_win.h @@ -7,8 +7,7 @@ #include "base/command_line.h" #include "base/macros.h" -#include "base/process/process_handle.h" -#include "base/win/scoped_handle.h" +#include "base/process/process.h" namespace browser_watcher { @@ -29,15 +28,15 @@ class WatcherClient { void set_use_legacy_launch(bool use_legacy_launch) { use_legacy_launch_ = use_legacy_launch; } - base::ProcessHandle process() const { return process_.Get(); } + base::ProcessHandle process() const { return process_.Handle(); } 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); + void LaunchWatcherProcess(const base::CommandLine& cmd_line, + base::Process self); // 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 @@ -49,7 +48,7 @@ class WatcherClient { // A handle to the launched watcher process. Valid after a successful // LaunchWatcher() call. - base::win::ScopedHandle process_; + base::Process process_; DISALLOW_COPY_AND_ASSIGN(WatcherClient); }; |