Skip to content

Commit

Permalink
Stop adding the "files/" prefix when sending open_resource IPC
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
yusukes authored and Commit bot committed Apr 16, 2015
1 parent 09e87de commit 7dd7f65
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
22 changes: 2 additions & 20 deletions components/nacl/renderer/json_manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 1 addition & 11 deletions components/nacl/renderer/ppb_nacl_private_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions ppapi/nacl_irt/manifest_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand 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))) {
Expand Down

0 comments on commit 7dd7f65

Please sign in to comment.