Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc

Issue 8974020: Change pnacl to read all resources from the extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
===================================================================
--- ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc (revision 115018)
+++ ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc (working copy)
@@ -33,8 +33,10 @@
const char kLlcUrl[] = "llc";
const char kLdUrl[] = "ld";
-nacl::string ResourceBaseUrl() {
- return nacl::string("pnacl_support/") + GetSandboxISA() + "/";
+nacl::string ExtensionUrl() {
+ const nacl::string kPnaclExtensionOrigin =
+ "chrome-extension://gcodniebolpnpaiggndmcmmfpldlknih/";
elijahtaylor (use chromium) 2011/12/19 21:42:52 Hard-coded extension string seems a bit fragile...
sehr (please use chromium) 2011/12/20 01:48:38 I agree that we need to have a better way to refer
+ return kPnaclExtensionOrigin + GetSandboxISA() + "/";
}
nacl::string Random32CharHexString(struct NaClDescRng* rng) {
@@ -172,15 +174,8 @@
//////////////////////////////////////////////////////////////////////
class PnaclManifest : public Manifest {
public:
- PnaclManifest(const pp::URLUtil_Dev* url_util,
- const nacl::string& manifest_base_url)
- : Manifest(url_util, manifest_base_url, GetSandboxISA(), false) {
- size_t last_slash_pos = manifest_base_url_.rfind("/");
- CHECK(last_slash_pos != nacl::string::npos);
- // url_prefix contains everything in manifest_base_url up to and including
- // the last slash.
- url_prefix_ =
- manifest_base_url_.substr(0, last_slash_pos + 1) + ResourceBaseUrl();
+ PnaclManifest(const pp::URLUtil_Dev* url_util)
+ : Manifest(url_util, ExtensionUrl(), GetSandboxISA(), false) {
}
virtual ~PnaclManifest() { }
@@ -201,9 +196,9 @@
nacl::string* full_url,
ErrorInfo* error_info) const {
// Does not do general URL resolution, simply appends relative_url to
- // the end of url_prefix_.
+ // the end of manifest_base_url_.
UNREFERENCED_PARAMETER(error_info);
- *full_url = url_prefix_ + relative_url;
+ *full_url = manifest_base_url_ + relative_url;
return true;
}
@@ -232,8 +227,11 @@
return ResolveURL(key_basename, full_url, error_info);
}
- private:
- nacl::string url_prefix_;
+ // Since the pnacl coordinator manifest is in a base in the chrome extension
+ // scheme, lookups will need to access resources in their extension origin.
+ virtual bool PermitsExtensionUrls() const {
+ return true;
+ }
};
//////////////////////////////////////////////////////////////////////
@@ -246,10 +244,9 @@
PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (plugin=%p, pexe=%s)\n",
static_cast<void*>(plugin), pexe_url.c_str()));
PnaclCoordinator* coordinator =
- new PnaclCoordinator(plugin,
- pexe_url,
- translate_notify_callback,
- ResourceBaseUrl());
+ new PnaclCoordinator(plugin, pexe_url, translate_notify_callback);
+ PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p)\n",
+ reinterpret_cast<const void*>(coordinator->manifest_)));
// Load llc and ld.
std::vector<nacl::string> resource_urls;
resource_urls.push_back(kLlcUrl);
@@ -260,7 +257,7 @@
coordinator->resources_.reset(
new PnaclResources(plugin,
coordinator,
- coordinator->resource_base_url_,
+ coordinator->manifest_,
resource_urls,
resources_cb));
CHECK(coordinator->resources_ != NULL);
@@ -297,25 +294,20 @@
PnaclCoordinator::PnaclCoordinator(
Plugin* plugin,
const nacl::string& pexe_url,
- const pp::CompletionCallback& translate_notify_callback,
- const nacl::string& resource_base_url)
+ const pp::CompletionCallback& translate_notify_callback)
: plugin_(plugin),
translate_notify_callback_(translate_notify_callback),
- resource_base_url_(resource_base_url),
llc_subprocess_(NULL),
ld_subprocess_(NULL),
subprocesses_should_die_(false),
file_system_(new pp::FileSystem(plugin, PP_FILESYSTEMTYPE_LOCALTEMPORARY)),
// TODO(sehr,jvoung): change base url to pnacl extension/testing url.
jvoung - send to chromium... 2011/12/19 21:37:08 TODO can be removed now =)
elijahtaylor (use chromium) 2011/12/19 21:42:52 Time to remove TODO?
sehr (please use chromium) 2011/12/20 01:48:38 Done.
sehr (please use chromium) 2011/12/20 01:48:38 Done.
- manifest_(new PnaclManifest(plugin->url_util(),
- plugin->manifest_base_url())),
+ manifest_(new PnaclManifest(plugin->url_util())),
pexe_url_(pexe_url) {
PLUGIN_PRINTF(("PnaclCoordinator::PnaclCoordinator (this=%p, plugin=%p)\n",
static_cast<void*>(this), static_cast<void*>(plugin)));
callback_factory_.Initialize(this);
NaClXMutexCtor(&subprocess_mu_);
- // Check the temporary file system.
- CHECK(file_system_ != NULL);
elijahtaylor (use chromium) 2011/12/19 21:42:52 Why did you delete this check?
sehr (please use chromium) 2011/12/20 01:48:38 In chrome, new throws rather than returning null,
}
PnaclCoordinator::~PnaclCoordinator() {
@@ -433,7 +425,9 @@
pp::CompletionCallback cb =
callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate);
- if (!plugin_->StreamAsFile(pexe_url_, cb.pp_completion_callback())) {
+ if (!plugin_->StreamAsFile(pexe_url_,
+ manifest_->PermitsExtensionUrls(),
+ cb.pp_completion_callback())) {
ReportNonPpapiError(nacl::string("failed to download ") + pexe_url_ + "\n");
}
}

Powered by Google App Engine
This is Rietveld 408576698