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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/containers/scoped_ptr_hash_map.h" |
14 #include "base/cpu.h" | 15 #include "base/cpu.h" |
15 #include "base/files/file.h" | 16 #include "base/files/file.h" |
16 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
19 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
21 #include "components/nacl/common/nacl_host_messages.h" | 22 #include "components/nacl/common/nacl_host_messages.h" |
22 #include "components/nacl/common/nacl_messages.h" | 23 #include "components/nacl/common/nacl_messages.h" |
23 #include "components/nacl/common/nacl_nonsfi_util.h" | 24 #include "components/nacl/common/nacl_nonsfi_util.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (!render_thread) | 82 if (!render_thread) |
82 return false; | 83 return false; |
83 if (!g_pnacl_resource_host.Get().get()) { | 84 if (!g_pnacl_resource_host.Get().get()) { |
84 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost( | 85 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost( |
85 render_thread->GetIOMessageLoopProxy()); | 86 render_thread->GetIOMessageLoopProxy()); |
86 render_thread->AddFilter(g_pnacl_resource_host.Get().get()); | 87 render_thread->AddFilter(g_pnacl_resource_host.Get().get()); |
87 } | 88 } |
88 return true; | 89 return true; |
89 } | 90 } |
90 | 91 |
| 92 // This contains state that is produced by LaunchSelLdr() and consumed |
| 93 // by StartPpapiProxy(). |
91 struct InstanceInfo { | 94 struct InstanceInfo { |
92 InstanceInfo() : plugin_pid(base::kNullProcessId), plugin_child_id(0) {} | 95 InstanceInfo() : plugin_pid(base::kNullProcessId), plugin_child_id(0) {} |
93 GURL url; | 96 GURL url; |
94 ppapi::PpapiPermissions permissions; | 97 ppapi::PpapiPermissions permissions; |
95 base::ProcessId plugin_pid; | 98 base::ProcessId plugin_pid; |
96 int plugin_child_id; | 99 int plugin_child_id; |
97 IPC::ChannelHandle channel_handle; | 100 IPC::ChannelHandle channel_handle; |
98 }; | 101 }; |
99 | 102 |
100 typedef std::map<PP_Instance, InstanceInfo> InstanceInfoMap; | 103 class NaClPluginInstance { |
| 104 public: |
| 105 NaClPluginInstance(PP_Instance instance): nexe_load_manager(instance) {} |
101 | 106 |
102 base::LazyInstance<InstanceInfoMap> g_instance_info = | 107 NexeLoadManager nexe_load_manager; |
103 LAZY_INSTANCE_INITIALIZER; | 108 scoped_ptr<JsonManifest> json_manifest; |
| 109 scoped_ptr<InstanceInfo> instance_info; |
| 110 }; |
| 111 |
| 112 typedef base::ScopedPtrHashMap<PP_Instance, NaClPluginInstance> InstanceMap; |
| 113 base::LazyInstance<InstanceMap> g_instance_map = LAZY_INSTANCE_INITIALIZER; |
| 114 |
| 115 NaClPluginInstance* GetNaClPluginInstance(PP_Instance instance) { |
| 116 InstanceMap& map = g_instance_map.Get(); |
| 117 InstanceMap::iterator iter = map.find(instance); |
| 118 if (iter == map.end()) |
| 119 return NULL; |
| 120 return iter->second; |
| 121 } |
| 122 |
| 123 NexeLoadManager* GetNexeLoadManager(PP_Instance instance) { |
| 124 NaClPluginInstance* nacl_plugin_instance = GetNaClPluginInstance(instance); |
| 125 if (!nacl_plugin_instance) |
| 126 return NULL; |
| 127 return &nacl_plugin_instance->nexe_load_manager; |
| 128 } |
| 129 |
| 130 JsonManifest* GetJsonManifest(PP_Instance instance) { |
| 131 NaClPluginInstance* nacl_plugin_instance = GetNaClPluginInstance(instance); |
| 132 if (!nacl_plugin_instance) |
| 133 return NULL; |
| 134 return nacl_plugin_instance->json_manifest.get(); |
| 135 } |
104 | 136 |
105 static const PP_NaClFileInfo kInvalidNaClFileInfo = { | 137 static const PP_NaClFileInfo kInvalidNaClFileInfo = { |
106 PP_kInvalidFileHandle, | 138 PP_kInvalidFileHandle, |
107 0, // token_lo | 139 0, // token_lo |
108 0, // token_hi | 140 0, // token_hi |
109 }; | 141 }; |
110 | 142 |
111 int GetRoutingID(PP_Instance instance) { | 143 int GetRoutingID(PP_Instance instance) { |
112 // Check that we are on the main renderer thread. | 144 // Check that we are on the main renderer thread. |
113 DCHECK(content::RenderThread::Get()); | 145 DCHECK(content::RenderThread::Get()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { | 194 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { |
163 public: | 195 public: |
164 ManifestServiceProxy(PP_Instance pp_instance, bool is_helper_process) | 196 ManifestServiceProxy(PP_Instance pp_instance, bool is_helper_process) |
165 : pp_instance_(pp_instance), is_helper_process_(is_helper_process) {} | 197 : pp_instance_(pp_instance), is_helper_process_(is_helper_process) {} |
166 | 198 |
167 ~ManifestServiceProxy() override {} | 199 ~ManifestServiceProxy() override {} |
168 | 200 |
169 void StartupInitializationComplete() override { | 201 void StartupInitializationComplete() override { |
170 if (StartPpapiProxy(pp_instance_) == PP_TRUE) { | 202 if (StartPpapiProxy(pp_instance_) == PP_TRUE) { |
171 JsonManifest* manifest = GetJsonManifest(pp_instance_); | 203 JsonManifest* manifest = GetJsonManifest(pp_instance_); |
172 NexeLoadManager* load_manager = NexeLoadManager::Get(pp_instance_); | 204 NexeLoadManager* load_manager = GetNexeLoadManager(pp_instance_); |
173 if (load_manager && manifest) { | 205 if (load_manager && manifest) { |
174 std::string full_url; | 206 std::string full_url; |
175 PP_PNaClOptions pnacl_options; | 207 PP_PNaClOptions pnacl_options; |
176 bool uses_nonsfi_mode; | 208 bool uses_nonsfi_mode; |
177 JsonManifest::ErrorInfo error_info; | 209 JsonManifest::ErrorInfo error_info; |
178 if (manifest->GetProgramURL(&full_url, | 210 if (manifest->GetProgramURL(&full_url, |
179 &pnacl_options, | 211 &pnacl_options, |
180 &uses_nonsfi_mode, | 212 &uses_nonsfi_mode, |
181 &error_info)) { | 213 &error_info)) { |
182 int64_t nexe_size = load_manager->nexe_size(); | 214 int64_t nexe_size = load_manager->nexe_size(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 process_type), | 401 process_type), |
370 &launch_result, | 402 &launch_result, |
371 &error_message_string))) { | 403 &error_message_string))) { |
372 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 404 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
373 FROM_HERE, | 405 FROM_HERE, |
374 base::Bind(callback.func, callback.user_data, | 406 base::Bind(callback.func, callback.user_data, |
375 static_cast<int32_t>(PP_ERROR_FAILED))); | 407 static_cast<int32_t>(PP_ERROR_FAILED))); |
376 return; | 408 return; |
377 } | 409 } |
378 | 410 |
379 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 411 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
380 DCHECK(load_manager); | 412 DCHECK(load_manager); |
381 if (!load_manager) { | 413 if (!load_manager) { |
382 PostPPCompletionCallback(callback, PP_ERROR_FAILED); | 414 PostPPCompletionCallback(callback, PP_ERROR_FAILED); |
383 base::SharedMemory::CloseHandle(launch_result.crash_info_shmem_handle); | 415 base::SharedMemory::CloseHandle(launch_result.crash_info_shmem_handle); |
384 return; | 416 return; |
385 } | 417 } |
386 load_manager->set_nonsfi(PP_ToBool(uses_nonsfi_mode)); | 418 load_manager->set_nonsfi(PP_ToBool(uses_nonsfi_mode)); |
387 | 419 |
388 if (!error_message_string.empty()) { | 420 if (!error_message_string.empty()) { |
389 if (PP_ToBool(main_service_runtime)) { | 421 if (PP_ToBool(main_service_runtime)) { |
390 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, | 422 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, |
391 "ServiceRuntime: failed to start", | 423 "ServiceRuntime: failed to start", |
392 error_message_string); | 424 error_message_string); |
393 } | 425 } |
394 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 426 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
395 FROM_HERE, | 427 FROM_HERE, |
396 base::Bind(callback.func, callback.user_data, | 428 base::Bind(callback.func, callback.user_data, |
397 static_cast<int32_t>(PP_ERROR_FAILED))); | 429 static_cast<int32_t>(PP_ERROR_FAILED))); |
398 return; | 430 return; |
399 } | 431 } |
400 result_socket = launch_result.imc_channel_handle; | 432 result_socket = launch_result.imc_channel_handle; |
401 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; | 433 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; |
402 instance_info.plugin_pid = launch_result.plugin_pid; | 434 instance_info.plugin_pid = launch_result.plugin_pid; |
403 instance_info.plugin_child_id = launch_result.plugin_child_id; | 435 instance_info.plugin_child_id = launch_result.plugin_child_id; |
404 | 436 |
405 // Don't save instance_info if channel handle is invalid. | 437 // Don't save instance_info if channel handle is invalid. |
406 if (IsValidChannelHandle(instance_info.channel_handle)) | 438 if (IsValidChannelHandle(instance_info.channel_handle)) { |
407 g_instance_info.Get()[instance] = instance_info; | 439 NaClPluginInstance* nacl_plugin_instance = GetNaClPluginInstance(instance); |
| 440 nacl_plugin_instance->instance_info.reset(new InstanceInfo(instance_info)); |
| 441 } |
408 | 442 |
409 *(static_cast<NaClHandle*>(imc_handle)) = ToNativeHandle(result_socket); | 443 *(static_cast<NaClHandle*>(imc_handle)) = ToNativeHandle(result_socket); |
410 | 444 |
411 // Store the crash information shared memory handle. | 445 // Store the crash information shared memory handle. |
412 load_manager->set_crash_info_shmem_handle( | 446 load_manager->set_crash_info_shmem_handle( |
413 launch_result.crash_info_shmem_handle); | 447 launch_result.crash_info_shmem_handle); |
414 | 448 |
415 // Create the trusted plugin channel. | 449 // Create the trusted plugin channel. |
416 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) { | 450 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) { |
417 bool report_exit_status = PP_ToBool(main_service_runtime); | 451 bool report_exit_status = PP_ToBool(main_service_runtime); |
(...skipping 27 matching lines...) Expand all Loading... |
445 manifest_service_channel.Pass()); | 479 manifest_service_channel.Pass()); |
446 } else { | 480 } else { |
447 // The manifest service is not used for some cases like PNaCl pexes. | 481 // The manifest service is not used for some cases like PNaCl pexes. |
448 // In that case, the socket will not be created, and thus this | 482 // In that case, the socket will not be created, and thus this |
449 // condition needs to be handled as success. | 483 // condition needs to be handled as success. |
450 PostPPCompletionCallback(callback, PP_OK); | 484 PostPPCompletionCallback(callback, PP_OK); |
451 } | 485 } |
452 } | 486 } |
453 | 487 |
454 PP_Bool StartPpapiProxy(PP_Instance instance) { | 488 PP_Bool StartPpapiProxy(PP_Instance instance) { |
455 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 489 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
456 DCHECK(load_manager); | 490 DCHECK(load_manager); |
457 if (!load_manager) | 491 if (!load_manager) |
458 return PP_FALSE; | 492 return PP_FALSE; |
459 | 493 |
460 content::PepperPluginInstance* plugin_instance = | 494 content::PepperPluginInstance* plugin_instance = |
461 content::PepperPluginInstance::Get(instance); | 495 content::PepperPluginInstance::Get(instance); |
462 if (!plugin_instance) { | 496 if (!plugin_instance) { |
463 DLOG(ERROR) << "GetInstance() failed"; | 497 DLOG(ERROR) << "GetInstance() failed"; |
464 return PP_FALSE; | 498 return PP_FALSE; |
465 } | 499 } |
466 | 500 |
467 InstanceInfoMap& map = g_instance_info.Get(); | 501 NaClPluginInstance* nacl_plugin_instance = GetNaClPluginInstance(instance); |
468 InstanceInfoMap::iterator it = map.find(instance); | 502 if (!nacl_plugin_instance->instance_info) { |
469 if (it == map.end()) { | |
470 DLOG(ERROR) << "Could not find instance ID"; | 503 DLOG(ERROR) << "Could not find instance ID"; |
471 return PP_FALSE; | 504 return PP_FALSE; |
472 } | 505 } |
473 InstanceInfo instance_info = it->second; | 506 scoped_ptr<InstanceInfo> instance_info = |
474 map.erase(it); | 507 nacl_plugin_instance->instance_info.Pass(); |
475 | 508 |
476 PP_ExternalPluginResult result = plugin_instance->SwitchToOutOfProcessProxy( | 509 PP_ExternalPluginResult result = plugin_instance->SwitchToOutOfProcessProxy( |
477 base::FilePath().AppendASCII(instance_info.url.spec()), | 510 base::FilePath().AppendASCII(instance_info->url.spec()), |
478 instance_info.permissions, | 511 instance_info->permissions, |
479 instance_info.channel_handle, | 512 instance_info->channel_handle, |
480 instance_info.plugin_pid, | 513 instance_info->plugin_pid, |
481 instance_info.plugin_child_id); | 514 instance_info->plugin_child_id); |
482 | 515 |
483 if (result == PP_EXTERNAL_PLUGIN_OK) { | 516 if (result == PP_EXTERNAL_PLUGIN_OK) { |
484 // Log the amound of time that has passed between the trusted plugin being | 517 // Log the amound of time that has passed between the trusted plugin being |
485 // initialized and the untrusted plugin being initialized. This is | 518 // initialized and the untrusted plugin being initialized. This is |
486 // (roughly) the cost of using NaCl, in terms of startup time. | 519 // (roughly) the cost of using NaCl, in terms of startup time. |
487 load_manager->ReportStartupOverhead(); | 520 load_manager->ReportStartupOverhead(); |
488 return PP_TRUE; | 521 return PP_TRUE; |
489 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_MODULE) { | 522 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_MODULE) { |
490 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, | 523 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, |
491 "could not initialize module."); | 524 "could not initialize module."); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 if (opt_level < 0 || opt_level > 3) | 670 if (opt_level < 0 || opt_level > 3) |
638 opt_level = kUnknownOptLevel; | 671 opt_level = kUnknownOptLevel; |
639 HistogramEnumerate("NaCl.Options.PNaCl.OptLevel", | 672 HistogramEnumerate("NaCl.Options.PNaCl.OptLevel", |
640 opt_level, | 673 opt_level, |
641 kUnknownOptLevel + 1); | 674 kUnknownOptLevel + 1); |
642 HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.CompileKBPerSec", | 675 HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.CompileKBPerSec", |
643 pexe_size / 1024, | 676 pexe_size / 1024, |
644 compile_time_us); | 677 compile_time_us); |
645 HistogramSizeKB("NaCl.Perf.Size.Pexe", pexe_size / 1024); | 678 HistogramSizeKB("NaCl.Perf.Size.Pexe", pexe_size / 1024); |
646 | 679 |
647 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 680 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
648 if (load_manager) { | 681 if (load_manager) { |
649 base::TimeDelta total_time = base::Time::Now() - | 682 base::TimeDelta total_time = base::Time::Now() - |
650 load_manager->pnacl_start_time(); | 683 load_manager->pnacl_start_time(); |
651 HistogramTimeTranslation("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", | 684 HistogramTimeTranslation("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", |
652 total_time.InMilliseconds()); | 685 total_time.InMilliseconds()); |
653 HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", | 686 HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", |
654 pexe_size / 1024, | 687 pexe_size / 1024, |
655 total_time.InMicroseconds()); | 688 total_time.InMicroseconds()); |
656 } | 689 } |
657 } | 690 } |
658 | 691 |
659 // If the resource host isn't initialized, don't try to do that here. | 692 // If the resource host isn't initialized, don't try to do that here. |
660 // Just return because something is already very wrong. | 693 // Just return because something is already very wrong. |
661 if (g_pnacl_resource_host.Get().get() == NULL) | 694 if (g_pnacl_resource_host.Get().get() == NULL) |
662 return; | 695 return; |
663 g_pnacl_resource_host.Get()->ReportTranslationFinished(instance, success); | 696 g_pnacl_resource_host.Get()->ReportTranslationFinished(instance, success); |
664 } | 697 } |
665 | 698 |
666 PP_FileHandle OpenNaClExecutable(PP_Instance instance, | 699 PP_FileHandle OpenNaClExecutable(PP_Instance instance, |
667 const char* file_url, | 700 const char* file_url, |
668 uint64_t* nonce_lo, | 701 uint64_t* nonce_lo, |
669 uint64_t* nonce_hi) { | 702 uint64_t* nonce_hi) { |
670 // Fast path only works for installed file URLs. | 703 // Fast path only works for installed file URLs. |
671 GURL gurl(file_url); | 704 GURL gurl(file_url); |
672 if (!gurl.SchemeIs("chrome-extension")) | 705 if (!gurl.SchemeIs("chrome-extension")) |
673 return PP_kInvalidFileHandle; | 706 return PP_kInvalidFileHandle; |
674 | 707 |
675 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 708 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
676 DCHECK(load_manager); | 709 DCHECK(load_manager); |
677 if (!load_manager) | 710 if (!load_manager) |
678 return PP_kInvalidFileHandle; | 711 return PP_kInvalidFileHandle; |
679 | 712 |
680 content::PepperPluginInstance* plugin_instance = | 713 content::PepperPluginInstance* plugin_instance = |
681 content::PepperPluginInstance::Get(instance); | 714 content::PepperPluginInstance::Get(instance); |
682 if (!plugin_instance) | 715 if (!plugin_instance) |
683 return PP_kInvalidFileHandle; | 716 return PP_kInvalidFileHandle; |
684 // IMPORTANT: Make sure the document can request the given URL. If we don't | 717 // IMPORTANT: Make sure the document can request the given URL. If we don't |
685 // check, a malicious app could probe the extension system. This enforces a | 718 // check, a malicious app could probe the extension system. This enforces a |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 resource_url, | 755 resource_url, |
723 PP_ToBool(length_is_computable), | 756 PP_ToBool(length_is_computable), |
724 loaded_bytes, | 757 loaded_bytes, |
725 total_bytes); | 758 total_bytes); |
726 DispatchProgressEvent(instance, event); | 759 DispatchProgressEvent(instance, event); |
727 } | 760 } |
728 | 761 |
729 void ReportLoadSuccess(PP_Instance instance, | 762 void ReportLoadSuccess(PP_Instance instance, |
730 uint64_t loaded_bytes, | 763 uint64_t loaded_bytes, |
731 uint64_t total_bytes) { | 764 uint64_t total_bytes) { |
732 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 765 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
733 if (load_manager) { | 766 if (load_manager) { |
734 load_manager->ReportLoadSuccess(load_manager->program_url(), | 767 load_manager->ReportLoadSuccess(load_manager->program_url(), |
735 loaded_bytes, | 768 loaded_bytes, |
736 total_bytes); | 769 total_bytes); |
737 } | 770 } |
738 } | 771 } |
739 | 772 |
740 void ReportLoadError(PP_Instance instance, | 773 void ReportLoadError(PP_Instance instance, |
741 PP_NaClError error, | 774 PP_NaClError error, |
742 const char* error_message) { | 775 const char* error_message) { |
743 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 776 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
744 if (load_manager) | 777 if (load_manager) |
745 load_manager->ReportLoadError(error, error_message); | 778 load_manager->ReportLoadError(error, error_message); |
746 } | 779 } |
747 | 780 |
748 void InstanceCreated(PP_Instance instance) { | 781 void InstanceCreated(PP_Instance instance) { |
749 NexeLoadManager::Create(instance); | 782 InstanceMap& map = g_instance_map.Get(); |
| 783 CHECK(map.find(instance) == map.end()); // Sanity check. |
| 784 scoped_ptr<NaClPluginInstance> new_instance(new NaClPluginInstance(instance)); |
| 785 map.add(instance, new_instance.Pass()); |
750 } | 786 } |
751 | 787 |
752 void InstanceDestroyed(PP_Instance instance) { | 788 void InstanceDestroyed(PP_Instance instance) { |
753 DeleteJsonManifest(instance); | 789 InstanceMap& map = g_instance_map.Get(); |
754 NexeLoadManager::Delete(instance); | 790 InstanceMap::iterator iter = map.find(instance); |
| 791 CHECK(iter != map.end()); |
| 792 // The erase may call NexeLoadManager's destructor prior to removing it from |
| 793 // the map. In that case, it is possible for the trusted Plugin to re-enter |
| 794 // the NexeLoadManager (e.g., by calling ReportLoadError). Passing out the |
| 795 // NexeLoadManager to a local scoped_ptr just ensures that its entry is gone |
| 796 // from the map prior to the destructor being invoked. |
| 797 scoped_ptr<NaClPluginInstance> temp(map.take(instance)); |
| 798 map.erase(iter); |
755 } | 799 } |
756 | 800 |
757 PP_Bool NaClDebugEnabledForURL(const char* alleged_nmf_url) { | 801 PP_Bool NaClDebugEnabledForURL(const char* alleged_nmf_url) { |
758 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 802 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
759 switches::kEnableNaClDebug)) | 803 switches::kEnableNaClDebug)) |
760 return PP_FALSE; | 804 return PP_FALSE; |
761 IPC::Sender* sender = content::RenderThread::Get(); | 805 IPC::Sender* sender = content::RenderThread::Get(); |
762 DCHECK(sender); | 806 DCHECK(sender); |
763 bool should_debug = false; | 807 bool should_debug = false; |
764 return PP_FromBool( | 808 return PP_FromBool( |
765 sender->Send(new NaClHostMsg_NaClDebugEnabledForURL(GURL(alleged_nmf_url), | 809 sender->Send(new NaClHostMsg_NaClDebugEnabledForURL(GURL(alleged_nmf_url), |
766 &should_debug)) && | 810 &should_debug)) && |
767 should_debug); | 811 should_debug); |
768 } | 812 } |
769 | 813 |
770 void Vlog(const char* message) { | 814 void Vlog(const char* message) { |
771 VLOG(1) << message; | 815 VLOG(1) << message; |
772 } | 816 } |
773 | 817 |
774 void InitializePlugin(PP_Instance instance, | 818 void InitializePlugin(PP_Instance instance, |
775 uint32_t argc, | 819 uint32_t argc, |
776 const char* argn[], | 820 const char* argn[], |
777 const char* argv[]) { | 821 const char* argv[]) { |
778 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 822 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
779 DCHECK(load_manager); | 823 DCHECK(load_manager); |
780 if (load_manager) | 824 if (load_manager) |
781 load_manager->InitializePlugin(argc, argn, argv); | 825 load_manager->InitializePlugin(argc, argn, argv); |
782 } | 826 } |
783 | 827 |
784 void DownloadManifestToBuffer(PP_Instance instance, | 828 void DownloadManifestToBuffer(PP_Instance instance, |
785 struct PP_CompletionCallback callback); | 829 struct PP_CompletionCallback callback); |
786 | 830 |
787 bool CreateJsonManifest(PP_Instance instance, | 831 bool CreateJsonManifest(PP_Instance instance, |
788 const std::string& manifest_url, | 832 const std::string& manifest_url, |
789 const std::string& manifest_data); | 833 const std::string& manifest_data); |
790 | 834 |
791 void RequestNaClManifest(PP_Instance instance, | 835 void RequestNaClManifest(PP_Instance instance, |
792 PP_CompletionCallback callback) { | 836 PP_CompletionCallback callback) { |
793 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 837 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
794 DCHECK(load_manager); | 838 DCHECK(load_manager); |
795 if (!load_manager) { | 839 if (!load_manager) { |
796 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 840 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
797 FROM_HERE, | 841 FROM_HERE, |
798 base::Bind(callback.func, callback.user_data, | 842 base::Bind(callback.func, callback.user_data, |
799 static_cast<int32_t>(PP_ERROR_FAILED))); | 843 static_cast<int32_t>(PP_ERROR_FAILED))); |
800 return; | 844 return; |
801 } | 845 } |
802 | 846 |
803 std::string url = load_manager->GetManifestURLArgument(); | 847 std::string url = load_manager->GetManifestURLArgument(); |
(...skipping 26 matching lines...) Expand all Loading... |
830 } | 874 } |
831 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 875 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
832 FROM_HERE, | 876 FROM_HERE, |
833 base::Bind(callback.func, callback.user_data, error)); | 877 base::Bind(callback.func, callback.user_data, error)); |
834 } else { | 878 } else { |
835 DownloadManifestToBuffer(instance, callback); | 879 DownloadManifestToBuffer(instance, callback); |
836 } | 880 } |
837 } | 881 } |
838 | 882 |
839 PP_Var GetManifestBaseURL(PP_Instance instance) { | 883 PP_Var GetManifestBaseURL(PP_Instance instance) { |
840 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 884 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
841 DCHECK(load_manager); | 885 DCHECK(load_manager); |
842 if (!load_manager) | 886 if (!load_manager) |
843 return PP_MakeUndefined(); | 887 return PP_MakeUndefined(); |
844 const GURL& gurl = load_manager->manifest_base_url(); | 888 const GURL& gurl = load_manager->manifest_base_url(); |
845 if (!gurl.is_valid()) | 889 if (!gurl.is_valid()) |
846 return PP_MakeUndefined(); | 890 return PP_MakeUndefined(); |
847 return ppapi::StringVar::StringToPPVar(gurl.spec()); | 891 return ppapi::StringVar::StringToPPVar(gurl.spec()); |
848 } | 892 } |
849 | 893 |
850 void ProcessNaClManifest(PP_Instance instance, const char* program_url) { | 894 void ProcessNaClManifest(PP_Instance instance, const char* program_url) { |
851 nacl::NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 895 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
852 if (load_manager) | 896 if (load_manager) |
853 load_manager->ProcessNaClManifest(program_url); | 897 load_manager->ProcessNaClManifest(program_url); |
854 } | 898 } |
855 | 899 |
856 PP_Bool DevInterfacesEnabled(PP_Instance instance) { | 900 PP_Bool DevInterfacesEnabled(PP_Instance instance) { |
857 nacl::NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 901 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
858 if (load_manager) | 902 if (load_manager) |
859 return PP_FromBool(load_manager->DevInterfacesEnabled()); | 903 return PP_FromBool(load_manager->DevInterfacesEnabled()); |
860 return PP_FALSE; | 904 return PP_FALSE; |
861 } | 905 } |
862 | 906 |
863 void DownloadManifestToBufferCompletion(PP_Instance instance, | 907 void DownloadManifestToBufferCompletion(PP_Instance instance, |
864 struct PP_CompletionCallback callback, | 908 struct PP_CompletionCallback callback, |
865 base::Time start_time, | 909 base::Time start_time, |
866 PP_NaClError pp_nacl_error, | 910 PP_NaClError pp_nacl_error, |
867 const std::string& data); | 911 const std::string& data); |
868 | 912 |
869 void DownloadManifestToBuffer(PP_Instance instance, | 913 void DownloadManifestToBuffer(PP_Instance instance, |
870 struct PP_CompletionCallback callback) { | 914 struct PP_CompletionCallback callback) { |
871 nacl::NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 915 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
872 DCHECK(load_manager); | 916 DCHECK(load_manager); |
873 content::PepperPluginInstance* plugin_instance = | 917 content::PepperPluginInstance* plugin_instance = |
874 content::PepperPluginInstance::Get(instance); | 918 content::PepperPluginInstance::Get(instance); |
875 if (!load_manager || !plugin_instance) { | 919 if (!load_manager || !plugin_instance) { |
876 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 920 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
877 FROM_HERE, | 921 FROM_HERE, |
878 base::Bind(callback.func, callback.user_data, | 922 base::Bind(callback.func, callback.user_data, |
879 static_cast<int32_t>(PP_ERROR_FAILED))); | 923 static_cast<int32_t>(PP_ERROR_FAILED))); |
880 } | 924 } |
881 const blink::WebDocument& document = | 925 const blink::WebDocument& document = |
(...skipping 15 matching lines...) Expand all Loading... |
897 | 941 |
898 void DownloadManifestToBufferCompletion(PP_Instance instance, | 942 void DownloadManifestToBufferCompletion(PP_Instance instance, |
899 struct PP_CompletionCallback callback, | 943 struct PP_CompletionCallback callback, |
900 base::Time start_time, | 944 base::Time start_time, |
901 PP_NaClError pp_nacl_error, | 945 PP_NaClError pp_nacl_error, |
902 const std::string& data) { | 946 const std::string& data) { |
903 base::TimeDelta download_time = base::Time::Now() - start_time; | 947 base::TimeDelta download_time = base::Time::Now() - start_time; |
904 HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload", | 948 HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload", |
905 download_time.InMilliseconds()); | 949 download_time.InMilliseconds()); |
906 | 950 |
907 nacl::NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 951 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
908 if (!load_manager) { | 952 if (!load_manager) { |
909 callback.func(callback.user_data, PP_ERROR_ABORTED); | 953 callback.func(callback.user_data, PP_ERROR_ABORTED); |
910 return; | 954 return; |
911 } | 955 } |
912 | 956 |
913 int32_t pp_error; | 957 int32_t pp_error; |
914 switch (pp_nacl_error) { | 958 switch (pp_nacl_error) { |
915 case PP_NACL_ERROR_LOAD_SUCCESS: | 959 case PP_NACL_ERROR_LOAD_SUCCESS: |
916 pp_error = PP_OK; | 960 pp_error = PP_OK; |
917 break; | 961 break; |
(...skipping 26 matching lines...) Expand all Loading... |
944 } | 988 } |
945 callback.func(callback.user_data, pp_error); | 989 callback.func(callback.user_data, pp_error); |
946 } | 990 } |
947 | 991 |
948 bool CreateJsonManifest(PP_Instance instance, | 992 bool CreateJsonManifest(PP_Instance instance, |
949 const std::string& manifest_url, | 993 const std::string& manifest_url, |
950 const std::string& manifest_data) { | 994 const std::string& manifest_data) { |
951 HistogramSizeKB("NaCl.Perf.Size.Manifest", | 995 HistogramSizeKB("NaCl.Perf.Size.Manifest", |
952 static_cast<int32_t>(manifest_data.length() / 1024)); | 996 static_cast<int32_t>(manifest_data.length() / 1024)); |
953 | 997 |
954 nacl::NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 998 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
955 if (!load_manager) | 999 if (!load_manager) |
956 return false; | 1000 return false; |
957 | 1001 |
958 const char* isa_type; | 1002 const char* isa_type; |
959 if (load_manager->IsPNaCl()) | 1003 if (load_manager->IsPNaCl()) |
960 isa_type = kPortableArch; | 1004 isa_type = kPortableArch; |
961 else | 1005 else |
962 isa_type = GetSandboxArch(); | 1006 isa_type = GetSandboxArch(); |
963 | 1007 |
964 scoped_ptr<nacl::JsonManifest> j( | 1008 scoped_ptr<nacl::JsonManifest> j( |
965 new nacl::JsonManifest( | 1009 new nacl::JsonManifest( |
966 manifest_url.c_str(), | 1010 manifest_url.c_str(), |
967 isa_type, | 1011 isa_type, |
968 IsNonSFIModeEnabled(), | 1012 IsNonSFIModeEnabled(), |
969 PP_ToBool(NaClDebugEnabledForURL(manifest_url.c_str())))); | 1013 PP_ToBool(NaClDebugEnabledForURL(manifest_url.c_str())))); |
970 JsonManifest::ErrorInfo error_info; | 1014 JsonManifest::ErrorInfo error_info; |
971 if (j->Init(manifest_data.c_str(), &error_info)) { | 1015 if (j->Init(manifest_data.c_str(), &error_info)) { |
972 AddJsonManifest(instance, j.Pass()); | 1016 GetNaClPluginInstance(instance)->json_manifest.reset(j.release()); |
973 return true; | 1017 return true; |
974 } | 1018 } |
975 load_manager->ReportLoadError(error_info.error, error_info.string); | 1019 load_manager->ReportLoadError(error_info.error, error_info.string); |
976 return false; | 1020 return false; |
977 } | 1021 } |
978 | 1022 |
979 PP_Bool ManifestGetProgramURL(PP_Instance instance, | 1023 PP_Bool ManifestGetProgramURL(PP_Instance instance, |
980 PP_Var* pp_full_url, | 1024 PP_Var* pp_full_url, |
981 PP_PNaClOptions* pnacl_options, | 1025 PP_PNaClOptions* pnacl_options, |
982 PP_Bool* pp_uses_nonsfi_mode) { | 1026 PP_Bool* pp_uses_nonsfi_mode) { |
983 nacl::NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 1027 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
984 | 1028 |
985 JsonManifest* manifest = GetJsonManifest(instance); | 1029 JsonManifest* manifest = GetJsonManifest(instance); |
986 if (manifest == NULL) | 1030 if (manifest == NULL) |
987 return PP_FALSE; | 1031 return PP_FALSE; |
988 | 1032 |
989 bool uses_nonsfi_mode; | 1033 bool uses_nonsfi_mode; |
990 std::string full_url; | 1034 std::string full_url; |
991 JsonManifest::ErrorInfo error_info; | 1035 JsonManifest::ErrorInfo error_info; |
992 if (manifest->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode, | 1036 if (manifest->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode, |
993 &error_info)) { | 1037 &error_info)) { |
(...skipping 12 matching lines...) Expand all Loading... |
1006 const std::string& key, | 1050 const std::string& key, |
1007 std::string* full_url, | 1051 std::string* full_url, |
1008 PP_PNaClOptions* pnacl_options) { | 1052 PP_PNaClOptions* pnacl_options) { |
1009 // For "helper" processes (llc and ld, for PNaCl translation), we resolve | 1053 // For "helper" processes (llc and ld, for PNaCl translation), we resolve |
1010 // keys manually as there is no existing .nmf file to parse. | 1054 // keys manually as there is no existing .nmf file to parse. |
1011 if (is_helper_process) { | 1055 if (is_helper_process) { |
1012 pnacl_options->translate = PP_FALSE; | 1056 pnacl_options->translate = PP_FALSE; |
1013 // We can only resolve keys in the files/ namespace. | 1057 // We can only resolve keys in the files/ namespace. |
1014 const std::string kFilesPrefix = "files/"; | 1058 const std::string kFilesPrefix = "files/"; |
1015 if (key.find(kFilesPrefix) == std::string::npos) { | 1059 if (key.find(kFilesPrefix) == std::string::npos) { |
1016 nacl::NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 1060 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1017 if (load_manager) | 1061 if (load_manager) |
1018 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | 1062 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
1019 "key did not start with files/"); | 1063 "key did not start with files/"); |
1020 return false; | 1064 return false; |
1021 } | 1065 } |
1022 std::string key_basename = key.substr(kFilesPrefix.length()); | 1066 std::string key_basename = key.substr(kFilesPrefix.length()); |
1023 *full_url = std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" + | 1067 *full_url = std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" + |
1024 key_basename; | 1068 key_basename; |
1025 return true; | 1069 return true; |
1026 } | 1070 } |
1027 | 1071 |
1028 JsonManifest* manifest = GetJsonManifest(instance); | 1072 JsonManifest* manifest = GetJsonManifest(instance); |
1029 if (manifest == NULL) | 1073 if (manifest == NULL) |
1030 return false; | 1074 return false; |
1031 | 1075 |
1032 return manifest->ResolveKey(key, full_url, pnacl_options); | 1076 return manifest->ResolveKey(key, full_url, pnacl_options); |
1033 } | 1077 } |
1034 | 1078 |
1035 PP_Bool GetPNaClResourceInfo(PP_Instance instance, | 1079 PP_Bool GetPNaClResourceInfo(PP_Instance instance, |
1036 PP_Var* llc_tool_name, | 1080 PP_Var* llc_tool_name, |
1037 PP_Var* ld_tool_name) { | 1081 PP_Var* ld_tool_name) { |
1038 static const char kFilename[] = "chrome://pnacl-translator/pnacl.json"; | 1082 static const char kFilename[] = "chrome://pnacl-translator/pnacl.json"; |
1039 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 1083 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1040 DCHECK(load_manager); | 1084 DCHECK(load_manager); |
1041 if (!load_manager) | 1085 if (!load_manager) |
1042 return PP_FALSE; | 1086 return PP_FALSE; |
1043 | 1087 |
1044 uint64_t nonce_lo = 0; | 1088 uint64_t nonce_lo = 0; |
1045 uint64_t nonce_hi = 0; | 1089 uint64_t nonce_hi = 0; |
1046 base::File file(GetReadonlyPnaclFd(kFilename, false /* is_executable */, | 1090 base::File file(GetReadonlyPnaclFd(kFilename, false /* is_executable */, |
1047 &nonce_lo, &nonce_hi)); | 1091 &nonce_lo, &nonce_hi)); |
1048 if (!file.IsValid()) { | 1092 if (!file.IsValid()) { |
1049 load_manager->ReportLoadError( | 1093 load_manager->ReportLoadError( |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 bytes_read = info.size; | 1286 bytes_read = info.size; |
1243 } | 1287 } |
1244 | 1288 |
1245 if (bytes_read == -1) { | 1289 if (bytes_read == -1) { |
1246 target_file.Close(); | 1290 target_file.Close(); |
1247 pp_error = PP_ERROR_FAILED; | 1291 pp_error = PP_ERROR_FAILED; |
1248 } | 1292 } |
1249 | 1293 |
1250 base::TimeDelta download_time = base::Time::Now() - request.start_time; | 1294 base::TimeDelta download_time = base::Time::Now() - request.start_time; |
1251 | 1295 |
1252 NexeLoadManager* load_manager = NexeLoadManager::Get(request.instance); | 1296 NexeLoadManager* load_manager = GetNexeLoadManager(request.instance); |
1253 if (load_manager) { | 1297 if (load_manager) { |
1254 load_manager->NexeFileDidOpen(pp_error, | 1298 load_manager->NexeFileDidOpen(pp_error, |
1255 target_file, | 1299 target_file, |
1256 http_status, | 1300 http_status, |
1257 bytes_read, | 1301 bytes_read, |
1258 request.url, | 1302 request.url, |
1259 download_time); | 1303 download_time); |
1260 } | 1304 } |
1261 | 1305 |
1262 if (pp_error == PP_OK && target_file.IsValid()) | 1306 if (pp_error == PP_OK && target_file.IsValid()) |
(...skipping 21 matching lines...) Expand all Loading... |
1284 | 1328 |
1285 callback.Run(pp_error, file_info); | 1329 callback.Run(pp_error, file_info); |
1286 } | 1330 } |
1287 | 1331 |
1288 void DownloadFile(PP_Instance instance, | 1332 void DownloadFile(PP_Instance instance, |
1289 const std::string& url, | 1333 const std::string& url, |
1290 const DownloadFileCallback& callback) { | 1334 const DownloadFileCallback& callback) { |
1291 DCHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> | 1335 DCHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
1292 BelongsToCurrentThread()); | 1336 BelongsToCurrentThread()); |
1293 | 1337 |
1294 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 1338 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1295 DCHECK(load_manager); | 1339 DCHECK(load_manager); |
1296 if (!load_manager) { | 1340 if (!load_manager) { |
1297 base::MessageLoop::current()->PostTask( | 1341 base::MessageLoop::current()->PostTask( |
1298 FROM_HERE, | 1342 FROM_HERE, |
1299 base::Bind(callback, | 1343 base::Bind(callback, |
1300 static_cast<int32_t>(PP_ERROR_FAILED), | 1344 static_cast<int32_t>(PP_ERROR_FAILED), |
1301 kInvalidNaClFileInfo)); | 1345 kInvalidNaClFileInfo)); |
1302 return; | 1346 return; |
1303 } | 1347 } |
1304 | 1348 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 base::Bind(&DownloadFileCompletion, callback), | 1428 base::Bind(&DownloadFileCompletion, callback), |
1385 base::Bind(&ProgressEventRateLimiter::ReportProgress, | 1429 base::Bind(&ProgressEventRateLimiter::ReportProgress, |
1386 base::Owned(tracker), std::string(url))); | 1430 base::Owned(tracker), std::string(url))); |
1387 file_downloader->Load(url_request); | 1431 file_downloader->Load(url_request); |
1388 } | 1432 } |
1389 | 1433 |
1390 void ReportSelLdrStatus(PP_Instance instance, | 1434 void ReportSelLdrStatus(PP_Instance instance, |
1391 int32_t load_status, | 1435 int32_t load_status, |
1392 int32_t max_status) { | 1436 int32_t max_status) { |
1393 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status); | 1437 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status); |
1394 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 1438 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1395 DCHECK(load_manager); | 1439 DCHECK(load_manager); |
1396 if (!load_manager) | 1440 if (!load_manager) |
1397 return; | 1441 return; |
1398 | 1442 |
1399 // Gather data to see if being installed changes load outcomes. | 1443 // Gather data to see if being installed changes load outcomes. |
1400 const char* name = load_manager->is_installed() ? | 1444 const char* name = load_manager->is_installed() ? |
1401 "NaCl.LoadStatus.SelLdr.InstalledApp" : | 1445 "NaCl.LoadStatus.SelLdr.InstalledApp" : |
1402 "NaCl.LoadStatus.SelLdr.NotInstalledApp"; | 1446 "NaCl.LoadStatus.SelLdr.NotInstalledApp"; |
1403 HistogramEnumerate(name, load_status, max_status); | 1447 HistogramEnumerate(name, load_status, max_status); |
1404 } | 1448 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 PostPPCompletionCallback(callback, PP_ERROR_FAILED); | 1483 PostPPCompletionCallback(callback, PP_ERROR_FAILED); |
1440 } | 1484 } |
1441 | 1485 |
1442 // TODO(teravest): Make a type like PP_NaClFileInfo to use for DownloadFile | 1486 // TODO(teravest): Make a type like PP_NaClFileInfo to use for DownloadFile |
1443 // that would close the file handle on destruction. | 1487 // that would close the file handle on destruction. |
1444 DownloadFile(instance, url, | 1488 DownloadFile(instance, url, |
1445 base::Bind(&DidOpenManifestEntry, out_file_info, callback)); | 1489 base::Bind(&DidOpenManifestEntry, out_file_info, callback)); |
1446 } | 1490 } |
1447 | 1491 |
1448 void SetPNaClStartTime(PP_Instance instance) { | 1492 void SetPNaClStartTime(PP_Instance instance) { |
1449 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 1493 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1450 if (load_manager) | 1494 if (load_manager) |
1451 load_manager->set_pnacl_start_time(base::Time::Now()); | 1495 load_manager->set_pnacl_start_time(base::Time::Now()); |
1452 } | 1496 } |
1453 | 1497 |
1454 // PexeDownloader is responsible for deleting itself when the download | 1498 // PexeDownloader is responsible for deleting itself when the download |
1455 // finishes. | 1499 // finishes. |
1456 class PexeDownloader : public blink::WebURLLoaderClient { | 1500 class PexeDownloader : public blink::WebURLLoaderClient { |
1457 public: | 1501 public: |
1458 PexeDownloader(PP_Instance instance, | 1502 PexeDownloader(PP_Instance instance, |
1459 scoped_ptr<blink::WebURLLoader> url_loader, | 1503 scoped_ptr<blink::WebURLLoader> url_loader, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 &StreamPexe | 1695 &StreamPexe |
1652 }; | 1696 }; |
1653 | 1697 |
1654 } // namespace | 1698 } // namespace |
1655 | 1699 |
1656 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1700 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1657 return &nacl_interface; | 1701 return &nacl_interface; |
1658 } | 1702 } |
1659 | 1703 |
1660 } // namespace nacl | 1704 } // namespace nacl |
OLD | NEW |