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

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 301013002: Pepper: Manifest ID cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix type signature Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/api/private/ppb_nacl_private.idl » ('j') | 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/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
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
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
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 bool 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 if (CreateJsonManifest(instance, base_url.spec(), data))
874 *out_manifest_id = CreateJsonManifest(instance, base_url.spec(), data); 866 error = PP_OK;
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
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
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 if (!CreateJsonManifest(instance, base_url, data))
996 pp_error = PP_ERROR_FAILED;
1007 } 997 }
1008 callback.func(callback.user_data, pp_error); 998 callback.func(callback.user_data, pp_error);
1009 } 999 }
1010 1000
1011 int32_t CreatePNaClManifest(PP_Instance /* instance */) { 1001 bool CreateJsonManifest(PP_Instance instance,
1012 return GetPNaClManifestId(); 1002 const std::string& manifest_url,
1013 } 1003 const std::string& manifest_data) {
1014
1015 int32_t CreateJsonManifest(PP_Instance instance,
1016 const std::string& manifest_url,
1017 const std::string& manifest_data) {
1018 HistogramSizeKB("NaCl.Perf.Size.Manifest", 1004 HistogramSizeKB("NaCl.Perf.Size.Manifest",
1019 static_cast<int32_t>(manifest_data.length() / 1024)); 1005 static_cast<int32_t>(manifest_data.length() / 1024));
1020 1006
1021 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1007 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1022 if (!load_manager) 1008 if (!load_manager)
1023 return -1; 1009 return false;
1024 int32_t manifest_id = g_next_manifest_id.Get();
1025 g_next_manifest_id.Get()++;
1026 1010
1027 const char* isa_type; 1011 const char* isa_type;
1028 if (load_manager->IsPNaCl()) 1012 if (load_manager->IsPNaCl())
1029 isa_type = kPortableArch; 1013 isa_type = kPortableArch;
1030 else 1014 else
1031 isa_type = GetSandboxArch(); 1015 isa_type = GetSandboxArch();
1032 1016
1033 scoped_ptr<nacl::JsonManifest> j( 1017 scoped_ptr<nacl::JsonManifest> j(
1034 new nacl::JsonManifest( 1018 new nacl::JsonManifest(
1035 manifest_url.c_str(), 1019 manifest_url.c_str(),
1036 isa_type, 1020 isa_type,
1037 IsNonSFIModeEnabled(), 1021 IsNonSFIModeEnabled(),
1038 PP_ToBool(NaClDebugEnabledForURL(manifest_url.c_str())))); 1022 PP_ToBool(NaClDebugEnabledForURL(manifest_url.c_str()))));
1039 JsonManifest::ErrorInfo error_info; 1023 JsonManifest::ErrorInfo error_info;
1040 if (j->Init(manifest_data.c_str(), &error_info)) { 1024 if (j->Init(manifest_data.c_str(), &error_info)) {
1041 g_manifest_map.Get().add(manifest_id, j.Pass()); 1025 g_manifest_map.Get().add(instance, j.Pass());
1042 return manifest_id; 1026 return true;
1043 } 1027 }
1044 load_manager->ReportLoadError(error_info.error, error_info.string); 1028 load_manager->ReportLoadError(error_info.error, error_info.string);
1045 return -1; 1029 return false;
1046 }
1047
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 } 1030 }
1054 1031
1055 PP_Bool ManifestGetProgramURL(PP_Instance instance, 1032 PP_Bool ManifestGetProgramURL(PP_Instance instance,
1056 int32_t manifest_id,
1057 PP_Var* pp_full_url, 1033 PP_Var* pp_full_url,
1058 PP_PNaClOptions* pnacl_options, 1034 PP_PNaClOptions* pnacl_options,
1059 PP_Bool* pp_uses_nonsfi_mode) { 1035 PP_Bool* pp_uses_nonsfi_mode) {
1060 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1036 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 1037
1070 JsonManifestMap::iterator it = g_manifest_map.Get().find(manifest_id); 1038 JsonManifestMap::iterator it = g_manifest_map.Get().find(instance);
1071 if (it == g_manifest_map.Get().end()) 1039 if (it == g_manifest_map.Get().end())
1072 return PP_FALSE; 1040 return PP_FALSE;
1073 1041
1074 bool uses_nonsfi_mode; 1042 bool uses_nonsfi_mode;
1075 std::string full_url; 1043 std::string full_url;
1076 JsonManifest::ErrorInfo error_info; 1044 JsonManifest::ErrorInfo error_info;
1077 if (it->second->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode, 1045 if (it->second->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode,
1078 &error_info)) { 1046 &error_info)) {
1079 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); 1047 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
1080 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode); 1048 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode);
1081 return PP_TRUE; 1049 return PP_TRUE;
1082 } 1050 }
1083 1051
1084 if (load_manager) 1052 if (load_manager)
1085 load_manager->ReportLoadError(error_info.error, error_info.string); 1053 load_manager->ReportLoadError(error_info.error, error_info.string);
1086 return PP_FALSE; 1054 return PP_FALSE;
1087 } 1055 }
1088 1056
1089 PP_Bool ManifestResolveKey(PP_Instance instance, 1057 PP_Bool ManifestResolveKey(PP_Instance instance,
1090 int32_t manifest_id, 1058 PP_Bool is_helper_process,
1091 const char* key, 1059 const char* key,
1092 PP_Var* pp_full_url, 1060 PP_Var* pp_full_url,
1093 PP_PNaClOptions* pnacl_options) { 1061 PP_PNaClOptions* pnacl_options) {
1094 if (manifest_id == GetPNaClManifestId()) { 1062 // For "helper" processes (llc and ld), we resolve keys manually as there is
1063 // no existing .nmf file to parse.
1064 if (PP_ToBool(is_helper_process)) {
1095 pnacl_options->translate = PP_FALSE; 1065 pnacl_options->translate = PP_FALSE;
1096 // We can only resolve keys in the files/ namespace. 1066 // We can only resolve keys in the files/ namespace.
1097 const std::string kFilesPrefix = "files/"; 1067 const std::string kFilesPrefix = "files/";
1098 std::string key_string(key); 1068 std::string key_string(key);
1099 if (key_string.find(kFilesPrefix) == std::string::npos) { 1069 if (key_string.find(kFilesPrefix) == std::string::npos) {
1100 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1070 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1101 if (load_manager) 1071 if (load_manager)
1102 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, 1072 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
1103 "key did not start with files/"); 1073 "key did not start with files/");
1104 return PP_FALSE; 1074 return PP_FALSE;
1105 } 1075 }
1106 std::string key_basename = key_string.substr(kFilesPrefix.length()); 1076 std::string key_basename = key_string.substr(kFilesPrefix.length());
1107 std::string pnacl_url = 1077 std::string pnacl_url =
1108 std::string("chrome://pnacl-translator/") + GetSandboxArch() + "/" + 1078 std::string("chrome://pnacl-translator/") + GetSandboxArch() + "/" +
1109 key_basename; 1079 key_basename;
1110 *pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url); 1080 *pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url);
1111 return PP_TRUE; 1081 return PP_TRUE;
1112 } 1082 }
1113 1083
1114 JsonManifestMap::iterator it = g_manifest_map.Get().find(manifest_id); 1084 JsonManifestMap::iterator it = g_manifest_map.Get().find(instance);
1115 if (it == g_manifest_map.Get().end()) 1085 if (it == g_manifest_map.Get().end())
1116 return PP_FALSE; 1086 return PP_FALSE;
1117 1087
1118 std::string full_url; 1088 std::string full_url;
1119 bool ok = it->second->ResolveKey(key, &full_url, pnacl_options); 1089 bool ok = it->second->ResolveKey(key, &full_url, pnacl_options);
1120 if (ok) 1090 if (ok)
1121 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); 1091 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
1122 return PP_FromBool(ok); 1092 return PP_FromBool(ok);
1123 } 1093 }
1124 1094
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 &GetExitStatus, 1505 &GetExitStatus,
1536 &SetExitStatus, 1506 &SetExitStatus,
1537 &Vlog, 1507 &Vlog,
1538 &InitializePlugin, 1508 &InitializePlugin,
1539 &GetNexeSize, 1509 &GetNexeSize,
1540 &RequestNaClManifest, 1510 &RequestNaClManifest,
1541 &GetManifestBaseURL, 1511 &GetManifestBaseURL,
1542 &ProcessNaClManifest, 1512 &ProcessNaClManifest,
1543 &GetManifestURLArgument, 1513 &GetManifestURLArgument,
1544 &DevInterfacesEnabled, 1514 &DevInterfacesEnabled,
1545 &CreatePNaClManifest,
1546 &DestroyManifest,
1547 &ManifestGetProgramURL, 1515 &ManifestGetProgramURL,
1548 &ManifestResolveKey, 1516 &ManifestResolveKey,
1549 &GetPNaClResourceInfo, 1517 &GetPNaClResourceInfo,
1550 &GetCpuFeatureAttrs, 1518 &GetCpuFeatureAttrs,
1551 &PostMessageToJavaScript, 1519 &PostMessageToJavaScript,
1552 &DownloadNexe, 1520 &DownloadNexe,
1553 &DownloadFile 1521 &DownloadFile
1554 }; 1522 };
1555 1523
1556 } // namespace 1524 } // namespace
1557 1525
1558 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1526 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1559 return &nacl_interface; 1527 return &nacl_interface;
1560 } 1528 }
1561 1529
1562 } // namespace nacl 1530 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | ppapi/api/private/ppb_nacl_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698