| Index: components/nacl/renderer/ppb_nacl_private_impl.cc
|
| diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| index 0aca3a17193a449bb57c8c38b917630f34b5a9f1..f3e8855989c90a91c1c693ad22d9238a6b7186b7 100644
|
| --- a/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| @@ -1080,23 +1080,15 @@
|
| 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 @@
|
| 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;
|
| - }
|
| - }
|
| -
|
| - // Hand off to DownloadFile to perform fetching the actual file.
|
| - DownloadFile(instance, resolved_url, out_file_info, callback);
|
| + *pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url);
|
| + return PP_TRUE;
|
| + }
|
| +
|
| + 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 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 @@
|
|
|
| // 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 @@
|
| 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 @@
|
| &GetManifestURLArgument,
|
| &DevInterfacesEnabled,
|
| &ManifestGetProgramURL,
|
| - &OpenManifestEntry,
|
| + &ManifestResolveKey,
|
| &GetPNaClResourceInfo,
|
| &GetCpuFeatureAttrs,
|
| &PostMessageToJavaScript,
|
| &DownloadNexe,
|
| + &DownloadFile
|
| };
|
|
|
| } // namespace
|
|
|