| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/nacl_host/nacl_broker_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" |
| 8 #include "ipc/ipc_switches.h" | 9 #include "ipc/ipc_switches.h" |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/nacl_host/nacl_broker_service.h" | 11 #include "chrome/browser/nacl_host/nacl_broker_service.h" |
| 11 #include "chrome/browser/nacl_host/nacl_process_host.h" | 12 #include "chrome/browser/nacl_host/nacl_process_host.h" |
| 12 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/nacl_cmd_line.h" | 15 #include "chrome/common/nacl_cmd_line.h" |
| 15 #include "chrome/common/nacl_messages.h" | 16 #include "chrome/common/nacl_messages.h" |
| 16 | 17 |
| 17 NaClBrokerHost::NaClBrokerHost( | 18 NaClBrokerHost::NaClBrokerHost( |
| 18 ResourceDispatcherHost* resource_dispatcher_host) | 19 ResourceDispatcherHost* resource_dispatcher_host) |
| 19 : ChildProcessHost(NACL_BROKER_PROCESS, resource_dispatcher_host) { | 20 : ChildProcessHost(NACL_BROKER_PROCESS, resource_dispatcher_host) { |
| 20 } | 21 } |
| 21 | 22 |
| 22 NaClBrokerHost::~NaClBrokerHost() { | 23 NaClBrokerHost::~NaClBrokerHost() { |
| 23 } | 24 } |
| 24 | 25 |
| 25 URLRequestContext* NaClBrokerHost::GetRequestContext( | 26 URLRequestContext* NaClBrokerHost::GetRequestContext( |
| 26 uint32 request_id, | 27 uint32 request_id, |
| 27 const ViewHostMsg_Resource_Request& request_data) { | 28 const ViewHostMsg_Resource_Request& request_data) { |
| 28 return NULL; | 29 return NULL; |
| 29 } | 30 } |
| 30 | 31 |
| 31 bool NaClBrokerHost::Init() { | 32 bool NaClBrokerHost::Init() { |
| 32 // Create the channel that will be used for communicating with the broker. | 33 // Create the channel that will be used for communicating with the broker. |
| 33 if (!CreateChannel()) | 34 if (!CreateChannel()) |
| 34 return false; | 35 return false; |
| 35 | 36 |
| 36 // Create the path to the nacl broker/loader executable. | 37 // Create the path to the nacl broker/loader executable. |
| 37 FilePath exe_path = GetChildPath(false); | 38 FilePath module_path; |
| 38 if (exe_path.empty()) | 39 if (!PathService::Get(base::FILE_MODULE, &module_path)) |
| 39 return false; | 40 return false; |
| 40 | 41 |
| 41 FilePath nacl_path = exe_path.DirName().Append(chrome::kNaClAppName); | 42 FilePath nacl_path = module_path.DirName().Append(chrome::kNaClAppName); |
| 42 CommandLine* cmd_line = new CommandLine(nacl_path); | 43 CommandLine* cmd_line = new CommandLine(nacl_path); |
| 43 nacl::CopyNaClCommandLineArguments(cmd_line); | 44 nacl::CopyNaClCommandLineArguments(cmd_line); |
| 44 | 45 |
| 45 cmd_line->AppendSwitchWithValue(switches::kProcessType, | 46 cmd_line->AppendSwitchWithValue(switches::kProcessType, |
| 46 switches::kNaClBrokerProcess); | 47 switches::kNaClBrokerProcess); |
| 47 | 48 |
| 48 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, | 49 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, |
| 49 ASCIIToWide(channel_id())); | 50 ASCIIToWide(channel_id())); |
| 50 | 51 |
| 51 ChildProcessHost::Launch(FilePath(), cmd_line); | 52 ChildProcessHost::Launch(FilePath(), cmd_line); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 65 | 66 |
| 66 bool NaClBrokerHost::LaunchLoader( | 67 bool NaClBrokerHost::LaunchLoader( |
| 67 const std::wstring& loader_channel_id) { | 68 const std::wstring& loader_channel_id) { |
| 68 return Send(new NaClProcessMsg_LaunchLoaderThroughBroker(loader_channel_id)); | 69 return Send(new NaClProcessMsg_LaunchLoaderThroughBroker(loader_channel_id)); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id, | 72 void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id, |
| 72 base::ProcessHandle handle) { | 73 base::ProcessHandle handle) { |
| 73 NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); | 74 NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); |
| 74 } | 75 } |
| OLD | NEW |