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

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

Issue 150713003: Create IPC channel to communicate with the renderer in NaClListener::OnStart(). (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
« no previous file with comments | « components/nacl/loader/nacl_ipc_adapter.cc ('k') | ppapi/ppapi_shared.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 std::string info_string(reinterpret_cast<const char*>(info), info_size); 102 std::string info_string(reinterpret_cast<const char*>(info), info_size);
103 bool result = false; 103 bool result = false;
104 if (!g_listener->Send(new NaClProcessMsg_AttachDebugExceptionHandler( 104 if (!g_listener->Send(new NaClProcessMsg_AttachDebugExceptionHandler(
105 info_string, &result))) 105 info_string, &result)))
106 return false; 106 return false;
107 return result; 107 return result;
108 } 108 }
109 109
110 #endif 110 #endif
111 111
112 // Creates the PPAPI IPC channel between the NaCl IRT and the host
113 // (browser/renderer) process, and starts to listen it on the thread where
114 // the given message_loop_proxy runs.
115 // Also, creates and sets the corresponding NaClDesc to the given nap with
116 // the FD #.
117 void SetUpIPCAdapter(IPC::ChannelHandle* handle,
118 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
119 struct NaClApp* nap,
120 int nacl_fd) {
121 scoped_refptr<NaClIPCAdapter> ipc_adapter(
122 new NaClIPCAdapter(*handle, message_loop_proxy.get()));
123 ipc_adapter->ConnectChannel();
124 #if defined(OS_POSIX)
125 handle->socket =
126 base::FileDescriptor(ipc_adapter->TakeClientFileDescriptor(), true);
127 #endif
128
129 // Pass a NaClDesc to the untrusted side. This will hold a ref to the
130 // NaClIPCAdapter.
131 NaClAppSetDesc(nap, nacl_fd, ipc_adapter->MakeNaClDesc());
132 }
133
112 } // namespace 134 } // namespace
113 135
114 class BrowserValidationDBProxy : public NaClValidationDB { 136 class BrowserValidationDBProxy : public NaClValidationDB {
115 public: 137 public:
116 explicit BrowserValidationDBProxy(NaClListener* listener) 138 explicit BrowserValidationDBProxy(NaClListener* listener)
117 : listener_(listener) { 139 : listener_(listener) {
118 } 140 }
119 141
120 virtual bool QueryKnownToValidate(const std::string& signature) OVERRIDE { 142 virtual bool QueryKnownToValidate(const std::string& signature) OVERRIDE {
121 // Initialize to false so that if the Send fails to write to the return 143 // Initialize to false so that if the Send fails to write to the return
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 264 }
243 NaClChromeMainSetUrandomFd(urandom_fd); 265 NaClChromeMainSetUrandomFd(urandom_fd);
244 #endif 266 #endif
245 267
246 NaClChromeMainInit(); 268 NaClChromeMainInit();
247 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); 269 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate();
248 if (args == NULL) { 270 if (args == NULL) {
249 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; 271 LOG(ERROR) << "NaClChromeMainArgsCreate() failed";
250 return; 272 return;
251 } 273 }
274
252 struct NaClApp *nap = NaClAppCreate(); 275 struct NaClApp *nap = NaClAppCreate();
253 if (nap == NULL) { 276 if (nap == NULL) {
254 LOG(ERROR) << "NaClAppCreate() failed"; 277 LOG(ERROR) << "NaClAppCreate() failed";
255 return; 278 return;
256 } 279 }
257 280
258 if (params.enable_ipc_proxy) { 281 if (params.enable_ipc_proxy) {
259 // Create the initial PPAPI IPC channel between the NaCl IRT and the 282 // Create the PPAPI IPC channels between the NaCl IRT and the hosts
260 // browser process. The IRT uses this channel to communicate with the 283 // (browser/renderer) processes. The IRT uses these channels to communicate
261 // browser and to create additional IPC channels to renderer processes. 284 // with the host and to initialize the IPC dispatchers.
262 IPC::ChannelHandle handle = 285 IPC::ChannelHandle browser_handle =
263 IPC::Channel::GenerateVerifiedChannelID("nacl"); 286 IPC::Channel::GenerateVerifiedChannelID("nacl");
264 scoped_refptr<NaClIPCAdapter> ipc_adapter( 287 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
265 new NaClIPCAdapter(handle, io_thread_.message_loop_proxy().get())); 288 nap, NACL_CHROME_DESC_BASE);
266 ipc_adapter->ConnectChannel();
267 289
268 // Pass a NaClDesc to the untrusted side. This will hold a ref to the 290 IPC::ChannelHandle renderer_handle =
269 // NaClIPCAdapter. 291 IPC::Channel::GenerateVerifiedChannelID("nacl");
270 NaClAppSetDesc(nap, NACL_CHROME_DESC_BASE, ipc_adapter->MakeNaClDesc()); 292 SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(),
271 #if defined(OS_POSIX) 293 nap, NACL_CHROME_DESC_BASE + 1);
272 handle.socket = base::FileDescriptor( 294
273 ipc_adapter->TakeClientFileDescriptor(), true); 295 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
274 #endif 296 browser_handle, renderer_handle)))
275 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle)))
276 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; 297 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
277 } 298 }
278 299
279 std::vector<nacl::FileDescriptor> handles = params.handles; 300 std::vector<nacl::FileDescriptor> handles = params.handles;
280 301
281 #if defined(OS_LINUX) || defined(OS_MACOSX) 302 #if defined(OS_LINUX) || defined(OS_MACOSX)
282 args->number_of_cores = number_of_cores_; 303 args->number_of_cores = number_of_cores_;
283 args->create_memory_object_func = CreateMemoryObject; 304 args->create_memory_object_func = CreateMemoryObject;
284 # if defined(OS_MACOSX) 305 # if defined(OS_MACOSX)
285 CHECK(handles.size() >= 1); 306 CHECK(handles.size() >= 1);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 #if defined(OS_LINUX) 368 #if defined(OS_LINUX)
348 if (params.enable_nonsfi_mode) { 369 if (params.enable_nonsfi_mode) {
349 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); 370 nacl::nonsfi::MainStart(args->imc_bootstrap_handle);
350 NOTREACHED(); 371 NOTREACHED();
351 return; 372 return;
352 } 373 }
353 #endif 374 #endif
354 NaClChromeMainStartApp(nap, args); 375 NaClChromeMainStartApp(nap, args);
355 NOTREACHED(); 376 NOTREACHED();
356 } 377 }
OLDNEW
« no previous file with comments | « components/nacl/loader/nacl_ipc_adapter.cc ('k') | ppapi/ppapi_shared.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698