Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Side by Side Diff: components/nacl/loader/nacl_listener.cc

Issue 139993009: [WIP] Yet another demo for BMM NaCl ppapi connection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <stdlib.h> 8 #include <stdlib.h>
9 9
10 #if defined(OS_POSIX) 10 #if defined(OS_POSIX)
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 233 }
234 234
235 void NaClListener::OnStart(const nacl::NaClStartParams& params) { 235 void NaClListener::OnStart(const nacl::NaClStartParams& params) {
236 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); 236 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate();
237 if (args == NULL) { 237 if (args == NULL) {
238 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; 238 LOG(ERROR) << "NaClChromeMainArgsCreate() failed";
239 return; 239 return;
240 } 240 }
241 241
242 if (params.enable_ipc_proxy) { 242 if (params.enable_ipc_proxy) {
243 // Create the initial PPAPI IPC channel between the NaCl IRT and the 243 #if defined(OS_LINUX)
244 // browser process. The IRT uses this channel to communicate with the 244 if (params.enable_nonsfi_mode) {
245 // browser and to create additional IPC channels to renderer processes. 245 IPC::ChannelHandle browser_ppapi_handle =
246 IPC::ChannelHandle handle = 246 IPC::Channel::GenerateVerifiedChannelID("nacl");
247 IPC::Channel::GenerateVerifiedChannelID("nacl"); 247 IPC::ChannelHandle renderer_ppapi_handle =
248 scoped_refptr<NaClIPCAdapter> ipc_adapter( 248 IPC::Channel::GenerateVerifiedChannelID("nacl");
249 new NaClIPCAdapter(handle, io_thread_.message_loop_proxy().get()));
250 ipc_adapter->ConnectChannel();
251 249
252 // Pass a NaClDesc to the untrusted side. This will hold a ref to the 250 int browser_ppapi_fds[2];
253 // NaClIPCAdapter. 251 int renderer_ppapi_fds[2];
254 args->initial_ipc_desc = ipc_adapter->MakeNaClDesc(); 252 IPC::Channel::SocketPair(&browser_ppapi_fds[0], &browser_ppapi_fds[1]);
Mark Seaborn 2014/02/03 22:59:07 You need to check the return value here. However,
253 IPC::Channel::SocketPair(&renderer_ppapi_fds[0], &renderer_ppapi_fds[1]);
254
255 browser_ppapi_handle.socket =
256 base::FileDescriptor(browser_ppapi_fds[1], true);
257 renderer_ppapi_handle.socket =
258 base::FileDescriptor(renderer_ppapi_fds[1], true);
259
260 nacl::nonsfi::SetIPCFileDescriptors(
261 browser_ppapi_fds[0], renderer_ppapi_fds[0]);
262
263 // TODO
264 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(
265 browser_ppapi_handle, renderer_ppapi_handle)))
266 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
267 } else {
268 #endif
269 // Create the initial PPAPI IPC channel between the NaCl IRT and the
270 // browser process. The IRT uses this channel to communicate with the
271 // browser and to create additional IPC channels to renderer processes.
272 IPC::ChannelHandle browser_ppapi_handle =
273 IPC::Channel::GenerateVerifiedChannelID("nacl");
274 scoped_refptr<NaClIPCAdapter> ipc_adapter(
275 new NaClIPCAdapter(browser_ppapi_handle,
276 io_thread_.message_loop_proxy().get()));
277 ipc_adapter->ConnectChannel();
278
279 // Pass a NaClDesc to the untrusted side. This will hold a ref to the
280 // NaClIPCAdapter.
281 args->initial_ipc_desc = ipc_adapter->MakeNaClDesc();
255 #if defined(OS_POSIX) 282 #if defined(OS_POSIX)
256 handle.socket = base::FileDescriptor( 283 browser_ppapi_handle.socket = base::FileDescriptor(
257 ipc_adapter->TakeClientFileDescriptor(), true); 284 ipc_adapter->TakeClientFileDescriptor(), true);
258 #endif 285 #endif
259 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle))) 286
260 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; 287 IPC::ChannelHandle renderer_ppapi_handle =
288 IPC::Channel::GenerateVerifiedChannelID("nacl");
289 scoped_refptr<NaClIPCAdapter> ipc_adapter2(
290 new NaClIPCAdapter(renderer_ppapi_handle,
291 io_thread_.message_loop_proxy().get()));
292 ipc_adapter2->ConnectChannel();
293
294 args->initial_ipc_desc2 = ipc_adapter2->MakeNaClDesc();
295 #if defined(OS_POSIX)
296 renderer_ppapi_handle.socket = base::FileDescriptor(
297 ipc_adapter2->TakeClientFileDescriptor(), true);
298 #endif
299 // TODO
300 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(
301 browser_ppapi_handle, renderer_ppapi_handle)))
302 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
303 }
261 } 304 }
262 305
263 std::vector<nacl::FileDescriptor> handles = params.handles; 306 std::vector<nacl::FileDescriptor> handles = params.handles;
264 307
265 #if defined(OS_LINUX) || defined(OS_MACOSX) 308 #if defined(OS_LINUX) || defined(OS_MACOSX)
266 args->urandom_fd = dup(base::GetUrandomFD()); 309 args->urandom_fd = dup(base::GetUrandomFD());
267 if (args->urandom_fd < 0) { 310 if (args->urandom_fd < 0) {
268 LOG(ERROR) << "Failed to dup() the urandom FD"; 311 LOG(ERROR) << "Failed to dup() the urandom FD";
269 return; 312 return;
270 } 313 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 #if defined(OS_LINUX) 379 #if defined(OS_LINUX)
337 if (params.enable_nonsfi_mode) { 380 if (params.enable_nonsfi_mode) {
338 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); 381 nacl::nonsfi::MainStart(args->imc_bootstrap_handle);
339 NOTREACHED(); 382 NOTREACHED();
340 return; 383 return;
341 } 384 }
342 #endif 385 #endif
343 NaClChromeMainStart(args); 386 NaClChromeMainStart(args);
344 NOTREACHED(); 387 NOTREACHED();
345 } 388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698