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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 95 |
96 base::LazyInstance<InstanceInfoMap> g_instance_info = | 96 base::LazyInstance<InstanceInfoMap> g_instance_info = |
97 LAZY_INSTANCE_INITIALIZER; | 97 LAZY_INSTANCE_INITIALIZER; |
98 | 98 |
99 typedef base::ScopedPtrHashMap<PP_Instance, NexeLoadManager> | 99 typedef base::ScopedPtrHashMap<PP_Instance, NexeLoadManager> |
100 NexeLoadManagerMap; | 100 NexeLoadManagerMap; |
101 | 101 |
102 base::LazyInstance<NexeLoadManagerMap> g_load_manager_map = | 102 base::LazyInstance<NexeLoadManagerMap> g_load_manager_map = |
103 LAZY_INSTANCE_INITIALIZER; | 103 LAZY_INSTANCE_INITIALIZER; |
104 | 104 |
105 typedef base::ScopedPtrHashMap<int32_t, nacl::JsonManifest> JsonManifestMap; | 105 typedef base::ScopedPtrHashMap<PP_Instance, nacl::JsonManifest> JsonManifestMap; |
106 | 106 |
107 base::LazyInstance<JsonManifestMap> g_manifest_map = | 107 base::LazyInstance<JsonManifestMap> g_manifest_map = |
108 LAZY_INSTANCE_INITIALIZER; | 108 LAZY_INSTANCE_INITIALIZER; |
109 | 109 |
110 base::LazyInstance<int32_t> g_next_manifest_id = | |
111 LAZY_INSTANCE_INITIALIZER; | |
112 | |
113 // We have to define a method here since we can't use a static initializer. | |
114 int32_t GetPNaClManifestId() { | |
115 return std::numeric_limits<int32_t>::max(); | |
116 } | |
117 | |
118 nacl::NexeLoadManager* GetNexeLoadManager(PP_Instance instance) { | 110 nacl::NexeLoadManager* GetNexeLoadManager(PP_Instance instance) { |
119 NexeLoadManagerMap& map = g_load_manager_map.Get(); | 111 NexeLoadManagerMap& map = g_load_manager_map.Get(); |
120 NexeLoadManagerMap::iterator iter = map.find(instance); | 112 NexeLoadManagerMap::iterator iter = map.find(instance); |
121 if (iter != map.end()) | 113 if (iter != map.end()) |
122 return iter->second; | 114 return iter->second; |
123 return NULL; | 115 return NULL; |
124 } | 116 } |
125 | 117 |
126 int GetRoutingID(PP_Instance instance) { | 118 int GetRoutingID(PP_Instance instance) { |
127 // Check that we are on the main renderer thread. | 119 // Check that we are on the main renderer thread. |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 } | 731 } |
740 | 732 |
741 void InstanceCreated(PP_Instance instance) { | 733 void InstanceCreated(PP_Instance instance) { |
742 scoped_ptr<NexeLoadManager> new_load_manager(new NexeLoadManager(instance)); | 734 scoped_ptr<NexeLoadManager> new_load_manager(new NexeLoadManager(instance)); |
743 NexeLoadManagerMap& map = g_load_manager_map.Get(); | 735 NexeLoadManagerMap& map = g_load_manager_map.Get(); |
744 DLOG_IF(ERROR, map.count(instance) != 0) << "Instance count should be 0"; | 736 DLOG_IF(ERROR, map.count(instance) != 0) << "Instance count should be 0"; |
745 map.add(instance, new_load_manager.Pass()); | 737 map.add(instance, new_load_manager.Pass()); |
746 } | 738 } |
747 | 739 |
748 void InstanceDestroyed(PP_Instance instance) { | 740 void InstanceDestroyed(PP_Instance instance) { |
741 g_manifest_map.Get().erase(instance); | |
742 | |
749 NexeLoadManagerMap& map = g_load_manager_map.Get(); | 743 NexeLoadManagerMap& map = g_load_manager_map.Get(); |
750 DLOG_IF(ERROR, map.count(instance) == 0) << "Could not find instance ID"; | 744 DLOG_IF(ERROR, map.count(instance) == 0) << "Could not find instance ID"; |
751 // The erase may call NexeLoadManager's destructor prior to removing it from | 745 // The erase may call NexeLoadManager's destructor prior to removing it from |
752 // the map. In that case, it is possible for the trusted Plugin to re-enter | 746 // the map. In that case, it is possible for the trusted Plugin to re-enter |
753 // the NexeLoadManager (e.g., by calling ReportLoadError). Passing out the | 747 // the NexeLoadManager (e.g., by calling ReportLoadError). Passing out the |
754 // NexeLoadManager to a local scoped_ptr just ensures that its entry is gone | 748 // NexeLoadManager to a local scoped_ptr just ensures that its entry is gone |
755 // from the map prior to the destructor being invoked. | 749 // from the map prior to the destructor being invoked. |
756 scoped_ptr<NexeLoadManager> temp(map.take(instance)); | 750 scoped_ptr<NexeLoadManager> temp(map.take(instance)); |
757 map.erase(instance); | 751 map.erase(instance); |
758 } | 752 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 | 819 |
826 int64_t GetNexeSize(PP_Instance instance) { | 820 int64_t GetNexeSize(PP_Instance instance) { |
827 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 821 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
828 DCHECK(load_manager); | 822 DCHECK(load_manager); |
829 if (load_manager) | 823 if (load_manager) |
830 return load_manager->nexe_size(); | 824 return load_manager->nexe_size(); |
831 return 0; | 825 return 0; |
832 } | 826 } |
833 | 827 |
834 void DownloadManifestToBuffer(PP_Instance instance, | 828 void DownloadManifestToBuffer(PP_Instance instance, |
835 int32_t* out_manifest_id, | |
836 struct PP_CompletionCallback callback); | 829 struct PP_CompletionCallback callback); |
837 | 830 |
838 int32_t CreateJsonManifest(PP_Instance instance, | 831 int32_t CreateJsonManifest(PP_Instance instance, |
839 const std::string& manifest_url, | 832 const std::string& manifest_url, |
840 const std::string& manifest_data); | 833 const std::string& manifest_data); |
841 | 834 |
842 void RequestNaClManifest(PP_Instance instance, | 835 void RequestNaClManifest(PP_Instance instance, |
843 const char* url, | 836 const char* url, |
844 int32_t* out_manifest_id, | |
845 PP_CompletionCallback callback) { | 837 PP_CompletionCallback callback) { |
846 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 838 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
847 DCHECK(load_manager); | 839 DCHECK(load_manager); |
848 if (!load_manager) { | 840 if (!load_manager) { |
849 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 841 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
850 FROM_HERE, | 842 FROM_HERE, |
851 base::Bind(callback.func, callback.user_data, | 843 base::Bind(callback.func, callback.user_data, |
852 static_cast<int32_t>(PP_ERROR_FAILED))); | 844 static_cast<int32_t>(PP_ERROR_FAILED))); |
853 return; | 845 return; |
854 } | 846 } |
855 | 847 |
856 if (!load_manager->RequestNaClManifest(url)) { | 848 if (!load_manager->RequestNaClManifest(url)) { |
857 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 849 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
858 FROM_HERE, | 850 FROM_HERE, |
859 base::Bind(callback.func, callback.user_data, | 851 base::Bind(callback.func, callback.user_data, |
860 static_cast<int32_t>(PP_ERROR_FAILED))); | 852 static_cast<int32_t>(PP_ERROR_FAILED))); |
861 return; | 853 return; |
862 } | 854 } |
863 | 855 |
864 const GURL& base_url = load_manager->manifest_base_url(); | 856 const GURL& base_url = load_manager->manifest_base_url(); |
865 if (base_url.SchemeIs("data")) { | 857 if (base_url.SchemeIs("data")) { |
866 GURL gurl(base_url); | 858 GURL gurl(base_url); |
867 std::string mime_type; | 859 std::string mime_type; |
868 std::string charset; | 860 std::string charset; |
869 std::string data; | 861 std::string data; |
870 int32_t error = PP_ERROR_FAILED; | 862 int32_t error = PP_ERROR_FAILED; |
871 if (net::DataURL::Parse(gurl, &mime_type, &charset, &data)) { | 863 if (net::DataURL::Parse(gurl, &mime_type, &charset, &data)) { |
872 if (data.size() <= ManifestDownloader::kNaClManifestMaxFileBytes) { | 864 if (data.size() <= ManifestDownloader::kNaClManifestMaxFileBytes) { |
873 error = PP_OK; | 865 error = PP_OK; |
874 *out_manifest_id = CreateJsonManifest(instance, base_url.spec(), data); | 866 CreateJsonManifest(instance, base_url.spec(), data); |
875 } else { | 867 } else { |
876 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_TOO_LARGE, | 868 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_TOO_LARGE, |
877 "manifest file too large."); | 869 "manifest file too large."); |
878 } | 870 } |
879 } else { | 871 } else { |
880 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_LOAD_URL, | 872 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_LOAD_URL, |
881 "could not load manifest url."); | 873 "could not load manifest url."); |
882 } | 874 } |
883 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 875 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
884 FROM_HERE, | 876 FROM_HERE, |
885 base::Bind(callback.func, callback.user_data, error)); | 877 base::Bind(callback.func, callback.user_data, error)); |
886 } else { | 878 } else { |
887 DownloadManifestToBuffer(instance, out_manifest_id, callback); | 879 DownloadManifestToBuffer(instance, callback); |
888 } | 880 } |
889 } | 881 } |
890 | 882 |
891 PP_Var GetManifestBaseURL(PP_Instance instance) { | 883 PP_Var GetManifestBaseURL(PP_Instance instance) { |
892 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 884 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
893 DCHECK(load_manager); | 885 DCHECK(load_manager); |
894 if (!load_manager) | 886 if (!load_manager) |
895 return PP_MakeUndefined(); | 887 return PP_MakeUndefined(); |
896 const GURL& gurl = load_manager->manifest_base_url(); | 888 const GURL& gurl = load_manager->manifest_base_url(); |
897 if (!gurl.is_valid()) | 889 if (!gurl.is_valid()) |
(...skipping 18 matching lines...) Expand all Loading... | |
916 | 908 |
917 PP_Bool DevInterfacesEnabled(PP_Instance instance) { | 909 PP_Bool DevInterfacesEnabled(PP_Instance instance) { |
918 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 910 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
919 if (load_manager) | 911 if (load_manager) |
920 return PP_FromBool(load_manager->DevInterfacesEnabled()); | 912 return PP_FromBool(load_manager->DevInterfacesEnabled()); |
921 return PP_FALSE; | 913 return PP_FALSE; |
922 } | 914 } |
923 | 915 |
924 void DownloadManifestToBufferCompletion(PP_Instance instance, | 916 void DownloadManifestToBufferCompletion(PP_Instance instance, |
925 struct PP_CompletionCallback callback, | 917 struct PP_CompletionCallback callback, |
926 int32_t* out_manifest_id, | |
927 base::Time start_time, | 918 base::Time start_time, |
928 PP_NaClError pp_nacl_error, | 919 PP_NaClError pp_nacl_error, |
929 const std::string& data); | 920 const std::string& data); |
930 | 921 |
931 void DownloadManifestToBuffer(PP_Instance instance, | 922 void DownloadManifestToBuffer(PP_Instance instance, |
932 int32_t* out_manifest_id, | |
933 struct PP_CompletionCallback callback) { | 923 struct PP_CompletionCallback callback) { |
934 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 924 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
935 DCHECK(load_manager); | 925 DCHECK(load_manager); |
936 content::PepperPluginInstance* plugin_instance = | 926 content::PepperPluginInstance* plugin_instance = |
937 content::PepperPluginInstance::Get(instance); | 927 content::PepperPluginInstance::Get(instance); |
938 if (!load_manager || !plugin_instance) { | 928 if (!load_manager || !plugin_instance) { |
939 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 929 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
940 FROM_HERE, | 930 FROM_HERE, |
941 base::Bind(callback.func, callback.user_data, | 931 base::Bind(callback.func, callback.user_data, |
942 static_cast<int32_t>(PP_ERROR_FAILED))); | 932 static_cast<int32_t>(PP_ERROR_FAILED))); |
943 } | 933 } |
944 const blink::WebDocument& document = | 934 const blink::WebDocument& document = |
945 plugin_instance->GetContainer()->element().document(); | 935 plugin_instance->GetContainer()->element().document(); |
946 | 936 |
947 const GURL& gurl = load_manager->manifest_base_url(); | 937 const GURL& gurl = load_manager->manifest_base_url(); |
948 scoped_ptr<blink::WebURLLoader> url_loader( | 938 scoped_ptr<blink::WebURLLoader> url_loader( |
949 CreateWebURLLoader(document, gurl)); | 939 CreateWebURLLoader(document, gurl)); |
950 blink::WebURLRequest request = CreateWebURLRequest(document, gurl); | 940 blink::WebURLRequest request = CreateWebURLRequest(document, gurl); |
951 | 941 |
952 // ManifestDownloader deletes itself after invoking the callback. | 942 // ManifestDownloader deletes itself after invoking the callback. |
953 ManifestDownloader* manifest_downloader = new ManifestDownloader( | 943 ManifestDownloader* manifest_downloader = new ManifestDownloader( |
954 url_loader.Pass(), | 944 url_loader.Pass(), |
955 load_manager->is_installed(), | 945 load_manager->is_installed(), |
956 base::Bind(DownloadManifestToBufferCompletion, | 946 base::Bind(DownloadManifestToBufferCompletion, |
957 instance, callback, out_manifest_id, base::Time::Now())); | 947 instance, callback, base::Time::Now())); |
958 manifest_downloader->Load(request); | 948 manifest_downloader->Load(request); |
959 } | 949 } |
960 | 950 |
961 void DownloadManifestToBufferCompletion(PP_Instance instance, | 951 void DownloadManifestToBufferCompletion(PP_Instance instance, |
962 struct PP_CompletionCallback callback, | 952 struct PP_CompletionCallback callback, |
963 int32_t* out_manifest_id, | |
964 base::Time start_time, | 953 base::Time start_time, |
965 PP_NaClError pp_nacl_error, | 954 PP_NaClError pp_nacl_error, |
966 const std::string& data) { | 955 const std::string& data) { |
967 base::TimeDelta download_time = base::Time::Now() - start_time; | 956 base::TimeDelta download_time = base::Time::Now() - start_time; |
968 HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload", | 957 HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload", |
969 download_time.InMilliseconds()); | 958 download_time.InMilliseconds()); |
970 | 959 |
971 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 960 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
972 if (!load_manager) { | 961 if (!load_manager) { |
973 callback.func(callback.user_data, PP_ERROR_ABORTED); | 962 callback.func(callback.user_data, PP_ERROR_ABORTED); |
(...skipping 22 matching lines...) Expand all Loading... | |
996 break; | 985 break; |
997 default: | 986 default: |
998 NOTREACHED(); | 987 NOTREACHED(); |
999 pp_error = PP_ERROR_FAILED; | 988 pp_error = PP_ERROR_FAILED; |
1000 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_LOAD_URL, | 989 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_LOAD_URL, |
1001 "could not load manifest url."); | 990 "could not load manifest url."); |
1002 } | 991 } |
1003 | 992 |
1004 if (pp_error == PP_OK) { | 993 if (pp_error == PP_OK) { |
1005 std::string base_url = load_manager->manifest_base_url().spec(); | 994 std::string base_url = load_manager->manifest_base_url().spec(); |
1006 *out_manifest_id = CreateJsonManifest(instance, base_url, data); | 995 CreateJsonManifest(instance, base_url, data); |
1007 } | 996 } |
1008 callback.func(callback.user_data, pp_error); | 997 callback.func(callback.user_data, pp_error); |
1009 } | 998 } |
1010 | 999 |
1011 int32_t CreatePNaClManifest(PP_Instance /* instance */) { | |
1012 return GetPNaClManifestId(); | |
1013 } | |
1014 | |
1015 int32_t CreateJsonManifest(PP_Instance instance, | 1000 int32_t CreateJsonManifest(PP_Instance instance, |
dmichael (off chromium)
2014/05/29 16:10:18
You don't seem to use the return value anymore, ca
teravest
2014/05/29 16:14:02
I changed this to use bool and cleaned up the erro
| |
1016 const std::string& manifest_url, | 1001 const std::string& manifest_url, |
1017 const std::string& manifest_data) { | 1002 const std::string& manifest_data) { |
1018 HistogramSizeKB("NaCl.Perf.Size.Manifest", | 1003 HistogramSizeKB("NaCl.Perf.Size.Manifest", |
1019 static_cast<int32_t>(manifest_data.length() / 1024)); | 1004 static_cast<int32_t>(manifest_data.length() / 1024)); |
1020 | 1005 |
1021 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1006 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1022 if (!load_manager) | 1007 if (!load_manager) |
1023 return -1; | 1008 return -1; |
1024 int32_t manifest_id = g_next_manifest_id.Get(); | |
1025 g_next_manifest_id.Get()++; | |
1026 | 1009 |
1027 const char* isa_type; | 1010 const char* isa_type; |
1028 if (load_manager->IsPNaCl()) | 1011 if (load_manager->IsPNaCl()) |
1029 isa_type = kPortableArch; | 1012 isa_type = kPortableArch; |
1030 else | 1013 else |
1031 isa_type = GetSandboxArch(); | 1014 isa_type = GetSandboxArch(); |
1032 | 1015 |
1033 scoped_ptr<nacl::JsonManifest> j( | 1016 scoped_ptr<nacl::JsonManifest> j( |
1034 new nacl::JsonManifest( | 1017 new nacl::JsonManifest( |
1035 manifest_url.c_str(), | 1018 manifest_url.c_str(), |
1036 isa_type, | 1019 isa_type, |
1037 IsNonSFIModeEnabled(), | 1020 IsNonSFIModeEnabled(), |
1038 PP_ToBool(NaClDebugEnabledForURL(manifest_url.c_str())))); | 1021 PP_ToBool(NaClDebugEnabledForURL(manifest_url.c_str())))); |
1039 JsonManifest::ErrorInfo error_info; | 1022 JsonManifest::ErrorInfo error_info; |
1040 if (j->Init(manifest_data.c_str(), &error_info)) { | 1023 if (j->Init(manifest_data.c_str(), &error_info)) { |
1041 g_manifest_map.Get().add(manifest_id, j.Pass()); | 1024 g_manifest_map.Get().add(instance, j.Pass()); |
1042 return manifest_id; | 1025 return instance; |
1043 } | 1026 } |
1044 load_manager->ReportLoadError(error_info.error, error_info.string); | 1027 load_manager->ReportLoadError(error_info.error, error_info.string); |
1045 return -1; | 1028 return -1; |
1046 } | 1029 } |
1047 | 1030 |
1048 void DestroyManifest(PP_Instance /* instance */, | |
1049 int32_t manifest_id) { | |
1050 if (manifest_id == GetPNaClManifestId()) | |
1051 return; | |
1052 g_manifest_map.Get().erase(manifest_id); | |
1053 } | |
1054 | |
1055 PP_Bool ManifestGetProgramURL(PP_Instance instance, | 1031 PP_Bool ManifestGetProgramURL(PP_Instance instance, |
1056 int32_t manifest_id, | |
1057 PP_Var* pp_full_url, | 1032 PP_Var* pp_full_url, |
1058 PP_PNaClOptions* pnacl_options, | 1033 PP_PNaClOptions* pnacl_options, |
1059 PP_Bool* pp_uses_nonsfi_mode) { | 1034 PP_Bool* pp_uses_nonsfi_mode) { |
1060 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1035 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1061 if (manifest_id == GetPNaClManifestId()) { | |
1062 if (load_manager) { | |
1063 load_manager->ReportLoadError( | |
1064 PP_NACL_ERROR_MANIFEST_GET_NEXE_URL, | |
1065 "pnacl manifest does not contain a program."); | |
1066 } | |
1067 return PP_FALSE; | |
1068 } | |
1069 | 1036 |
1070 JsonManifestMap::iterator it = g_manifest_map.Get().find(manifest_id); | 1037 JsonManifestMap::iterator it = g_manifest_map.Get().find(instance); |
1071 if (it == g_manifest_map.Get().end()) | 1038 if (it == g_manifest_map.Get().end()) |
1072 return PP_FALSE; | 1039 return PP_FALSE; |
1073 | 1040 |
1074 bool uses_nonsfi_mode; | 1041 bool uses_nonsfi_mode; |
1075 std::string full_url; | 1042 std::string full_url; |
1076 JsonManifest::ErrorInfo error_info; | 1043 JsonManifest::ErrorInfo error_info; |
1077 if (it->second->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode, | 1044 if (it->second->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode, |
1078 &error_info)) { | 1045 &error_info)) { |
1079 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); | 1046 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); |
1080 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode); | 1047 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode); |
1081 return PP_TRUE; | 1048 return PP_TRUE; |
1082 } | 1049 } |
1083 | 1050 |
1084 if (load_manager) | 1051 if (load_manager) |
1085 load_manager->ReportLoadError(error_info.error, error_info.string); | 1052 load_manager->ReportLoadError(error_info.error, error_info.string); |
1086 return PP_FALSE; | 1053 return PP_FALSE; |
1087 } | 1054 } |
1088 | 1055 |
1089 PP_Bool ManifestResolveKey(PP_Instance instance, | 1056 PP_Bool ManifestResolveKey(PP_Instance instance, |
1090 int32_t manifest_id, | 1057 PP_Bool helper_process, |
dmichael (off chromium)
2014/05/29 16:10:18
nit: is_helper_process?
teravest
2014/05/29 16:14:02
Done.
| |
1091 const char* key, | 1058 const char* key, |
1092 PP_Var* pp_full_url, | 1059 PP_Var* pp_full_url, |
1093 PP_PNaClOptions* pnacl_options) { | 1060 PP_PNaClOptions* pnacl_options) { |
1094 if (manifest_id == GetPNaClManifestId()) { | 1061 // For "helper" processes (llc and ld), we resolve keys manually as there is |
1062 // no existing .nmf file to parse. | |
1063 if (PP_ToBool(helper_process)) { | |
1095 pnacl_options->translate = PP_FALSE; | 1064 pnacl_options->translate = PP_FALSE; |
1096 // We can only resolve keys in the files/ namespace. | 1065 // We can only resolve keys in the files/ namespace. |
1097 const std::string kFilesPrefix = "files/"; | 1066 const std::string kFilesPrefix = "files/"; |
1098 std::string key_string(key); | 1067 std::string key_string(key); |
1099 if (key_string.find(kFilesPrefix) == std::string::npos) { | 1068 if (key_string.find(kFilesPrefix) == std::string::npos) { |
1100 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1069 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1101 if (load_manager) | 1070 if (load_manager) |
1102 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | 1071 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
1103 "key did not start with files/"); | 1072 "key did not start with files/"); |
1104 return PP_FALSE; | 1073 return PP_FALSE; |
1105 } | 1074 } |
1106 std::string key_basename = key_string.substr(kFilesPrefix.length()); | 1075 std::string key_basename = key_string.substr(kFilesPrefix.length()); |
1107 std::string pnacl_url = | 1076 std::string pnacl_url = |
1108 std::string("chrome://pnacl-translator/") + GetSandboxArch() + "/" + | 1077 std::string("chrome://pnacl-translator/") + GetSandboxArch() + "/" + |
1109 key_basename; | 1078 key_basename; |
1110 *pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url); | 1079 *pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url); |
1111 return PP_TRUE; | 1080 return PP_TRUE; |
1112 } | 1081 } |
1113 | 1082 |
1114 JsonManifestMap::iterator it = g_manifest_map.Get().find(manifest_id); | 1083 JsonManifestMap::iterator it = g_manifest_map.Get().find(instance); |
1115 if (it == g_manifest_map.Get().end()) | 1084 if (it == g_manifest_map.Get().end()) |
1116 return PP_FALSE; | 1085 return PP_FALSE; |
1117 | 1086 |
1118 std::string full_url; | 1087 std::string full_url; |
1119 bool ok = it->second->ResolveKey(key, &full_url, pnacl_options); | 1088 bool ok = it->second->ResolveKey(key, &full_url, pnacl_options); |
1120 if (ok) | 1089 if (ok) |
1121 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); | 1090 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); |
1122 return PP_FromBool(ok); | 1091 return PP_FromBool(ok); |
1123 } | 1092 } |
1124 | 1093 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1535 &GetExitStatus, | 1504 &GetExitStatus, |
1536 &SetExitStatus, | 1505 &SetExitStatus, |
1537 &Vlog, | 1506 &Vlog, |
1538 &InitializePlugin, | 1507 &InitializePlugin, |
1539 &GetNexeSize, | 1508 &GetNexeSize, |
1540 &RequestNaClManifest, | 1509 &RequestNaClManifest, |
1541 &GetManifestBaseURL, | 1510 &GetManifestBaseURL, |
1542 &ProcessNaClManifest, | 1511 &ProcessNaClManifest, |
1543 &GetManifestURLArgument, | 1512 &GetManifestURLArgument, |
1544 &DevInterfacesEnabled, | 1513 &DevInterfacesEnabled, |
1545 &CreatePNaClManifest, | |
1546 &DestroyManifest, | |
1547 &ManifestGetProgramURL, | 1514 &ManifestGetProgramURL, |
1548 &ManifestResolveKey, | 1515 &ManifestResolveKey, |
1549 &GetPNaClResourceInfo, | 1516 &GetPNaClResourceInfo, |
1550 &GetCpuFeatureAttrs, | 1517 &GetCpuFeatureAttrs, |
1551 &PostMessageToJavaScript, | 1518 &PostMessageToJavaScript, |
1552 &DownloadNexe, | 1519 &DownloadNexe, |
1553 &DownloadFile | 1520 &DownloadFile |
1554 }; | 1521 }; |
1555 | 1522 |
1556 } // namespace | 1523 } // namespace |
1557 | 1524 |
1558 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1525 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1559 return &nacl_interface; | 1526 return &nacl_interface; |
1560 } | 1527 } |
1561 | 1528 |
1562 } // namespace nacl | 1529 } // namespace nacl |
OLD | NEW |