OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/nacl/broker/nacl_broker_listener.h" | 5 #include "components/nacl/broker/nacl_broker_listener.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 NaClBrokerListener::NaClBrokerListener() | 33 NaClBrokerListener::NaClBrokerListener() |
34 : browser_handle_(base::kNullProcessHandle) { | 34 : browser_handle_(base::kNullProcessHandle) { |
35 } | 35 } |
36 | 36 |
37 NaClBrokerListener::~NaClBrokerListener() { | 37 NaClBrokerListener::~NaClBrokerListener() { |
38 base::CloseProcessHandle(browser_handle_); | 38 base::CloseProcessHandle(browser_handle_); |
39 } | 39 } |
40 | 40 |
41 void NaClBrokerListener::Listen() { | 41 void NaClBrokerListener::Listen() { |
42 std::string channel_name = | 42 std::string channel_name = |
43 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 43 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
44 switches::kProcessChannelID); | 44 switches::kProcessChannelID); |
45 channel_ = IPC::Channel::CreateClient(channel_name, this); | 45 channel_ = IPC::Channel::CreateClient(channel_name, this); |
46 CHECK(channel_->Connect()); | 46 CHECK(channel_->Connect()); |
47 base::MessageLoop::current()->Run(); | 47 base::MessageLoop::current()->Run(); |
48 } | 48 } |
49 | 49 |
50 // NOTE: changes to this method need to be reviewed by the security team. | 50 // NOTE: changes to this method need to be reviewed by the security team. |
51 void NaClBrokerListener::PreSpawnTarget(sandbox::TargetPolicy* policy, | 51 void NaClBrokerListener::PreSpawnTarget(sandbox::TargetPolicy* policy, |
52 bool* success) { | 52 bool* success) { |
53 // This code is duplicated in chrome_content_browser_client.cc. | 53 // This code is duplicated in chrome_content_browser_client.cc. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 void NaClBrokerListener::OnLaunchLoaderThroughBroker( | 88 void NaClBrokerListener::OnLaunchLoaderThroughBroker( |
89 const std::string& loader_channel_id) { | 89 const std::string& loader_channel_id) { |
90 base::ProcessHandle loader_handle_in_browser = 0; | 90 base::ProcessHandle loader_handle_in_browser = 0; |
91 | 91 |
92 // Create the path to the nacl broker/loader executable - it's the executable | 92 // Create the path to the nacl broker/loader executable - it's the executable |
93 // this code is running in. | 93 // this code is running in. |
94 base::FilePath exe_path; | 94 base::FilePath exe_path; |
95 PathService::Get(base::FILE_EXE, &exe_path); | 95 PathService::Get(base::FILE_EXE, &exe_path); |
96 if (!exe_path.empty()) { | 96 if (!exe_path.empty()) { |
97 CommandLine* cmd_line = new CommandLine(exe_path); | 97 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
98 nacl::CopyNaClCommandLineArguments(cmd_line); | 98 nacl::CopyNaClCommandLineArguments(cmd_line); |
99 | 99 |
100 cmd_line->AppendSwitchASCII(switches::kProcessType, | 100 cmd_line->AppendSwitchASCII(switches::kProcessType, |
101 switches::kNaClLoaderProcess); | 101 switches::kNaClLoaderProcess); |
102 | 102 |
103 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, | 103 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, |
104 loader_channel_id); | 104 loader_channel_id); |
105 | 105 |
106 base::Process loader_process = content::StartSandboxedProcess(this, | 106 base::Process loader_process = content::StartSandboxedProcess(this, |
107 cmd_line); | 107 cmd_line); |
(...skipping 22 matching lines...) Expand all Loading... |
130 const std::string& startup_info) { | 130 const std::string& startup_info) { |
131 NaClStartDebugExceptionHandlerThread( | 131 NaClStartDebugExceptionHandlerThread( |
132 process_handle, startup_info, | 132 process_handle, startup_info, |
133 base::MessageLoopProxy::current(), | 133 base::MessageLoopProxy::current(), |
134 base::Bind(SendReply, channel_.get(), pid)); | 134 base::Bind(SendReply, channel_.get(), pid)); |
135 } | 135 } |
136 | 136 |
137 void NaClBrokerListener::OnStopBroker() { | 137 void NaClBrokerListener::OnStopBroker() { |
138 base::MessageLoop::current()->Quit(); | 138 base::MessageLoop::current()->Quit(); |
139 } | 139 } |
OLD | NEW |