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

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

Issue 329593002: Pepper: Make ManifestResolveKey resuable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/nacl/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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); 1036 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
1037 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode); 1037 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode);
1038 return PP_TRUE; 1038 return PP_TRUE;
1039 } 1039 }
1040 1040
1041 if (load_manager) 1041 if (load_manager)
1042 load_manager->ReportLoadError(error_info.error, error_info.string); 1042 load_manager->ReportLoadError(error_info.error, error_info.string);
1043 return PP_FALSE; 1043 return PP_FALSE;
1044 } 1044 }
1045 1045
1046 PP_Bool ManifestResolveKey(PP_Instance instance, 1046 bool ManifestResolveKey(PP_Instance instance,
1047 PP_Bool is_helper_process, 1047 bool is_helper_process,
1048 const char* key, 1048 const std::string& key,
1049 PP_Var* pp_full_url, 1049 std::string* full_url,
1050 PP_PNaClOptions* pnacl_options) { 1050 PP_PNaClOptions* pnacl_options) {
1051 // For "helper" processes (llc and ld), we resolve keys manually as there is 1051 // For "helper" processes (llc and ld), we resolve keys manually as there is
1052 // no existing .nmf file to parse. 1052 // no existing .nmf file to parse.
1053 if (PP_ToBool(is_helper_process)) { 1053 if (is_helper_process) {
1054 pnacl_options->translate = PP_FALSE; 1054 pnacl_options->translate = PP_FALSE;
1055 // We can only resolve keys in the files/ namespace. 1055 // We can only resolve keys in the files/ namespace.
1056 const std::string kFilesPrefix = "files/"; 1056 const std::string kFilesPrefix = "files/";
1057 std::string key_string(key); 1057 if (key.find(kFilesPrefix) == std::string::npos) {
1058 if (key_string.find(kFilesPrefix) == std::string::npos) {
1059 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1058 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1060 if (load_manager) 1059 if (load_manager)
1061 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, 1060 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
1062 "key did not start with files/"); 1061 "key did not start with files/");
1063 return PP_FALSE; 1062 return false;
1064 } 1063 }
1065 std::string key_basename = key_string.substr(kFilesPrefix.length()); 1064 std::string key_basename = key.substr(kFilesPrefix.length());
1066 std::string pnacl_url = 1065 *full_url = std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" +
1067 std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" + 1066 key_basename;
1068 key_basename; 1067 return true;
1069 *pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url);
1070 return PP_TRUE;
1071 } 1068 }
1072 1069
1073 JsonManifest* manifest = GetJsonManifest(instance); 1070 JsonManifest* manifest = GetJsonManifest(instance);
1074 if (manifest == NULL) 1071 if (manifest == NULL)
1075 return PP_FALSE; 1072 return false;
1076 1073
1074 return manifest->ResolveKey(key, full_url, pnacl_options);
1075 }
1076
1077 PP_Bool ExternalManifestResolveKey(PP_Instance instance,
1078 PP_Bool is_helper_process,
1079 const char* key,
1080 PP_Var* pp_full_url,
1081 PP_PNaClOptions* pnacl_options) {
1077 std::string full_url; 1082 std::string full_url;
1078 bool ok = manifest->ResolveKey(key, &full_url, pnacl_options); 1083 bool ok = ManifestResolveKey(instance,
1084 PP_ToBool(is_helper_process),
1085 std::string(key),
1086 &full_url,
1087 pnacl_options);
1079 if (ok) 1088 if (ok)
1080 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); 1089 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
1081 return PP_FromBool(ok); 1090 return PP_FromBool(ok);
1082 } 1091 }
1083 1092
1084 PP_Bool GetPNaClResourceInfo(PP_Instance instance, 1093 PP_Bool GetPNaClResourceInfo(PP_Instance instance,
1085 const char* filename, 1094 const char* filename,
1086 PP_Var* llc_tool_name, 1095 PP_Var* llc_tool_name,
1087 PP_Var* ld_tool_name) { 1096 PP_Var* ld_tool_name) {
1088 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1097 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 &GetExitStatus, 1544 &GetExitStatus,
1536 &SetExitStatus, 1545 &SetExitStatus,
1537 &Vlog, 1546 &Vlog,
1538 &InitializePlugin, 1547 &InitializePlugin,
1539 &GetNexeSize, 1548 &GetNexeSize,
1540 &RequestNaClManifest, 1549 &RequestNaClManifest,
1541 &GetManifestBaseURL, 1550 &GetManifestBaseURL,
1542 &ProcessNaClManifest, 1551 &ProcessNaClManifest,
1543 &DevInterfacesEnabled, 1552 &DevInterfacesEnabled,
1544 &ManifestGetProgramURL, 1553 &ManifestGetProgramURL,
1545 &ManifestResolveKey, 1554 &ExternalManifestResolveKey,
1546 &GetPNaClResourceInfo, 1555 &GetPNaClResourceInfo,
1547 &GetCpuFeatureAttrs, 1556 &GetCpuFeatureAttrs,
1548 &PostMessageToJavaScript, 1557 &PostMessageToJavaScript,
1549 &DownloadNexe, 1558 &DownloadNexe,
1550 &DownloadFile, 1559 &DownloadFile,
1551 &ReportSelLdrStatus 1560 &ReportSelLdrStatus
1552 }; 1561 };
1553 1562
1554 } // namespace 1563 } // namespace
1555 1564
1556 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1565 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1557 return &nacl_interface; 1566 return &nacl_interface;
1558 } 1567 }
1559 1568
1560 } // namespace nacl 1569 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698