| 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" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/process/process.h" | 14 #include "base/process/process.h" |
| 15 #include "base/process/process_handle.h" | |
| 16 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 17 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 19 #include "base/win/scoped_comptr.h" | 18 #include "base/win/scoped_comptr.h" |
| 20 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
| 21 #include "ipc/ipc_channel_proxy.h" | 20 #include "ipc/ipc_channel_proxy.h" |
| 22 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
| 23 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
| 24 #include "ui/aura/remote_window_tree_host_win.h" | 23 #include "ui/aura/remote_window_tree_host_win.h" |
| 25 #include "ui/metro_viewer/metro_viewer_messages.h" | 24 #include "ui/metro_viewer/metro_viewer_messages.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 if (!channel_) { | 60 if (!channel_) { |
| 62 instance_ = NULL; | 61 instance_ = NULL; |
| 63 return; | 62 return; |
| 64 } | 63 } |
| 65 | 64 |
| 66 base::ProcessId viewer_process_id = GetViewerProcessId(); | 65 base::ProcessId viewer_process_id = GetViewerProcessId(); |
| 67 channel_->Close(); | 66 channel_->Close(); |
| 68 if (message_filter_.get()) { | 67 if (message_filter_.get()) { |
| 69 // Wait for the viewer process to go away. | 68 // Wait for the viewer process to go away. |
| 70 if (viewer_process_id != base::kNullProcessId) { | 69 if (viewer_process_id != base::kNullProcessId) { |
| 71 base::ProcessHandle viewer_process = NULL; | 70 base::Process viewer_process = |
| 72 base::OpenProcessHandleWithAccess( | 71 base::Process::OpenWithAccess( |
| 73 viewer_process_id, | 72 viewer_process_id, |
| 74 PROCESS_QUERY_INFORMATION | SYNCHRONIZE, | 73 PROCESS_QUERY_INFORMATION | SYNCHRONIZE); |
| 75 &viewer_process); | 74 if (viewer_process.IsValid()) { |
| 76 if (viewer_process) { | 75 int exit_code; |
| 77 ::WaitForSingleObject(viewer_process, INFINITE); | 76 viewer_process.WaitForExit(&exit_code); |
| 78 ::CloseHandle(viewer_process); | |
| 79 } | 77 } |
| 80 } | 78 } |
| 81 channel_->RemoveFilter(message_filter_.get()); | 79 channel_->RemoveFilter(message_filter_.get()); |
| 82 } | 80 } |
| 83 instance_ = NULL; | 81 instance_ = NULL; |
| 84 } | 82 } |
| 85 | 83 |
| 86 base::ProcessId MetroViewerProcessHost::GetViewerProcessId() { | 84 base::ProcessId MetroViewerProcessHost::GetViewerProcessId() { |
| 87 if (channel_) | 85 if (channel_) |
| 88 return channel_->GetPeerPID(); | 86 return channel_->GetPeerPID(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 const base::FilePath& folder) { | 333 const base::FilePath& folder) { |
| 336 if (success) | 334 if (success) |
| 337 select_folder_completion_callback_.Run(base::FilePath(folder), 0, NULL); | 335 select_folder_completion_callback_.Run(base::FilePath(folder), 0, NULL); |
| 338 else | 336 else |
| 339 failure_callback_.Run(NULL); | 337 failure_callback_.Run(NULL); |
| 340 select_folder_completion_callback_.Reset(); | 338 select_folder_completion_callback_.Reset(); |
| 341 failure_callback_.Reset(); | 339 failure_callback_.Reset(); |
| 342 } | 340 } |
| 343 | 341 |
| 344 } // namespace win8 | 342 } // namespace win8 |
| OLD | NEW |