Chromium Code Reviews| 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 scoped_refptr<NaClIPCAdapter> SetUpIPCAdapter( |
|
Mark Seaborn
2015/04/16 20:51:21
You can change this to return 'void' now.
Yusuke Sato
2015/04/16 21:25:02
Done.
| |
| 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; | 161 return ipc_adapter; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 | 307 |
| 305 if (params.enable_ipc_proxy) { | 308 if (params.enable_ipc_proxy) { |
| 306 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 309 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 307 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 310 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 308 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 311 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 309 | 312 |
| 310 // Create the PPAPI IPC channels between the NaCl IRT and the host | 313 // Create the PPAPI IPC channels between the NaCl IRT and the host |
| 311 // (browser/renderer) processes. The IRT uses these channels to | 314 // (browser/renderer) processes. The IRT uses these channels to |
| 312 // communicate with the host and to initialize the IPC dispatchers. | 315 // communicate with the host and to initialize the IPC dispatchers. |
| 313 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), | 316 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), |
| 314 nap, NACL_CHROME_DESC_BASE); | 317 nap, NACL_CHROME_DESC_BASE, |
| 318 NaClIPCAdapter::ResolveFileTokenCallback()); | |
| 315 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(), | 319 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(), |
| 316 nap, NACL_CHROME_DESC_BASE + 1); | 320 nap, NACL_CHROME_DESC_BASE + 1, |
| 317 | 321 NaClIPCAdapter::ResolveFileTokenCallback()); |
| 318 scoped_refptr<NaClIPCAdapter> manifest_ipc_adapter = | 322 SetUpIPCAdapter(&manifest_service_handle, |
| 319 SetUpIPCAdapter(&manifest_service_handle, | 323 io_thread_.message_loop_proxy(), |
| 320 io_thread_.message_loop_proxy(), | 324 nap, |
| 321 nap, | 325 NACL_CHROME_DESC_BASE + 2, |
| 322 NACL_CHROME_DESC_BASE + 2); | 326 base::Bind(&NaClListener::ResolveFileToken, |
| 323 manifest_ipc_adapter->set_resolve_file_token_callback( | 327 base::Unretained(this))); |
| 324 base::Bind(&NaClListener::ResolveFileToken, base::Unretained(this))); | |
| 325 } | 328 } |
| 326 | 329 |
| 327 trusted_listener_ = new NaClTrustedListener( | 330 trusted_listener_ = new NaClTrustedListener( |
| 328 IPC::Channel::GenerateVerifiedChannelID("nacl"), | 331 IPC::Channel::GenerateVerifiedChannelID("nacl"), |
| 329 io_thread_.message_loop_proxy().get(), | 332 io_thread_.message_loop_proxy().get(), |
| 330 &shutdown_event_); | 333 &shutdown_event_); |
| 331 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( | 334 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
| 332 browser_handle, | 335 browser_handle, |
| 333 ppapi_renderer_handle, | 336 ppapi_renderer_handle, |
| 334 trusted_listener_->TakeClientChannelHandle(), | 337 trusted_listener_->TakeClientChannelHandle(), |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 } | 465 } |
| 463 | 466 |
| 464 void NaClListener::OnFileTokenResolved( | 467 void NaClListener::OnFileTokenResolved( |
| 465 uint64_t token_lo, | 468 uint64_t token_lo, |
| 466 uint64_t token_hi, | 469 uint64_t token_hi, |
| 467 IPC::PlatformFileForTransit ipc_fd, | 470 IPC::PlatformFileForTransit ipc_fd, |
| 468 base::FilePath file_path) { | 471 base::FilePath file_path) { |
| 469 resolved_cb_.Run(ipc_fd, file_path); | 472 resolved_cb_.Run(ipc_fd, file_path); |
| 470 resolved_cb_.Reset(); | 473 resolved_cb_.Reset(); |
| 471 } | 474 } |
| OLD | NEW |