Commit 7dd7f650 authored by yusukes's avatar yusukes Committed by Commit bot

Stop adding the "files/" prefix when sending open_resource IPC

This is for simplifying https://codereview.chromium.org/1010183002/

This also removes 'if (key == kProgramKey) ...' check from
JsonManifest::ResolveKey. This is safe because kProgram key was
never passed to the function before the change.

BUG=nativeclient:3802
TEST=git cl try, manually checked that both ARC and PNaCl demo still work

Review URL: https://codereview.chromium.org/1070233007

Cr-Commit-Position: refs/heads/master@{#325547}
parent 09e87de8
......@@ -463,38 +463,20 @@ void JsonManifest::GetPrefetchableFiles(
bool JsonManifest::ResolveKey(const std::string& key,
std::string* full_url,
PP_PNaClOptions* pnacl_options) const {
// key must be one of kProgramKey or kFileKey '/' file-section-key
if (full_url == NULL || pnacl_options == NULL)
return false;
if (key == kProgramKey)
return GetKeyUrl(dictionary_, key, full_url, pnacl_options);
std::string::const_iterator p = std::find(key.begin(), key.end(), '/');
if (p == key.end()) {
VLOG(1) << "ResolveKey failed: invalid key, no slash: " << key;
return false;
}
// generalize to permit other sections?
std::string prefix(key.begin(), p);
if (prefix != kFilesKey) {
VLOG(1) << "ResolveKey failed: invalid key, no \"files\" prefix: " << key;
return false;
}
const Json::Value& files = dictionary_[kFilesKey];
if (!files.isObject()) {
VLOG(1) << "ResolveKey failed: no \"files\" dictionary";
return false;
}
std::string rest(p + 1, key.end());
if (!files.isMember(rest)) {
if (!files.isMember(key)) {
VLOG(1) << "ResolveKey failed: no such \"files\" entry: " << key;
return false;
}
return GetKeyUrl(files, rest, full_url, pnacl_options);
return GetKeyUrl(files, key, full_url, pnacl_options);
}
bool JsonManifest::MatchesSchema(ErrorInfo* error_info) {
......
......@@ -1107,18 +1107,8 @@ bool ManifestResolveKey(PP_Instance instance,
// keys manually as there is no existing .nmf file to parse.
if (is_helper_process) {
pnacl_options->translate = PP_FALSE;
// We can only resolve keys in the files/ namespace.
const std::string kFilesPrefix = "files/";
if (key.find(kFilesPrefix) == std::string::npos) {
nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
if (load_manager)
load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
"key did not start with files/");
return false;
}
std::string key_basename = key.substr(kFilesPrefix.length());
*full_url = std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" +
key_basename;
key;
return true;
}
......
......@@ -21,8 +21,6 @@
namespace ppapi {
const char kFilePrefix[] = "files/";
// IPC channel is asynchronously set up. So, the NaCl process may try to
// send a OpenResource message to the host before the connection is
// established. In such a case, it is necessary to wait for the set up
......@@ -101,7 +99,7 @@ bool ManifestService::OpenResource(const char* file, int* fd) {
uint64_t file_token_lo = 0;
uint64_t file_token_hi = 0;
if (!filter_->Send(new PpapiHostMsg_OpenResource(
std::string(kFilePrefix) + file,
file,
&ipc_fd,
&file_token_lo,
&file_token_hi))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment