| 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 "chrome/browser/browser_process_platform_part_winaura.h" | 5 #include "chrome/browser/browser_process_platform_part_winaura.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "chrome/browser/metro_viewer/metro_viewer_process_host_win.h" | 10 #include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_win.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 | 12 |
| 13 BrowserProcessPlatformPart::BrowserProcessPlatformPart() { | 13 BrowserProcessPlatformPart::BrowserProcessPlatformPart() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() { | 16 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 void BrowserProcessPlatformPart::PlatformSpecificCommandLineProcessing( | 19 void BrowserProcessPlatformPart::PlatformSpecificCommandLineProcessing( |
| 20 const CommandLine& command_line) { | 20 const CommandLine& command_line) { |
| 21 if (command_line.HasSwitch(switches::kViewerConnection) && | 21 if (command_line.HasSwitch(switches::kViewerConnection) && |
| 22 !metro_viewer_process_host_.get()) { | 22 !metro_viewer_process_host_.get()) { |
| 23 // Tell the metro viewer process host to connect to the given IPC channel. | 23 // Tell the metro viewer process host to connect to the given IPC channel. |
| 24 metro_viewer_process_host_.reset( | 24 metro_viewer_process_host_.reset( |
| 25 new MetroViewerProcessHost( | 25 new ChromeMetroViewerProcessHost( |
| 26 command_line.GetSwitchValueASCII(switches::kViewerConnection))); | 26 command_line.GetSwitchValueASCII(switches::kViewerConnection))); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 void BrowserProcessPlatformPart::StartTearDown() { | 30 void BrowserProcessPlatformPart::StartTearDown() { |
| 31 } | 31 } |
| 32 | 32 |
| 33 void BrowserProcessPlatformPart::OnMetroViewerProcessTerminated() { | 33 void BrowserProcessPlatformPart::OnMetroViewerProcessTerminated() { |
| 34 metro_viewer_process_host_.reset(); | 34 metro_viewer_process_host_.reset(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void BrowserProcessPlatformPart::TerminateMetroViewerProcess() { | 37 void BrowserProcessPlatformPart::TerminateMetroViewerProcess() { |
| 38 if (metro_viewer_process_host_) { | 38 if (metro_viewer_process_host_) { |
| 39 base::ProcessId viewer_id = | 39 base::ProcessId viewer_id = |
| 40 metro_viewer_process_host_->GetViewerProcessId(); | 40 metro_viewer_process_host_->GetViewerProcessId(); |
| 41 if (viewer_id == base::kNullProcessId) | 41 if (viewer_id == base::kNullProcessId) |
| 42 return; | 42 return; |
| 43 // The viewer doesn't hold any state so it is fine to kill it before it | 43 // The viewer doesn't hold any state so it is fine to kill it before it |
| 44 // cleanly exits. This will trigger MetroViewerProcessHost::OnChannelError() | 44 // cleanly exits. This will trigger MetroViewerProcessHost::OnChannelError() |
| 45 // which will cleanup references to g_browser_process. | 45 // which will cleanup references to g_browser_process. |
| 46 bool success = base::KillProcessById(viewer_id, 0, true); | 46 bool success = base::KillProcessById(viewer_id, 0, true); |
| 47 DCHECK(success); | 47 DCHECK(success); |
| 48 } | 48 } |
| 49 } | 49 } |
| OLD | NEW |