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 #include "content/public/common/child_process_host.h" |
18 | 18 |
19 NaClBrokerHost::NaClBrokerHost() | 19 NaClBrokerHost::NaClBrokerHost() |
20 : BrowserChildProcessHost(content::PROCESS_TYPE_NACL_BROKER), | 20 : BrowserChildProcessHost(content::PROCESS_TYPE_NACL_BROKER), |
21 stopping_(false) { | 21 stopping_(false) { |
22 } | 22 } |
23 | 23 |
24 NaClBrokerHost::~NaClBrokerHost() { | 24 NaClBrokerHost::~NaClBrokerHost() { |
25 } | 25 } |
26 | 26 |
27 bool NaClBrokerHost::Init() { | 27 bool NaClBrokerHost::Init() { |
28 // 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. |
29 if (!child_process_host()->CreateChannel()) | 29 std::string channel_id = child_process_host()->CreateChannel(); |
| 30 if (channel_id.empty()) |
30 return false; | 31 return false; |
31 | 32 |
32 // Create the path to the nacl broker/loader executable. | 33 // Create the path to the nacl broker/loader executable. |
33 FilePath module_path; | 34 FilePath module_path; |
34 if (!PathService::Get(base::FILE_MODULE, &module_path)) | 35 if (!PathService::Get(base::FILE_MODULE, &module_path)) |
35 return false; | 36 return false; |
36 | 37 |
37 FilePath nacl_path = module_path.DirName().Append(chrome::kNaClAppName); | 38 FilePath nacl_path = module_path.DirName().Append(chrome::kNaClAppName); |
38 CommandLine* cmd_line = new CommandLine(nacl_path); | 39 CommandLine* cmd_line = new CommandLine(nacl_path); |
39 nacl::CopyNaClCommandLineArguments(cmd_line); | 40 nacl::CopyNaClCommandLineArguments(cmd_line); |
40 | 41 |
41 cmd_line->AppendSwitchASCII(switches::kProcessType, | 42 cmd_line->AppendSwitchASCII(switches::kProcessType, |
42 switches::kNaClBrokerProcess); | 43 switches::kNaClBrokerProcess); |
43 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, | 44 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
44 child_process_host()->channel_id()); | |
45 if (logging::DialogsAreSuppressed()) | 45 if (logging::DialogsAreSuppressed()) |
46 cmd_line->AppendSwitch(switches::kNoErrorDialogs); | 46 cmd_line->AppendSwitch(switches::kNoErrorDialogs); |
47 | 47 |
48 BrowserChildProcessHost::Launch(FilePath(), cmd_line); | 48 BrowserChildProcessHost::Launch(FilePath(), cmd_line); |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
52 bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) { | 52 bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) { |
53 bool handled = true; | 53 bool handled = true; |
54 IPC_BEGIN_MESSAGE_MAP(NaClBrokerHost, msg) | 54 IPC_BEGIN_MESSAGE_MAP(NaClBrokerHost, msg) |
(...skipping 10 matching lines...) Expand all Loading... |
65 | 65 |
66 void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id, | 66 void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id, |
67 base::ProcessHandle handle) { | 67 base::ProcessHandle handle) { |
68 NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); | 68 NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); |
69 } | 69 } |
70 | 70 |
71 void NaClBrokerHost::StopBroker() { | 71 void NaClBrokerHost::StopBroker() { |
72 stopping_ = true; | 72 stopping_ = true; |
73 Send(new NaClProcessMsg_StopBroker()); | 73 Send(new NaClProcessMsg_StopBroker()); |
74 } | 74 } |
OLD | NEW |