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

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

Issue 1125043002: NaCl: Stop sending resource FDs with NaClProcessMsg_Start (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git rebase master Created 5 years, 7 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
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 <fcntl.h> 8 #include <fcntl.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 channel_->AddFilter(filter_.get()); 268 channel_->AddFilter(filter_.get());
269 channel_->AddFilter(new FileTokenMessageFilter()); 269 channel_->AddFilter(new FileTokenMessageFilter());
270 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); 270 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true);
271 main_loop_ = base::MessageLoop::current(); 271 main_loop_ = base::MessageLoop::current();
272 main_loop_->Run(); 272 main_loop_->Run();
273 } 273 }
274 274
275 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { 275 bool NaClListener::OnMessageReceived(const IPC::Message& msg) {
276 bool handled = true; 276 bool handled = true;
277 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) 277 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg)
278 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetPrefetchedResource,
279 OnSetPrefetchedResource)
278 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart) 280 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart)
279 IPC_MESSAGE_UNHANDLED(handled = false) 281 IPC_MESSAGE_UNHANDLED(handled = false)
280 IPC_END_MESSAGE_MAP() 282 IPC_END_MESSAGE_MAP()
281 return handled; 283 return handled;
282 } 284 }
283 285
284 bool NaClListener::OnOpenResource( 286 bool NaClListener::OnOpenResource(
285 const IPC::Message& msg, 287 const IPC::Message& msg,
286 const std::string& key, 288 const std::string& key,
287 NaClIPCAdapter::OpenResourceReplyCallback cb) { 289 NaClIPCAdapter::OpenResourceReplyCallback cb) {
(...skipping 12 matching lines...) Expand all
300 // and return true. 302 // and return true.
301 cb.Run(msg, file, path); 303 cb.Run(msg, file, path);
302 return true; 304 return true;
303 } 305 }
304 306
305 // Return false to fall back to the slow path. Let NaClIPCAdapter issue an 307 // Return false to fall back to the slow path. Let NaClIPCAdapter issue an
306 // IPC to the renderer. 308 // IPC to the renderer.
307 return false; 309 return false;
308 } 310 }
309 311
312 void NaClListener::OnSetPrefetchedResource(
Mark Seaborn 2015/05/08 00:35:36 It might be worth adding a sanity check to ensure
Yusuke Sato 2015/05/08 15:12:35 Done.
313 const std::vector<
314 nacl::NaClResourcePrefetchResult>& prefetched_resource_files) {
315 for (size_t i = 0; i < prefetched_resource_files.size(); ++i) {
316 bool result = prefetched_resource_files_.insert(std::make_pair(
317 prefetched_resource_files[i].file_key,
318 std::make_pair(
319 prefetched_resource_files[i].file,
320 prefetched_resource_files[i].file_path_metadata))).second;
321 if (!result) {
322 LOG(FATAL) << "Duplicated open_resource key: "
323 << prefetched_resource_files[i].file_key;
324 }
325 }
326 }
327
310 void NaClListener::OnStart(const nacl::NaClStartParams& params) { 328 void NaClListener::OnStart(const nacl::NaClStartParams& params) {
311 #if defined(OS_LINUX) || defined(OS_MACOSX) 329 #if defined(OS_LINUX) || defined(OS_MACOSX)
312 int urandom_fd = dup(base::GetUrandomFD()); 330 int urandom_fd = dup(base::GetUrandomFD());
313 if (urandom_fd < 0) { 331 if (urandom_fd < 0) {
314 LOG(ERROR) << "Failed to dup() the urandom FD"; 332 LOG(ERROR) << "Failed to dup() the urandom FD";
315 return; 333 return;
316 } 334 }
317 NaClChromeMainSetUrandomFd(urandom_fd); 335 NaClChromeMainSetUrandomFd(urandom_fd);
318 #endif 336 #endif
319 struct NaClApp* nap = NULL; 337 struct NaClApp* nap = NULL;
320 NaClChromeMainInit(); 338 NaClChromeMainInit();
321 339
322 CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle)); 340 CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle));
323 crash_info_shmem_.reset(new base::SharedMemory( 341 crash_info_shmem_.reset(new base::SharedMemory(
324 params.crash_info_shmem_handle, false /* not readonly */)); 342 params.crash_info_shmem_handle, false /* not readonly */));
325 CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize)); 343 CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize));
326 NaClSetFatalErrorCallback(&FatalLogHandler); 344 NaClSetFatalErrorCallback(&FatalLogHandler);
327 345
328 nap = NaClAppCreate(); 346 nap = NaClAppCreate();
329 if (nap == NULL) { 347 if (nap == NULL) {
330 LOG(ERROR) << "NaClAppCreate() failed"; 348 LOG(ERROR) << "NaClAppCreate() failed";
331 return; 349 return;
332 } 350 }
333 351
334 IPC::ChannelHandle browser_handle; 352 IPC::ChannelHandle browser_handle;
335 IPC::ChannelHandle ppapi_renderer_handle; 353 IPC::ChannelHandle ppapi_renderer_handle;
336 IPC::ChannelHandle manifest_service_handle; 354 IPC::ChannelHandle manifest_service_handle;
337 355
338 for (size_t i = 0; i < params.prefetched_resource_files.size(); ++i) {
339 bool result = prefetched_resource_files_.insert(std::make_pair(
340 params.prefetched_resource_files[i].file_key,
341 std::make_pair(
342 params.prefetched_resource_files[i].file,
343 params.prefetched_resource_files[i].file_path_metadata))).second;
344 if (!result) {
345 LOG(FATAL) << "Duplicated open_resource key: "
346 << params.prefetched_resource_files[i].file_key;
347 }
348 }
349
350 if (params.enable_ipc_proxy) { 356 if (params.enable_ipc_proxy) {
351 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 357 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
352 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 358 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
353 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 359 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
354 360
355 // Create the PPAPI IPC channels between the NaCl IRT and the host 361 // Create the PPAPI IPC channels between the NaCl IRT and the host
356 // (browser/renderer) processes. The IRT uses these channels to 362 // (browser/renderer) processes. The IRT uses these channels to
357 // communicate with the host and to initialize the IPC dispatchers. 363 // communicate with the host and to initialize the IPC dispatchers.
358 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), 364 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
359 nap, NACL_CHROME_DESC_BASE, 365 nap, NACL_CHROME_DESC_BASE,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 505 }
500 506
501 void NaClListener::OnFileTokenResolved( 507 void NaClListener::OnFileTokenResolved(
502 uint64_t token_lo, 508 uint64_t token_lo,
503 uint64_t token_hi, 509 uint64_t token_hi,
504 IPC::PlatformFileForTransit ipc_fd, 510 IPC::PlatformFileForTransit ipc_fd,
505 base::FilePath file_path) { 511 base::FilePath file_path) {
506 resolved_cb_.Run(ipc_fd, file_path); 512 resolved_cb_.Run(ipc_fd, file_path);
507 resolved_cb_.Reset(); 513 resolved_cb_.Reset();
508 } 514 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698