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/loader/nacl_listener.h" | 5 #include "components/nacl/loader/nacl_listener.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 g_listener->Send(new NaClProcessHostMsg_DebugStubPortSelected(port)); | 132 g_listener->Send(new NaClProcessHostMsg_DebugStubPortSelected(port)); |
133 } | 133 } |
134 | 134 |
135 #endif | 135 #endif |
136 | 136 |
137 // Creates the PPAPI IPC channel between the NaCl IRT and the host | 137 // Creates the PPAPI IPC channel between the NaCl IRT and the host |
138 // (browser/renderer) process, and starts to listen it on the thread where | 138 // (browser/renderer) process, and starts to listen it on the thread where |
139 // the given message_loop_proxy runs. | 139 // the given message_loop_proxy runs. |
140 // Also, creates and sets the corresponding NaClDesc to the given nap with | 140 // Also, creates and sets the corresponding NaClDesc to the given nap with |
141 // the FD #. | 141 // the FD #. |
142 scoped_refptr<NaClIPCAdapter> SetUpIPCAdapter( | 142 void SetUpIPCAdapter( |
143 IPC::ChannelHandle* handle, | 143 IPC::ChannelHandle* handle, |
144 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 144 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
145 struct NaClApp* nap, | 145 struct NaClApp* nap, |
146 int nacl_fd) { | 146 int nacl_fd, |
| 147 NaClIPCAdapter::ResolveFileTokenCallback resolve_file_token_cb) { |
147 scoped_refptr<NaClIPCAdapter> ipc_adapter( | 148 scoped_refptr<NaClIPCAdapter> ipc_adapter( |
148 new NaClIPCAdapter(*handle, message_loop_proxy.get())); | 149 new NaClIPCAdapter(*handle, |
| 150 message_loop_proxy.get(), |
| 151 resolve_file_token_cb)); |
149 ipc_adapter->ConnectChannel(); | 152 ipc_adapter->ConnectChannel(); |
150 #if defined(OS_POSIX) | 153 #if defined(OS_POSIX) |
151 handle->socket = | 154 handle->socket = |
152 base::FileDescriptor(ipc_adapter->TakeClientFileDescriptor()); | 155 base::FileDescriptor(ipc_adapter->TakeClientFileDescriptor()); |
153 #endif | 156 #endif |
154 | 157 |
155 // Pass a NaClDesc to the untrusted side. This will hold a ref to the | 158 // Pass a NaClDesc to the untrusted side. This will hold a ref to the |
156 // NaClIPCAdapter. | 159 // NaClIPCAdapter. |
157 NaClAppSetDesc(nap, nacl_fd, ipc_adapter->MakeNaClDesc()); | 160 NaClAppSetDesc(nap, nacl_fd, ipc_adapter->MakeNaClDesc()); |
158 return ipc_adapter; | |
159 } | 161 } |
160 | 162 |
161 } // namespace | 163 } // namespace |
162 | 164 |
163 class BrowserValidationDBProxy : public NaClValidationDB { | 165 class BrowserValidationDBProxy : public NaClValidationDB { |
164 public: | 166 public: |
165 explicit BrowserValidationDBProxy(NaClListener* listener) | 167 explicit BrowserValidationDBProxy(NaClListener* listener) |
166 : listener_(listener) { | 168 : listener_(listener) { |
167 } | 169 } |
168 | 170 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 306 |
305 if (params.enable_ipc_proxy) { | 307 if (params.enable_ipc_proxy) { |
306 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 308 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
307 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 309 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
308 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 310 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
309 | 311 |
310 // Create the PPAPI IPC channels between the NaCl IRT and the host | 312 // Create the PPAPI IPC channels between the NaCl IRT and the host |
311 // (browser/renderer) processes. The IRT uses these channels to | 313 // (browser/renderer) processes. The IRT uses these channels to |
312 // communicate with the host and to initialize the IPC dispatchers. | 314 // communicate with the host and to initialize the IPC dispatchers. |
313 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), | 315 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), |
314 nap, NACL_CHROME_DESC_BASE); | 316 nap, NACL_CHROME_DESC_BASE, |
| 317 NaClIPCAdapter::ResolveFileTokenCallback()); |
315 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(), | 318 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(), |
316 nap, NACL_CHROME_DESC_BASE + 1); | 319 nap, NACL_CHROME_DESC_BASE + 1, |
317 | 320 NaClIPCAdapter::ResolveFileTokenCallback()); |
318 scoped_refptr<NaClIPCAdapter> manifest_ipc_adapter = | 321 SetUpIPCAdapter(&manifest_service_handle, |
319 SetUpIPCAdapter(&manifest_service_handle, | 322 io_thread_.message_loop_proxy(), |
320 io_thread_.message_loop_proxy(), | 323 nap, |
321 nap, | 324 NACL_CHROME_DESC_BASE + 2, |
322 NACL_CHROME_DESC_BASE + 2); | 325 base::Bind(&NaClListener::ResolveFileToken, |
323 manifest_ipc_adapter->set_resolve_file_token_callback( | 326 base::Unretained(this))); |
324 base::Bind(&NaClListener::ResolveFileToken, base::Unretained(this))); | |
325 } | 327 } |
326 | 328 |
327 trusted_listener_ = new NaClTrustedListener( | 329 trusted_listener_ = new NaClTrustedListener( |
328 IPC::Channel::GenerateVerifiedChannelID("nacl"), | 330 IPC::Channel::GenerateVerifiedChannelID("nacl"), |
329 io_thread_.message_loop_proxy().get(), | 331 io_thread_.message_loop_proxy().get(), |
330 &shutdown_event_); | 332 &shutdown_event_); |
331 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( | 333 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
332 browser_handle, | 334 browser_handle, |
333 ppapi_renderer_handle, | 335 ppapi_renderer_handle, |
334 trusted_listener_->TakeClientChannelHandle(), | 336 trusted_listener_->TakeClientChannelHandle(), |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } | 464 } |
463 | 465 |
464 void NaClListener::OnFileTokenResolved( | 466 void NaClListener::OnFileTokenResolved( |
465 uint64_t token_lo, | 467 uint64_t token_lo, |
466 uint64_t token_hi, | 468 uint64_t token_hi, |
467 IPC::PlatformFileForTransit ipc_fd, | 469 IPC::PlatformFileForTransit ipc_fd, |
468 base::FilePath file_path) { | 470 base::FilePath file_path) { |
469 resolved_cb_.Run(ipc_fd, file_path); | 471 resolved_cb_.Run(ipc_fd, file_path); |
470 resolved_cb_.Reset(); | 472 resolved_cb_.Reset(); |
471 } | 473 } |
OLD | NEW |