Commit f9594d64 authored by teravest@chromium.org's avatar teravest@chromium.org

Pepper: Remove Manifest::ResolveURL

This need not be exposed as part of the Manifest interface.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263045 0039d316-1c4b-4281-b951-d872f2087c98
parent 68059696
...@@ -580,26 +580,6 @@ bool JsonManifest::GetKeyUrl(const Json::Value& dictionary, ...@@ -580,26 +580,6 @@ bool JsonManifest::GetKeyUrl(const Json::Value& dictionary,
return ResolveURL(relative_url, full_url, error_info); return ResolveURL(relative_url, full_url, error_info);
} }
bool JsonManifest::ResolveURL(const nacl::string& relative_url,
nacl::string* full_url,
ErrorInfo* error_info) const {
// The contents of the manifest are resolved relative to the manifest URL.
CHECK(url_util_ != NULL);
pp::Var resolved_url =
url_util_->ResolveRelativeToURL(pp::Var(manifest_base_url_),
relative_url);
if (!resolved_url.is_string()) {
error_info->SetReport(
PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
"could not resolve url '" + relative_url +
"' relative to manifest base url '" + manifest_base_url_.c_str() +
"'.");
return false;
}
*full_url = resolved_url.AsString();
return true;
}
bool JsonManifest::GetProgramURL(nacl::string* full_url, bool JsonManifest::GetProgramURL(nacl::string* full_url,
PnaclOptions* pnacl_options, PnaclOptions* pnacl_options,
bool* uses_nonsfi_mode, bool* uses_nonsfi_mode,
...@@ -686,4 +666,24 @@ bool JsonManifest::ResolveKey(const nacl::string& key, ...@@ -686,4 +666,24 @@ bool JsonManifest::ResolveKey(const nacl::string& key,
return GetKeyUrl(files, rest, full_url, pnacl_options, error_info); return GetKeyUrl(files, rest, full_url, pnacl_options, error_info);
} }
bool JsonManifest::ResolveURL(const nacl::string& relative_url,
nacl::string* full_url,
ErrorInfo* error_info) const {
// The contents of the manifest are resolved relative to the manifest URL.
CHECK(url_util_ != NULL);
pp::Var resolved_url =
url_util_->ResolveRelativeToURL(pp::Var(manifest_base_url_),
relative_url);
if (!resolved_url.is_string()) {
error_info->SetReport(
PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
"could not resolve url '" + relative_url +
"' relative to manifest base url '" + manifest_base_url_.c_str() +
"'.");
return false;
}
*full_url = resolved_url.AsString();
return true;
}
} // namespace plugin } // namespace plugin
...@@ -53,11 +53,6 @@ class JsonManifest : public Manifest { ...@@ -53,11 +53,6 @@ class JsonManifest : public Manifest {
bool* uses_nonsfi_mode, bool* uses_nonsfi_mode,
ErrorInfo* error_info) const; ErrorInfo* error_info) const;
// Resolves a URL relative to the manifest base URL
virtual bool ResolveURL(const nacl::string& relative_url,
nacl::string* full_url,
ErrorInfo* error_info) const;
// Gets the file names from the "files" section of the manifest. No // Gets the file names from the "files" section of the manifest. No
// checking that the keys' values are proper ISA dictionaries -- it // checking that the keys' values are proper ISA dictionaries -- it
// is assumed that other consistency checks take care of that, and // is assumed that other consistency checks take care of that, and
...@@ -76,6 +71,11 @@ class JsonManifest : public Manifest { ...@@ -76,6 +71,11 @@ class JsonManifest : public Manifest {
private: private:
NACL_DISALLOW_COPY_AND_ASSIGN(JsonManifest); NACL_DISALLOW_COPY_AND_ASSIGN(JsonManifest);
// Resolves a URL relative to the manifest base URL
bool ResolveURL(const nacl::string& relative_url,
nacl::string* full_url,
ErrorInfo* error_info) const;
// Checks that |dictionary_| is a valid manifest, according to the schema. // Checks that |dictionary_| is a valid manifest, according to the schema.
// Returns true on success, and sets |error_info| to a detailed message // Returns true on success, and sets |error_info| to a detailed message
// if not. // if not.
......
...@@ -46,11 +46,6 @@ class Manifest { ...@@ -46,11 +46,6 @@ class Manifest {
bool* uses_nonsfi_mode, bool* uses_nonsfi_mode,
ErrorInfo* error_info) const = 0; ErrorInfo* error_info) const = 0;
// Resolves a URL relative to the manifest base URL
virtual bool ResolveURL(const nacl::string& relative_url,
nacl::string* full_url,
ErrorInfo* error_info) const = 0;
// Gets the file names from the "files" section of the manifest. No // Gets the file names from the "files" section of the manifest. No
// checking that the keys' values are proper ISA dictionaries -- it // checking that the keys' values are proper ISA dictionaries -- it
// is assumed that other consistency checks take care of that, and // is assumed that other consistency checks take care of that, and
...@@ -59,7 +54,7 @@ class Manifest { ...@@ -59,7 +54,7 @@ class Manifest {
// Resolves a key from the "files" section to a fully resolved URL, // Resolves a key from the "files" section to a fully resolved URL,
// i.e., relative URL values are fully expanded relative to the // i.e., relative URL values are fully expanded relative to the
// manifest's URL (via ResolveURL). Fills in |pnacl_options| if // manifest's URL. Fills in |pnacl_options| if
// the resolved key requires a pnacl translation step to obtain // the resolved key requires a pnacl translation step to obtain
// the final requested resource. // the final requested resource.
// If there was an error, details are reported via error_info. // If there was an error, details are reported via error_info.
......
...@@ -38,8 +38,7 @@ namespace plugin { ...@@ -38,8 +38,7 @@ namespace plugin {
class PnaclManifest : public Manifest { class PnaclManifest : public Manifest {
public: public:
PnaclManifest(const nacl::string& sandbox_arch) PnaclManifest(const nacl::string& sandbox_arch)
: manifest_base_url_(PnaclUrls::GetBaseUrl()), : sandbox_arch_(sandbox_arch) { }
sandbox_arch_(sandbox_arch) { }
virtual ~PnaclManifest() { } virtual ~PnaclManifest() { }
...@@ -58,16 +57,6 @@ class PnaclManifest : public Manifest { ...@@ -58,16 +57,6 @@ class PnaclManifest : public Manifest {
return false; return false;
} }
virtual bool ResolveURL(const nacl::string& relative_url,
nacl::string* full_url,
ErrorInfo* error_info) const {
// Does not do general URL resolution, simply appends relative_url to
// the end of manifest_base_url_.
UNREFERENCED_PARAMETER(error_info);
*full_url = manifest_base_url_ + relative_url;
return true;
}
virtual bool GetFileKeys(std::set<nacl::string>* keys) const { virtual bool GetFileKeys(std::set<nacl::string>* keys) const {
// Does not support enumeration. // Does not support enumeration.
PLUGIN_PRINTF(("PnaclManifest does not support key enumeration\n")); PLUGIN_PRINTF(("PnaclManifest does not support key enumeration\n"));
...@@ -92,14 +81,13 @@ class PnaclManifest : public Manifest { ...@@ -92,14 +81,13 @@ class PnaclManifest : public Manifest {
// Resolve the full URL to the file. Provide it with a platform-specific // Resolve the full URL to the file. Provide it with a platform-specific
// prefix. // prefix.
nacl::string key_basename = key.substr(kFilesPrefix.length()); nacl::string key_basename = key.substr(kFilesPrefix.length());
return ResolveURL(sandbox_arch_ + "/" + key_basename, *full_url = PnaclUrls::GetBaseUrl() + sandbox_arch_ + "/" + key_basename;
full_url, error_info); return true;
} }
private: private:
NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest); NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest);
nacl::string manifest_base_url_;
nacl::string sandbox_arch_; nacl::string sandbox_arch_;
}; };
...@@ -451,7 +439,7 @@ void PnaclCoordinator::BitcodeStreamDidOpen(int32_t pp_error) { ...@@ -451,7 +439,7 @@ void PnaclCoordinator::BitcodeStreamDidOpen(int32_t pp_error) {
// The component updater's resource throttles + OnDemand update/install // The component updater's resource throttles + OnDemand update/install
// should block the URL request until the compiler is present. Now we // should block the URL request until the compiler is present. Now we
// can load the resources (e.g. llc and ld nexes). // can load the resources (e.g. llc and ld nexes).
resources_.reset(new PnaclResources(plugin_, this, this->manifest_.get())); resources_.reset(new PnaclResources(plugin_, this));
CHECK(resources_ != NULL); CHECK(resources_ != NULL);
// The first step of loading resources: read the resource info file. // The first step of loading resources: read the resource info file.
......
...@@ -96,14 +96,7 @@ void PnaclResources::ReadResourceInfo( ...@@ -96,14 +96,7 @@ void PnaclResources::ReadResourceInfo(
const pp::CompletionCallback& resource_info_read_cb) { const pp::CompletionCallback& resource_info_read_cb) {
PLUGIN_PRINTF(("PnaclResources::ReadResourceInfo\n")); PLUGIN_PRINTF(("PnaclResources::ReadResourceInfo\n"));
nacl::string full_url; nacl::string full_url = PnaclUrls::GetBaseUrl() + resource_info_url;
ErrorInfo error_info;
if (!manifest_->ResolveURL(resource_info_url, &full_url, &error_info)) {
ReadResourceInfoError(nacl::string("failed to resolve ") +
resource_info_url + ": " +
error_info.message() + ".");
return;
}
PLUGIN_PRINTF(("Resolved resources info url: %s\n", full_url.c_str())); PLUGIN_PRINTF(("Resolved resources info url: %s\n", full_url.c_str()));
nacl::string resource_info_filename = nacl::string resource_info_filename =
PnaclUrls::PnaclComponentURLToFilename(full_url); PnaclUrls::PnaclComponentURLToFilename(full_url);
...@@ -186,17 +179,9 @@ bool PnaclResources::ParseResourceInfo(const nacl::string& buf, ...@@ -186,17 +179,9 @@ bool PnaclResources::ParseResourceInfo(const nacl::string& buf,
nacl::string PnaclResources::GetFullUrl( nacl::string PnaclResources::GetFullUrl(
const nacl::string& partial_url, const nacl::string& sandbox_arch) const { const nacl::string& partial_url, const nacl::string& sandbox_arch) const {
nacl::string full_url;
ErrorInfo error_info;
const nacl::string& url_with_platform_prefix = const nacl::string& url_with_platform_prefix =
sandbox_arch + "/" + partial_url; sandbox_arch + "/" + partial_url;
if (!manifest_->ResolveURL(url_with_platform_prefix, nacl::string full_url = PnaclUrls::GetBaseUrl() + url_with_platform_prefix;
&full_url,
&error_info)) {
PLUGIN_PRINTF(("PnaclResources::GetFullUrl failed: %s.\n",
error_info.message().c_str()));
return "";
}
return full_url; return full_url;
} }
......
...@@ -48,11 +48,9 @@ class PnaclUrls { ...@@ -48,11 +48,9 @@ class PnaclUrls {
class PnaclResources { class PnaclResources {
public: public:
PnaclResources(Plugin* plugin, PnaclResources(Plugin* plugin,
PnaclCoordinator* coordinator, PnaclCoordinator* coordinator)
const Manifest* manifest)
: plugin_(plugin), : plugin_(plugin),
coordinator_(coordinator), coordinator_(coordinator) {
manifest_(manifest) {
} }
virtual ~PnaclResources(); virtual ~PnaclResources();
...@@ -90,8 +88,6 @@ class PnaclResources { ...@@ -90,8 +88,6 @@ class PnaclResources {
Plugin* plugin_; Plugin* plugin_;
// The coordinator responsible for reporting errors, etc. // The coordinator responsible for reporting errors, etc.
PnaclCoordinator* coordinator_; PnaclCoordinator* coordinator_;
// The manifest for looking up resource URLs.
const Manifest* manifest_;
// The descriptor wrappers for the downloaded URLs. Only valid // The descriptor wrappers for the downloaded URLs. Only valid
// once all_loaded_callback_ has been invoked. // once all_loaded_callback_ has been invoked.
std::map<nacl::string, nacl::DescWrapper*> resource_wrappers_; std::map<nacl::string, nacl::DescWrapper*> resource_wrappers_;
......
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