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

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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; 261 LOG(ERROR) << "NaClChromeMainArgsCreate() failed";
262 return; 262 return;
263 } 263 }
264 264
265 struct NaClApp* nap = NaClAppMake(); 265 struct NaClApp* nap = NaClAppMake();
266 if (nap == NULL) { 266 if (nap == NULL) {
267 LOG(ERROR) << "NaClAppMake() failed"; 267 LOG(ERROR) << "NaClAppMake() failed";
268 return; 268 return;
269 } 269 }
270 if (params.enable_ipc_proxy) { 270 if (params.enable_ipc_proxy) {
271 // Create the PPAPI IPC channels between the NaCl IRT and the hosts 271 #if defined(OS_LINUX)
272 // (browser/renderer) processes. The IRT uses these channels to communicate 272 if (params.enable_nonsfi_mode) {
Mark Seaborn 2014/02/07 23:54:10 You should be able to use this new SocketPair()-ba
hidehiko 2014/02/10 08:18:34 Just for clarification: Even if we use raw SocketP
Mark Seaborn 2014/02/10 18:57:35 Oops, yes, I see what you mean. Your current code
273 // with the host and to initialize the IPC dispatchers. 273 // In non-SFI mode, we neither intercept nor rewrite the message by
274 IPC::ChannelHandle browser_handle = 274 // IPCAdapter, and the channels are connected between the plugin and
275 IPC::Channel::GenerateVerifiedChannelID("nacl"); 275 // the hosts directly. So, the IPC::Channel instances will be created in
276 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), 276 // the plugin side, because the IPC::Listener needs to be live on the
277 nap, NACL_CHROME_DESC_BASE); 277 // plugin's main thread. However, on the initialization (i.e. before
278 // loading the plugin binary), the FD is needed to be passed to the
279 // hosts. So, here we create raw FD pairs, and pass the clients side FDs
280 // to the hosts, and the server side FDs to the plugin.
281 int browser_server_ppapi_fd;
282 int browser_client_ppapi_fd;
283 int renderer_server_ppapi_fd;
284 int renderer_client_ppapi_fd;
285 if (!IPC::SocketPair(
286 &browser_server_ppapi_fd, &browser_client_ppapi_fd) ||
287 !IPC::SocketPair(
288 &renderer_server_ppapi_fd, &renderer_client_ppapi_fd)) {
289 LOG(ERROR) << "Failed to create sockets for IPC.";
290 return;
291 }
278 292
279 IPC::ChannelHandle renderer_handle = 293 // Set the plugin IPC channel FD.
280 IPC::Channel::GenerateVerifiedChannelID("nacl"); 294 nacl::nonsfi::SetIPCFileDescriptors(
281 SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(), 295 browser_server_ppapi_fd, renderer_server_ppapi_fd);
282 nap, NACL_CHROME_DESC_BASE + 1);
283 296
284 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( 297 // Send back to the client side IPC channel FD to the host.
285 browser_handle, renderer_handle))) 298 IPC::ChannelHandle browser_handle =
286 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; 299 IPC::Channel::GenerateVerifiedChannelID("nacl");
300 browser_handle.socket =
301 base::FileDescriptor(browser_client_ppapi_fd, true);
302
303 IPC::ChannelHandle renderer_handle =
304 IPC::Channel::GenerateVerifiedChannelID("nacl");
305 renderer_handle.socket =
306 base::FileDescriptor(renderer_client_ppapi_fd, true);
307
308 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
309 browser_handle, renderer_handle)))
310 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
311 } else {
312 #endif
313 // Create the PPAPI IPC channels between the NaCl IRT and the hosts
314 // (browser/renderer) processes. The IRT uses these channels to
315 // communicate with the host and to initialize the IPC dispatchers.
316 IPC::ChannelHandle browser_handle =
317 IPC::Channel::GenerateVerifiedChannelID("nacl");
318 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
319 nap, NACL_CHROME_DESC_BASE);
320
321 IPC::ChannelHandle renderer_handle =
322 IPC::Channel::GenerateVerifiedChannelID("nacl");
323 SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(),
324 nap, NACL_CHROME_DESC_BASE + 1);
325
326 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
327 browser_handle, renderer_handle)))
328 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
329 #if defined(OS_LINUX)
330 }
331 #endif
287 } 332 }
288 333
289 std::vector<nacl::FileDescriptor> handles = params.handles; 334 std::vector<nacl::FileDescriptor> handles = params.handles;
290 335
291 #if defined(OS_LINUX) || defined(OS_MACOSX) 336 #if defined(OS_LINUX) || defined(OS_MACOSX)
292 args->urandom_fd = dup(base::GetUrandomFD()); 337 args->urandom_fd = dup(base::GetUrandomFD());
293 if (args->urandom_fd < 0) { 338 if (args->urandom_fd < 0) {
294 LOG(ERROR) << "Failed to dup() the urandom FD"; 339 LOG(ERROR) << "Failed to dup() the urandom FD";
295 return; 340 return;
296 } 341 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 #if defined(OS_LINUX) 407 #if defined(OS_LINUX)
363 if (params.enable_nonsfi_mode) { 408 if (params.enable_nonsfi_mode) {
364 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); 409 nacl::nonsfi::MainStart(args->imc_bootstrap_handle);
365 NOTREACHED(); 410 NOTREACHED();
366 return; 411 return;
367 } 412 }
368 #endif 413 #endif
369 NaClChromeMainStartApp(nap, args); 414 NaClChromeMainStartApp(nap, args);
370 NOTREACHED(); 415 NOTREACHED();
371 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698