Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/renderer/ppb_nacl_private_impl.h" | 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 load_manager->set_manifest_service_channel( | 432 load_manager->set_manifest_service_channel( |
| 433 manifest_service_channel.Pass()); | 433 manifest_service_channel.Pass()); |
| 434 } else { | 434 } else { |
| 435 // Currently, manifest service works only on linux/non-SFI mode. | 435 // Currently, manifest service works only on linux/non-SFI mode. |
| 436 // On other platforms, the socket will not be created, and thus this | 436 // On other platforms, the socket will not be created, and thus this |
| 437 // condition needs to be handled as success. | 437 // condition needs to be handled as success. |
| 438 connected_callback.Run(PP_OK); | 438 connected_callback.Run(PP_OK); |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 | 441 |
| 442 // Forward declaration. | |
| 443 void ReportLoadError(PP_Instance instance, | |
| 444 PP_NaClError error, | |
| 445 const char* error_message, | |
| 446 const char* console_message); | |
| 447 | |
| 448 PP_Bool StartPpapiProxy(PP_Instance instance) { | 442 PP_Bool StartPpapiProxy(PP_Instance instance) { |
| 449 InstanceInfoMap& map = g_instance_info.Get(); | 443 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 450 InstanceInfoMap::iterator it = map.find(instance); | 444 DCHECK(load_manager); |
| 451 if (it == map.end()) { | 445 if (!load_manager) |
| 452 DLOG(ERROR) << "Could not find instance ID"; | |
| 453 return PP_FALSE; | 446 return PP_FALSE; |
| 454 } | |
| 455 InstanceInfo instance_info = it->second; | |
| 456 map.erase(it); | |
| 457 | 447 |
| 458 content::PepperPluginInstance* plugin_instance = | 448 content::PepperPluginInstance* plugin_instance = |
| 459 content::PepperPluginInstance::Get(instance); | 449 content::PepperPluginInstance::Get(instance); |
| 460 if (!plugin_instance) { | 450 if (!plugin_instance) { |
| 461 DLOG(ERROR) << "GetInstance() failed"; | 451 DLOG(ERROR) << "GetInstance() failed"; |
| 462 return PP_FALSE; | 452 return PP_FALSE; |
| 463 } | 453 } |
| 464 | 454 |
| 455 InstanceInfoMap& map = g_instance_info.Get(); | |
| 456 InstanceInfoMap::iterator it = map.find(instance); | |
| 457 if (it == map.end()) { | |
| 458 DLOG(ERROR) << "Could not find instance ID"; | |
| 459 return PP_FALSE; | |
| 460 } | |
| 461 InstanceInfo instance_info = it->second; | |
| 462 map.erase(it); | |
| 463 | |
| 465 PP_ExternalPluginResult result = plugin_instance->SwitchToOutOfProcessProxy( | 464 PP_ExternalPluginResult result = plugin_instance->SwitchToOutOfProcessProxy( |
| 466 base::FilePath().AppendASCII(instance_info.url.spec()), | 465 base::FilePath().AppendASCII(instance_info.url.spec()), |
| 467 instance_info.permissions, | 466 instance_info.permissions, |
| 468 instance_info.channel_handle, | 467 instance_info.channel_handle, |
| 469 instance_info.plugin_pid, | 468 instance_info.plugin_pid, |
| 470 instance_info.plugin_child_id); | 469 instance_info.plugin_child_id); |
| 471 | 470 |
| 472 if (result == PP_EXTERNAL_PLUGIN_OK) { | 471 if (result == PP_EXTERNAL_PLUGIN_OK) { |
| 473 // Log the amound of time that has passed between the trusted plugin being | 472 // Log the amound of time that has passed between the trusted plugin being |
|
dmichael (off chromium)
2014/06/05 19:06:54
unrelated nit: amound->amount
| |
| 474 // initialized and the untrusted plugin being initialized. This is | 473 // initialized and the untrusted plugin being initialized. This is |
| 475 // (roughly) the cost of using NaCl, in terms of startup time. | 474 // (roughly) the cost of using NaCl, in terms of startup time. |
| 476 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 475 load_manager->ReportStartupOverhead(); |
| 477 if (load_manager) | |
| 478 load_manager->ReportStartupOverhead(); | |
| 479 return PP_TRUE; | 476 return PP_TRUE; |
| 480 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_MODULE) { | 477 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_MODULE) { |
| 481 ReportLoadError(instance, | 478 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, |
| 482 PP_NACL_ERROR_START_PROXY_MODULE, | 479 "could not initialize module."); |
| 483 "could not initialize module.", | |
| 484 "could not initialize module."); | |
| 485 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_INSTANCE) { | 480 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_INSTANCE) { |
| 486 ReportLoadError(instance, | 481 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, |
| 487 PP_NACL_ERROR_START_PROXY_MODULE, | 482 "could not create instance."); |
| 488 "could not create instance.", | |
| 489 "could not create instance."); | |
| 490 } | 483 } |
| 491 return PP_FALSE; | 484 return PP_FALSE; |
| 492 } | 485 } |
| 493 | 486 |
| 494 int UrandomFD(void) { | 487 int UrandomFD(void) { |
| 495 #if defined(OS_POSIX) | 488 #if defined(OS_POSIX) |
| 496 return base::GetUrandomFD(); | 489 return base::GetUrandomFD(); |
| 497 #else | 490 #else |
| 498 return -1; | 491 return -1; |
| 499 #endif | 492 #endif |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 const char* url, | 711 const char* url, |
| 719 uint64_t loaded_bytes, | 712 uint64_t loaded_bytes, |
| 720 uint64_t total_bytes) { | 713 uint64_t total_bytes) { |
| 721 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 714 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 722 if (load_manager) | 715 if (load_manager) |
| 723 load_manager->ReportLoadSuccess(url, loaded_bytes, total_bytes); | 716 load_manager->ReportLoadSuccess(url, loaded_bytes, total_bytes); |
| 724 } | 717 } |
| 725 | 718 |
| 726 void ReportLoadError(PP_Instance instance, | 719 void ReportLoadError(PP_Instance instance, |
| 727 PP_NaClError error, | 720 PP_NaClError error, |
| 728 const char* error_message, | 721 const char* error_message) { |
| 729 const char* console_message) { | |
| 730 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 722 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 731 if (load_manager) | 723 if (load_manager) |
| 732 load_manager->ReportLoadError(error, error_message, console_message); | 724 load_manager->ReportLoadError(error, error_message); |
| 733 } | 725 } |
| 734 | 726 |
| 735 void ReportLoadAbort(PP_Instance instance) { | 727 void ReportLoadAbort(PP_Instance instance) { |
| 736 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 728 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 737 if (load_manager) | 729 if (load_manager) |
| 738 load_manager->ReportLoadAbort(); | 730 load_manager->ReportLoadAbort(); |
| 739 } | 731 } |
| 740 | 732 |
| 741 void NexeDidCrash(PP_Instance instance, const char* crash_log) { | 733 void NexeDidCrash(PP_Instance instance, const char* crash_log) { |
| 742 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 734 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1559 &ReportSelLdrStatus | 1551 &ReportSelLdrStatus |
| 1560 }; | 1552 }; |
| 1561 | 1553 |
| 1562 } // namespace | 1554 } // namespace |
| 1563 | 1555 |
| 1564 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1556 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
| 1565 return &nacl_interface; | 1557 return &nacl_interface; |
| 1566 } | 1558 } |
| 1567 | 1559 |
| 1568 } // namespace nacl | 1560 } // namespace nacl |
| OLD | NEW |