Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "win8/viewer/metro_viewer_process_host.h" | 5 #include "win8/viewer/metro_viewer_process_host.h" |
| 6 | 6 |
| 7 #include <shlobj.h> | 7 #include <shlobj.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 MetroViewerProcessHost::~MetroViewerProcessHost() { | 60 MetroViewerProcessHost::~MetroViewerProcessHost() { |
| 61 if (!channel_) { | 61 if (!channel_) { |
| 62 instance_ = NULL; | 62 instance_ = NULL; |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 | 65 |
| 66 base::ProcessId viewer_process_id = GetViewerProcessId(); | 66 base::ProcessId viewer_process_id = GetViewerProcessId(); |
| 67 channel_->Close(); | 67 channel_->Close(); |
| 68 if (message_filter_) { | 68 if (message_filter_) { |
| 69 // Wait for the viewer process to go away. | 69 // Wait for the viewer process to go away. |
| 70 if (viewer_process_id != base::kNullProcessId) { | 70 DisposeViewer(viewer_process_id, false); |
| 71 base::ProcessHandle viewer_process = NULL; | |
| 72 base::OpenProcessHandleWithAccess( | |
| 73 viewer_process_id, | |
| 74 PROCESS_QUERY_INFORMATION | SYNCHRONIZE, | |
| 75 &viewer_process); | |
| 76 if (viewer_process) { | |
| 77 ::WaitForSingleObject(viewer_process, INFINITE); | |
| 78 ::CloseHandle(viewer_process); | |
| 79 } | |
| 80 } | |
| 81 channel_->RemoveFilter(message_filter_); | 71 channel_->RemoveFilter(message_filter_); |
| 82 } | 72 } |
| 83 instance_ = NULL; | 73 instance_ = NULL; |
| 84 } | 74 } |
| 85 | 75 |
| 76 void MetroViewerProcessHost::DisposeViewer(base::ProcessId viewer_process_id, | |
| 77 bool force_immediately) { | |
| 78 if (viewer_process_id != base::kNullProcessId) { | |
| 79 base::ProcessHandle viewer_process = NULL; | |
| 80 base::OpenProcessHandleWithAccess(viewer_process_id, | |
| 81 PROCESS_QUERY_INFORMATION | SYNCHRONIZE, | |
| 82 &viewer_process); | |
|
ananta
2014/09/20 00:32:54
You need to add PROCESS_TERMINATE to this mask
| |
| 83 if (viewer_process) { | |
| 84 if (force_immediately) { | |
| 85 // In tests, we don't want to wait around for the viewer to | |
| 86 // terminate, so kill it immediately. See http://crbug.com/411147 | |
| 87 // for more details. | |
| 88 ::TerminateProcess(viewer_process, 0); | |
| 89 } else { | |
| 90 ::WaitForSingleObject(viewer_process, INFINITE); | |
| 91 } | |
| 92 ::CloseHandle(viewer_process); | |
| 93 } | |
| 94 } | |
| 95 } | |
| 96 | |
| 86 base::ProcessId MetroViewerProcessHost::GetViewerProcessId() { | 97 base::ProcessId MetroViewerProcessHost::GetViewerProcessId() { |
| 87 if (channel_) | 98 if (channel_) |
| 88 return channel_->GetPeerPID(); | 99 return channel_->GetPeerPID(); |
| 89 return base::kNullProcessId; | 100 return base::kNullProcessId; |
| 90 } | 101 } |
| 91 | 102 |
| 92 bool MetroViewerProcessHost::LaunchViewerAndWaitForConnection( | 103 bool MetroViewerProcessHost::LaunchViewerAndWaitForConnection( |
| 93 const base::string16& app_user_model_id) { | 104 const base::string16& app_user_model_id) { |
| 94 DCHECK_EQ(base::kNullProcessId, channel_->GetPeerPID()); | 105 DCHECK_EQ(base::kNullProcessId, channel_->GetPeerPID()); |
| 95 | 106 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 const base::FilePath& folder) { | 346 const base::FilePath& folder) { |
| 336 if (success) | 347 if (success) |
| 337 select_folder_completion_callback_.Run(base::FilePath(folder), 0, NULL); | 348 select_folder_completion_callback_.Run(base::FilePath(folder), 0, NULL); |
| 338 else | 349 else |
| 339 failure_callback_.Run(NULL); | 350 failure_callback_.Run(NULL); |
| 340 select_folder_completion_callback_.Reset(); | 351 select_folder_completion_callback_.Reset(); |
| 341 failure_callback_.Reset(); | 352 failure_callback_.Reset(); |
| 342 } | 353 } |
| 343 | 354 |
| 344 } // namespace win8 | 355 } // namespace win8 |
| OLD | NEW |