| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/nacl_host/nacl_broker_host_win.h" | 5 #include "chrome/browser/nacl_host/nacl_broker_host_win.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "ipc/ipc_switches.h" | 9 #include "ipc/ipc_switches.h" |
| 10 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" | 10 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" |
| 11 #include "chrome/browser/nacl_host/nacl_process_host.h" | 11 #include "chrome/browser/nacl_host/nacl_process_host.h" |
| 12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/logging_chrome.h" | 14 #include "chrome/common/logging_chrome.h" |
| 15 #include "chrome/common/nacl_cmd_line.h" | 15 #include "chrome/common/nacl_cmd_line.h" |
| 16 #include "chrome/common/nacl_messages.h" | 16 #include "chrome/common/nacl_messages.h" |
| 17 #include "content/common/child_process_host.h" |
| 17 | 18 |
| 18 NaClBrokerHost::NaClBrokerHost() | 19 NaClBrokerHost::NaClBrokerHost() |
| 19 : BrowserChildProcessHost(content::PROCESS_TYPE_NACL_BROKER), | 20 : BrowserChildProcessHost(content::PROCESS_TYPE_NACL_BROKER), |
| 20 stopping_(false) { | 21 stopping_(false) { |
| 21 } | 22 } |
| 22 | 23 |
| 23 NaClBrokerHost::~NaClBrokerHost() { | 24 NaClBrokerHost::~NaClBrokerHost() { |
| 24 } | 25 } |
| 25 | 26 |
| 26 bool NaClBrokerHost::Init() { | 27 bool NaClBrokerHost::Init() { |
| 27 // Create the channel that will be used for communicating with the broker. | 28 // Create the channel that will be used for communicating with the broker. |
| 28 if (!CreateChannel()) | 29 if (!child_process_host()->CreateChannel()) |
| 29 return false; | 30 return false; |
| 30 | 31 |
| 31 // Create the path to the nacl broker/loader executable. | 32 // Create the path to the nacl broker/loader executable. |
| 32 FilePath module_path; | 33 FilePath module_path; |
| 33 if (!PathService::Get(base::FILE_MODULE, &module_path)) | 34 if (!PathService::Get(base::FILE_MODULE, &module_path)) |
| 34 return false; | 35 return false; |
| 35 | 36 |
| 36 FilePath nacl_path = module_path.DirName().Append(chrome::kNaClAppName); | 37 FilePath nacl_path = module_path.DirName().Append(chrome::kNaClAppName); |
| 37 CommandLine* cmd_line = new CommandLine(nacl_path); | 38 CommandLine* cmd_line = new CommandLine(nacl_path); |
| 38 nacl::CopyNaClCommandLineArguments(cmd_line); | 39 nacl::CopyNaClCommandLineArguments(cmd_line); |
| 39 | 40 |
| 40 cmd_line->AppendSwitchASCII(switches::kProcessType, | 41 cmd_line->AppendSwitchASCII(switches::kProcessType, |
| 41 switches::kNaClBrokerProcess); | 42 switches::kNaClBrokerProcess); |
| 42 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); | 43 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, |
| 44 child_process_host()->channel_id()); |
| 43 if (logging::DialogsAreSuppressed()) | 45 if (logging::DialogsAreSuppressed()) |
| 44 cmd_line->AppendSwitch(switches::kNoErrorDialogs); | 46 cmd_line->AppendSwitch(switches::kNoErrorDialogs); |
| 45 | 47 |
| 46 BrowserChildProcessHost::Launch(FilePath(), cmd_line); | 48 BrowserChildProcessHost::Launch(FilePath(), cmd_line); |
| 47 return true; | 49 return true; |
| 48 } | 50 } |
| 49 | 51 |
| 50 bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) { | 52 bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) { |
| 51 bool handled = true; | 53 bool handled = true; |
| 52 IPC_BEGIN_MESSAGE_MAP(NaClBrokerHost, msg) | 54 IPC_BEGIN_MESSAGE_MAP(NaClBrokerHost, msg) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 | 65 |
| 64 void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id, | 66 void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id, |
| 65 base::ProcessHandle handle) { | 67 base::ProcessHandle handle) { |
| 66 NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); | 68 NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); |
| 67 } | 69 } |
| 68 | 70 |
| 69 void NaClBrokerHost::StopBroker() { | 71 void NaClBrokerHost::StopBroker() { |
| 70 stopping_ = true; | 72 stopping_ = true; |
| 71 Send(new NaClProcessMsg_StopBroker()); | 73 Send(new NaClProcessMsg_StopBroker()); |
| 72 } | 74 } |
| OLD | NEW |