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

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

Issue 140573003: Connect PPAPI IPC channels for non-SFI mode. (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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return; 272 return;
273 } 273 }
274 274
275 struct NaClApp *nap = NaClAppCreate(); 275 struct NaClApp *nap = NaClAppCreate();
276 if (nap == NULL) { 276 if (nap == NULL) {
277 LOG(ERROR) << "NaClAppCreate() failed"; 277 LOG(ERROR) << "NaClAppCreate() failed";
278 return; 278 return;
279 } 279 }
280 280
281 if (params.enable_ipc_proxy) { 281 if (params.enable_ipc_proxy) {
282 // Create the PPAPI IPC channels between the NaCl IRT and the hosts 282 #if defined(OS_LINUX)
283 // (browser/renderer) processes. The IRT uses these channels to communicate 283 if (params.enable_nonsfi_mode) {
284 // with the host and to initialize the IPC dispatchers. 284 // In non-SFI mode, we neither intercept nor rewrite the message by
285 IPC::ChannelHandle browser_handle = 285 // IPCAdapter, and the channels are connected between the plugin and
286 IPC::Channel::GenerateVerifiedChannelID("nacl"); 286 // the hosts directly. So, the IPC::Channel instances will be created in
287 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), 287 // the plugin side, because the IPC::Listener needs to be live on the
Mark Seaborn 2014/02/15 03:00:52 Did you mean "needs to live"?
hidehiko 2014/02/19 13:05:02 Done.
288 nap, NACL_CHROME_DESC_BASE); 288 // plugin's main thread. However, on the initialization (i.e. before
Mark Seaborn 2014/02/15 03:00:52 "on initialization"
hidehiko 2014/02/19 13:05:02 Done.
289 // loading the plugin binary), the FD is needed to be passed to the
Mark Seaborn 2014/02/15 03:00:52 "FD needs to be passed"
hidehiko 2014/02/19 13:05:02 Done.
290 // hosts. So, here we create raw FD pairs, and pass the clients side FDs
291 // to the hosts, and the server side FDs to the plugin.
292 int browser_server_ppapi_fd;
293 int browser_client_ppapi_fd;
294 int renderer_server_ppapi_fd;
295 int renderer_client_ppapi_fd;
296 if (!IPC::SocketPair(
297 &browser_server_ppapi_fd, &browser_client_ppapi_fd) ||
298 !IPC::SocketPair(
299 &renderer_server_ppapi_fd, &renderer_client_ppapi_fd)) {
300 LOG(ERROR) << "Failed to create sockets for IPC.";
301 return;
302 }
289 303
290 IPC::ChannelHandle renderer_handle = 304 // Set the plugin IPC channel FD.
291 IPC::Channel::GenerateVerifiedChannelID("nacl"); 305 nacl::nonsfi::SetIPCFileDescriptors(
Mark Seaborn 2014/02/15 03:00:52 Can this just call the function from ppapi/proxy/p
hidehiko 2014/02/19 13:05:02 Done (but I just worried about if it is layer viol
292 SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(), 306 browser_server_ppapi_fd, renderer_server_ppapi_fd);
293 nap, NACL_CHROME_DESC_BASE + 1);
294 307
295 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( 308 // Send back to the client side IPC channel FD to the host.
296 browser_handle, renderer_handle))) 309 IPC::ChannelHandle browser_handle =
297 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; 310 IPC::Channel::GenerateVerifiedChannelID("nacl");
311 browser_handle.socket =
312 base::FileDescriptor(browser_client_ppapi_fd, true);
313
314 IPC::ChannelHandle renderer_handle =
315 IPC::Channel::GenerateVerifiedChannelID("nacl");
316 renderer_handle.socket =
317 base::FileDescriptor(renderer_client_ppapi_fd, true);
318
319 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
Mark Seaborn 2014/02/15 03:00:52 This call is the same in both paths, right? So it
hidehiko 2014/02/19 13:05:02 Done.
320 browser_handle, renderer_handle)))
321 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
322 } else {
323 #endif
324 // Create the PPAPI IPC channels between the NaCl IRT and the hosts
325 // (browser/renderer) processes. The IRT uses these channels to
326 // communicate with the host and to initialize the IPC dispatchers.
327 IPC::ChannelHandle browser_handle =
328 IPC::Channel::GenerateVerifiedChannelID("nacl");
329 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
330 nap, NACL_CHROME_DESC_BASE);
331
332 IPC::ChannelHandle renderer_handle =
333 IPC::Channel::GenerateVerifiedChannelID("nacl");
334 SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(),
335 nap, NACL_CHROME_DESC_BASE + 1);
336
337 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
338 browser_handle, renderer_handle)))
339 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
340 #if defined(OS_LINUX)
341 }
342 #endif
298 } 343 }
299 344
300 std::vector<nacl::FileDescriptor> handles = params.handles; 345 std::vector<nacl::FileDescriptor> handles = params.handles;
301 346
302 #if defined(OS_LINUX) || defined(OS_MACOSX) 347 #if defined(OS_LINUX) || defined(OS_MACOSX)
303 args->number_of_cores = number_of_cores_; 348 args->number_of_cores = number_of_cores_;
304 args->create_memory_object_func = CreateMemoryObject; 349 args->create_memory_object_func = CreateMemoryObject;
305 # if defined(OS_MACOSX) 350 # if defined(OS_MACOSX)
306 CHECK(handles.size() >= 1); 351 CHECK(handles.size() >= 1);
307 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); 352 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 #if defined(OS_LINUX) 413 #if defined(OS_LINUX)
369 if (params.enable_nonsfi_mode) { 414 if (params.enable_nonsfi_mode) {
370 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); 415 nacl::nonsfi::MainStart(args->imc_bootstrap_handle);
371 NOTREACHED(); 416 NOTREACHED();
372 return; 417 return;
373 } 418 }
374 #endif 419 #endif
375 NaClChromeMainStartApp(nap, args); 420 NaClChromeMainStartApp(nap, args);
376 NOTREACHED(); 421 NOTREACHED();
377 } 422 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698