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

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

Issue 1179523002: NaCl: Clean up error handling during NaCl loader startup in OnStart() (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | 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 <fcntl.h> 8 #include <fcntl.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 LOG(FATAL) << "Duplicated open_resource key: " 321 LOG(FATAL) << "Duplicated open_resource key: "
322 << prefetched_resource_file.file_key; 322 << prefetched_resource_file.file_key;
323 } 323 }
324 } 324 }
325 325
326 void NaClListener::OnStart(const nacl::NaClStartParams& params) { 326 void NaClListener::OnStart(const nacl::NaClStartParams& params) {
327 is_started_ = true; 327 is_started_ = true;
328 #if defined(OS_LINUX) || defined(OS_MACOSX) 328 #if defined(OS_LINUX) || defined(OS_MACOSX)
329 int urandom_fd = dup(base::GetUrandomFD()); 329 int urandom_fd = dup(base::GetUrandomFD());
330 if (urandom_fd < 0) { 330 if (urandom_fd < 0) {
331 LOG(ERROR) << "Failed to dup() the urandom FD"; 331 LOG(FATAL) << "Failed to dup() the urandom FD";
332 return;
333 } 332 }
334 NaClChromeMainSetUrandomFd(urandom_fd); 333 NaClChromeMainSetUrandomFd(urandom_fd);
335 #endif 334 #endif
336 struct NaClApp* nap = NULL; 335 struct NaClApp* nap = NULL;
337 NaClChromeMainInit(); 336 NaClChromeMainInit();
338 337
339 CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle)); 338 CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle));
340 crash_info_shmem_.reset(new base::SharedMemory( 339 crash_info_shmem_.reset(new base::SharedMemory(
341 params.crash_info_shmem_handle, false /* not readonly */)); 340 params.crash_info_shmem_handle, false /* not readonly */));
342 CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize)); 341 CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize));
343 NaClSetFatalErrorCallback(&FatalLogHandler); 342 NaClSetFatalErrorCallback(&FatalLogHandler);
344 343
345 nap = NaClAppCreate(); 344 nap = NaClAppCreate();
346 if (nap == NULL) { 345 if (nap == NULL) {
347 LOG(ERROR) << "NaClAppCreate() failed"; 346 LOG(FATAL) << "NaClAppCreate() failed";
348 return;
349 } 347 }
350 348
351 IPC::ChannelHandle browser_handle; 349 IPC::ChannelHandle browser_handle;
352 IPC::ChannelHandle ppapi_renderer_handle; 350 IPC::ChannelHandle ppapi_renderer_handle;
353 IPC::ChannelHandle manifest_service_handle; 351 IPC::ChannelHandle manifest_service_handle;
354 352
355 if (params.enable_ipc_proxy) { 353 if (params.enable_ipc_proxy) {
356 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 354 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
357 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 355 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
358 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 356 manifest_service_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
(...skipping 17 matching lines...) Expand all
376 } 374 }
377 375
378 trusted_listener_ = 376 trusted_listener_ =
379 new NaClTrustedListener(IPC::Channel::GenerateVerifiedChannelID("nacl"), 377 new NaClTrustedListener(IPC::Channel::GenerateVerifiedChannelID("nacl"),
380 io_thread_.task_runner().get(), &shutdown_event_); 378 io_thread_.task_runner().get(), &shutdown_event_);
381 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( 379 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
382 browser_handle, 380 browser_handle,
383 ppapi_renderer_handle, 381 ppapi_renderer_handle,
384 trusted_listener_->TakeClientChannelHandle(), 382 trusted_listener_->TakeClientChannelHandle(),
385 manifest_service_handle))) 383 manifest_service_handle)))
386 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; 384 LOG(FATAL) << "Failed to send IPC channel handle to NaClProcessHost.";
387 385
388 struct NaClChromeMainArgs* args = NaClChromeMainArgsCreate(); 386 struct NaClChromeMainArgs* args = NaClChromeMainArgsCreate();
389 if (args == NULL) { 387 if (args == NULL) {
390 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; 388 LOG(FATAL) << "NaClChromeMainArgsCreate() failed";
391 return;
392 } 389 }
393 390
394 #if defined(OS_LINUX) || defined(OS_MACOSX) 391 #if defined(OS_LINUX) || defined(OS_MACOSX)
395 args->number_of_cores = number_of_cores_; 392 args->number_of_cores = number_of_cores_;
396 args->create_memory_object_func = CreateMemoryObject; 393 args->create_memory_object_func = CreateMemoryObject;
397 # if defined(OS_MACOSX) 394 # if defined(OS_MACOSX)
398 CHECK(params.mac_shm_fd != IPC::InvalidPlatformFileForTransit()); 395 CHECK(params.mac_shm_fd != IPC::InvalidPlatformFileForTransit());
399 g_shm_fd = IPC::PlatformFileForTransitToPlatformFile(params.mac_shm_fd); 396 g_shm_fd = IPC::PlatformFileForTransitToPlatformFile(params.mac_shm_fd);
400 # endif 397 # endif
401 #endif 398 #endif
402 399
403 DCHECK(params.process_type != nacl::kUnknownNaClProcessType); 400 DCHECK(params.process_type != nacl::kUnknownNaClProcessType);
404 CHECK(params.irt_handle != IPC::InvalidPlatformFileForTransit()); 401 CHECK(params.irt_handle != IPC::InvalidPlatformFileForTransit());
405 NaClHandle irt_handle = 402 NaClHandle irt_handle =
406 IPC::PlatformFileForTransitToPlatformFile(params.irt_handle); 403 IPC::PlatformFileForTransitToPlatformFile(params.irt_handle);
407 404
408 #if defined(OS_WIN) 405 #if defined(OS_WIN)
409 args->irt_fd = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle), 406 args->irt_fd = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle),
410 _O_RDONLY | _O_BINARY); 407 _O_RDONLY | _O_BINARY);
411 if (args->irt_fd < 0) { 408 if (args->irt_fd < 0) {
412 LOG(ERROR) << "_open_osfhandle() failed"; 409 LOG(FATAL) << "_open_osfhandle() failed";
413 return;
414 } 410 }
415 #else 411 #else
416 args->irt_fd = irt_handle; 412 args->irt_fd = irt_handle;
417 #endif 413 #endif
418 414
419 if (params.validation_cache_enabled) { 415 if (params.validation_cache_enabled) {
420 // SHA256 block size. 416 // SHA256 block size.
421 CHECK_EQ(params.validation_cache_key.length(), (size_t) 64); 417 CHECK_EQ(params.validation_cache_key.length(), (size_t) 64);
422 // The cache structure is not freed and exists until the NaCl process exits. 418 // The cache structure is not freed and exists until the NaCl process exits.
423 args->validation_cache = CreateValidationCache( 419 args->validation_cache = CreateValidationCache(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 496 }
501 497
502 void NaClListener::OnFileTokenResolved( 498 void NaClListener::OnFileTokenResolved(
503 uint64_t token_lo, 499 uint64_t token_lo,
504 uint64_t token_hi, 500 uint64_t token_hi,
505 IPC::PlatformFileForTransit ipc_fd, 501 IPC::PlatformFileForTransit ipc_fd,
506 base::FilePath file_path) { 502 base::FilePath file_path) {
507 resolved_cb_.Run(ipc_fd, file_path); 503 resolved_cb_.Run(ipc_fd, file_path);
508 resolved_cb_.Reset(); 504 resolved_cb_.Reset();
509 } 505 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698