summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-03 19:14:48 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-03 19:14:48 +0000
commitcd3f8a6dfb50d917d62ba6f78f694bc586d40831 (patch)
tree56333680e9feb515c7b34c8ff2c9ab27dc26593d /components
parenta1493a66d15a825bbce1f6c9cf587bd16ef7e2eb (diff)
downloadchromium_src-cd3f8a6dfb50d917d62ba6f78f694bc586d40831.zip
chromium_src-cd3f8a6dfb50d917d62ba6f78f694bc586d40831.tar.gz
chromium_src-cd3f8a6dfb50d917d62ba6f78f694bc586d40831.tar.bz2
Revert of Pepper: Refactor OpenManifestEntry. (https://codereview.chromium.org/302093012/)
Reason for revert: This broke NaClBrowserTestPnaclNonSfi.IrtManifestFile on linux 32. That test will have to pass on the right trybot before landing. I'm not sure why it broke yet. Original issue's description: > Pepper: Refactor OpenManifestEntry. > > This change pulls out more OpenManifestEntry code from service_runtime, making > PPB_NaCl_Private a smallter interface, and preparing for pulling all of that > logic out of the trusted plugin. > > BUG=239656 > R=dmichael@chromium.org > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=274530 TBR=dmichael@chromium.org NOTREECHECKS=true NOTRY=true BUG=239656 Review URL: https://codereview.chromium.org/318463002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/nacl/renderer/ppb_nacl_private_impl.cc75
1 files changed, 27 insertions, 48 deletions
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 0aca3a1..f3e8855 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -1080,23 +1080,15 @@ PP_Bool ManifestGetProgramURL(PP_Instance instance,
return PP_FALSE;
}
-// TODO(teravest): Refactor DownloadFile/DownloadNexe out to their own file;
-// this one is getting way too messy.
-void DownloadFile(PP_Instance instance,
- const std::string& url,
- struct PP_NaClFileInfo* file_info,
- struct PP_CompletionCallback callback);
-
-void OpenManifestEntry(PP_Instance instance,
- PP_Bool is_helper_process,
- const char* key,
- PP_NaClFileInfo* out_file_info,
- PP_CompletionCallback callback) {
- std::string resolved_url;
-
+PP_Bool ManifestResolveKey(PP_Instance instance,
+ PP_Bool is_helper_process,
+ const char* key,
+ PP_Var* pp_full_url,
+ PP_PNaClOptions* pnacl_options) {
// For "helper" processes (llc and ld), we resolve keys manually as there is
// no existing .nmf file to parse.
if (PP_ToBool(is_helper_process)) {
+ pnacl_options->translate = PP_FALSE;
// We can only resolve keys in the files/ namespace.
const std::string kFilesPrefix = "files/";
std::string key_string(key);
@@ -1105,41 +1097,25 @@ void OpenManifestEntry(PP_Instance instance,
if (load_manager)
load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
"key did not start with files/");
- ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
- FROM_HERE,
- base::Bind(callback.func, callback.user_data,
- static_cast<int32_t>(PP_ERROR_FAILED)));
- return;
+ return PP_FALSE;
}
std::string key_basename = key_string.substr(kFilesPrefix.length());
- resolved_url =
+ std::string pnacl_url =
std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" +
key_basename;
- } else {
- JsonManifestMap::iterator it = g_manifest_map.Get().find(instance);
- if (it == g_manifest_map.Get().end()) {
- ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
- FROM_HERE,
- base::Bind(callback.func, callback.user_data,
- static_cast<int32_t>(PP_ERROR_FAILED)));
- return;
- }
-
- PP_PNaClOptions pnacl_options;
- bool ok = it->second->ResolveKey(key, &resolved_url, &pnacl_options);
- // We don't support OpenManifestEntry for files that require PNaCl
- // translation.
- if (!ok || pnacl_options.translate) {
- ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
- FROM_HERE,
- base::Bind(callback.func, callback.user_data,
- static_cast<int32_t>(PP_ERROR_FAILED)));
- return;
- }
+ *pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url);
+ return PP_TRUE;
}
- // Hand off to DownloadFile to perform fetching the actual file.
- DownloadFile(instance, resolved_url, out_file_info, callback);
+ JsonManifestMap::iterator it = g_manifest_map.Get().find(instance);
+ if (it == g_manifest_map.Get().end())
+ return PP_FALSE;
+
+ std::string full_url;
+ bool ok = it->second->ResolveKey(key, &full_url, pnacl_options);
+ if (ok)
+ *pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
+ return PP_FromBool(ok);
}
PP_Bool GetPNaClResourceInfo(PP_Instance instance,
@@ -1452,9 +1428,10 @@ void DownloadFileCompletion(base::PlatformFile file,
}
void DownloadFile(PP_Instance instance,
- const std::string& url,
+ const char* url,
struct PP_NaClFileInfo* file_info,
struct PP_CompletionCallback callback) {
+ CHECK(url);
CHECK(file_info);
NexeLoadManager* load_manager = GetNexeLoadManager(instance);
@@ -1469,8 +1446,9 @@ void DownloadFile(PP_Instance instance,
// Handle special PNaCl support files which are installed on the user's
// machine.
- if (url.find(kPNaClTranslatorBaseUrl, 0) == 0) {
- PP_FileHandle handle = GetReadonlyPnaclFd(url.c_str());
+ std::string url_string(url);
+ if (url_string.find(kPNaClTranslatorBaseUrl, 0) == 0) {
+ PP_FileHandle handle = GetReadonlyPnaclFd(url);
if (handle == PP_kInvalidFileHandle) {
ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
FROM_HERE,
@@ -1505,7 +1483,7 @@ void DownloadFile(PP_Instance instance,
uint64_t file_token_lo = 0;
uint64_t file_token_hi = 0;
PP_FileHandle file_handle = OpenNaClExecutable(instance,
- url.c_str(),
+ url,
&file_token_lo,
&file_token_hi);
if (file_handle != PP_kInvalidFileHandle) {
@@ -1585,11 +1563,12 @@ const PPB_NaCl_Private nacl_interface = {
&GetManifestURLArgument,
&DevInterfacesEnabled,
&ManifestGetProgramURL,
- &OpenManifestEntry,
+ &ManifestResolveKey,
&GetPNaClResourceInfo,
&GetCpuFeatureAttrs,
&PostMessageToJavaScript,
&DownloadNexe,
+ &DownloadFile
};
} // namespace