diff options
author | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 18:50:56 +0000 |
---|---|---|
committer | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 18:50:56 +0000 |
commit | eecc60c0af77e15929e82d26cfb52311dc0e83f9 (patch) | |
tree | e4b9c5d74d7f317d24a78b2cf5d0e39cc14da95a /ppapi | |
parent | 46e297a4adce655baf3e956b4a04ecd0c1083f2d (diff) | |
download | chromium_src-eecc60c0af77e15929e82d26cfb52311dc0e83f9.zip chromium_src-eecc60c0af77e15929e82d26cfb52311dc0e83f9.tar.gz chromium_src-eecc60c0af77e15929e82d26cfb52311dc0e83f9.tar.bz2 |
Get all the resources relative to a single base. Currently the same base
URL used for the link resources. In the future that base will be the pnacl
manifest file.
BUG= none
TEST= none
Review URL: http://codereview.chromium.org/8525014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109659 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
8 files changed, 51 insertions, 149 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/manifest.cc b/ppapi/native_client/src/trusted/plugin/manifest.cc index a34b9ad..ddf4880 100644 --- a/ppapi/native_client/src/trusted/plugin/manifest.cc +++ b/ppapi/native_client/src/trusted/plugin/manifest.cc @@ -60,10 +60,6 @@ const char* const kUrlKey = "url"; // } // } -// TODO(jvoung): Remove these when we find a better way to store/install them. -const char* const kPnaclLlcKey = "pnacl-llc"; -const char* const kPnaclLdKey = "pnacl-ld"; - // Looks up |property_name| in the vector |valid_names| with length // |valid_name_count|. Returns true if |property_name| is found. bool FindMatchingProperty(nacl::string property_name, @@ -434,67 +430,4 @@ bool Manifest::ResolveKey(const nacl::string& key, full_url, error_info, is_portable, this); } -// TODO(jvoung): We won't need these if we figure out how to install llc and ld. -bool Manifest::GetLLCURL(nacl::string* full_url, ErrorInfo* error_info) { - if (full_url == NULL || error_info == NULL) - return false; - - Json::Value pnacl_llc = dictionary_[kPnaclLlcKey]; - - nacl::string nexe_url; - nacl::string error_string; - bool is_portable; - if (!GetURLFromISADictionary(pnacl_llc, - sandbox_isa_, - &nexe_url, - &error_string, - &is_portable)) { - error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL, - nacl::string(kPnaclLlcKey) + ":" + sandbox_isa_ + - error_string); - return false; - } - - if (is_portable) { - // Bootstrap problem -- we need this to translate portable programs! - error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL, - nacl::string(kPnaclLlcKey) + - " must be pre-translated for " + sandbox_isa_ + "!"); - return false; - } - - return ResolveURL(nexe_url, full_url, error_info); -} - -bool Manifest::GetLDURL(nacl::string* full_url, ErrorInfo* error_info) { - if (full_url == NULL || error_info == NULL) - return false; - - Json::Value pnacl_ld = dictionary_[kPnaclLdKey]; - - nacl::string nexe_url; - nacl::string error_string; - bool is_portable; - if (!GetURLFromISADictionary(pnacl_ld, - sandbox_isa_, - &nexe_url, - &error_string, - &is_portable)) { - error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL, - nacl::string(kPnaclLdKey) + ":" + sandbox_isa_ + - error_string); - return false; - } - - if (is_portable) { - // Bootstrap problem -- we need this to translate portable programs! - error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL, - nacl::string(kPnaclLdKey) + - " must be pre-translated for " + sandbox_isa_ + "!"); - return false; - } - - return ResolveURL(nexe_url, full_url, error_info); -} - } // namespace plugin diff --git a/ppapi/native_client/src/trusted/plugin/manifest.h b/ppapi/native_client/src/trusted/plugin/manifest.h index 4e055c0..73d42bd 100644 --- a/ppapi/native_client/src/trusted/plugin/manifest.h +++ b/ppapi/native_client/src/trusted/plugin/manifest.h @@ -51,15 +51,6 @@ class Manifest { ErrorInfo* error_info, bool* is_portable); - // TODO(jvoung): Get rid of these when we find a better way to - // store / install these. - // Gets the full nexe URL for the LLC nexe from the manifest file. - bool GetLLCURL(nacl::string* full_url, ErrorInfo* error_info); - - // Gets the full nexe URL for the LD nexe from the manifest file. - bool GetLDURL(nacl::string* full_url, ErrorInfo* error_info); - // end TODO(jvoung) - // Resolves a URL relative to the manifest base URL bool ResolveURL(const nacl::string& relative_url, nacl::string* full_url, diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index 24a0157..1970ad7 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -1607,20 +1607,11 @@ void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { // Inform JavaScript that we found a nexe URL to load. EnqueueProgressEvent(kProgressEventProgress); if (is_portable) { - // TODO(jvoung): Do we want to check an ENV var if pnacl is enabled first? - nacl::string llc_url; - nacl::string ld_url; - if (SelectLLCURLFromManifest(&llc_url, &error_info) && - SelectLDURLFromManifest(&ld_url, &error_info)) { - pp::CompletionCallback translate_callback = - callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); - // Will always call the callback on success or failure. - pnacl_.BitcodeToNative(program_url, - llc_url, - ld_url, - translate_callback); - return; - } + pp::CompletionCallback translate_callback = + callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); + // Will always call the callback on success or failure. + pnacl_.BitcodeToNative(program_url, translate_callback); + return; } else { pp::CompletionCallback open_callback = callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); @@ -1708,26 +1699,6 @@ bool Plugin::SelectProgramURLFromManifest(nacl::string* result, return manifest_->GetProgramURL(result, error_info, is_portable); } -// TODO(jvoung): get rid of these when we have a better hosting solution -// for PNaCl's nexes. -bool Plugin::SelectLLCURLFromManifest(nacl::string* result, - ErrorInfo* error_info) { - PLUGIN_PRINTF(("Plugin::SelectLLCURLFromManifest()\n")); - if (result == NULL || error_info == NULL || manifest_ == NULL) - return false; - return manifest_->GetLLCURL(result, error_info); -} - -bool Plugin::SelectLDURLFromManifest(nacl::string* result, - ErrorInfo* error_info) { - PLUGIN_PRINTF(("Plugin::SelectLDURLFromManifest()\n")); - if (result == NULL || error_info == NULL || manifest_ == NULL) - return false; - return manifest_->GetLDURL(result, error_info); -} -// end TODO(jvoung) - - void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, FileDownloader*& url_downloader, PP_CompletionCallback callback) { diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h index bb1c220..966933b 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.h +++ b/ppapi/native_client/src/trusted/plugin/plugin.h @@ -442,13 +442,6 @@ class Plugin : public pp::InstancePrivate { ErrorInfo* error_info, bool* is_portable); - // TODO(jvoung): get rid of these once we find a better way to store / install - // the pnacl translator nexes. - bool SelectLLCURLFromManifest(nacl::string* result, - ErrorInfo* error_info); - bool SelectLDURLFromManifest(nacl::string* result, - ErrorInfo* error_info); - // Logs timing information to a UMA histogram, and also logs the same timing // information divided by the size of the nexe to another histogram. void HistogramStartupTimeSmall(const std::string& name, float dt); diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc index 9a947fa..dcf89c1 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc @@ -348,20 +348,23 @@ nacl::string GeneratedObjectFileName() { return nacl::string("___PNACL_GENERATED"); } -string_vector LinkResources(const nacl::string& sandbox_isa, - bool withGenerated) { - string_vector results; - nacl::string base_dir = "pnacl_support/" + sandbox_isa; +nacl::string ResourceBaseUrl() { + nacl::string sandbox_isa = GetSandboxISA(); + nacl::string base_url = "pnacl_support/" + sandbox_isa + "/"; + return base_url; +} +string_vector LinkResources(bool withGenerated) { + string_vector results; // NOTE: order of items == link order. - results.push_back(base_dir + "/crtbegin.o"); + results.push_back("crtbegin.o"); if (withGenerated) { results.push_back(GeneratedObjectFileName()); } - results.push_back(base_dir + "/libcrt_platform.a"); - results.push_back(base_dir + "/libgcc.a"); - results.push_back(base_dir + "/libgcc_eh.a"); - results.push_back(base_dir + "/crtend.o"); + results.push_back("libcrt_platform.a"); + results.push_back("libgcc.a"); + results.push_back("libgcc_eh.a"); + results.push_back("crtend.o"); return results; } @@ -429,7 +432,7 @@ void WINAPI DoLinkThread(void* arg) { } //// Files. - string_vector files = LinkResources(sandbox_isa, true); + string_vector files = LinkResources(true); PnaclResources* resources = coordinator->resources(); for (string_vector::iterator i = files.begin(), e = files.end(); i != e; ++i) { @@ -585,15 +588,16 @@ void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error, void PnaclCoordinator::BitcodeToNative( const nacl::string& pexe_url, - const nacl::string& llc_url, - const nacl::string& ld_url, const pp::CompletionCallback& finish_callback) { - PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (pexe=%s, llc=%s, ld=%s)\n", - pexe_url.c_str(), - llc_url.c_str(), - ld_url.c_str())); - llc_url_ = llc_url; - ld_url_ = ld_url; + PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (pexe=%s)\n", + pexe_url.c_str())); + // The base URL for finding all the resources will be obtained from the + // PNaCl manifest file. + // Also, the llc and ld pathnames should be read from the manifest. + // TODO(sehr): change to use the manifest file when ready. + resource_base_url_ = ResourceBaseUrl(); + llc_url_ = "llc"; + ld_url_ = "ld"; translate_notify_callback_ = finish_callback; // Steps: @@ -613,9 +617,9 @@ void PnaclCoordinator::BitcodeToNative( callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad, pexe_url, translation_unit_.get()); - resources_->AddResourceUrl(llc_url); - resources_->AddResourceUrl(ld_url); - string_vector link_resources = LinkResources(GetSandboxISA(), false); + resources_->AddResourceUrl(llc_url_); + resources_->AddResourceUrl(ld_url_); + string_vector link_resources = LinkResources(false); for (string_vector::iterator i = link_resources.begin(), e = link_resources.end(); i != e; diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h index c8fecee..3a0a83a 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h @@ -90,8 +90,6 @@ class PnaclCoordinator { void Initialize(Plugin* instance); void BitcodeToNative(const nacl::string& pexe_url, - const nacl::string& llc_url, - const nacl::string& ld_url, const pp::CompletionCallback& finish_callback); // Call this to take ownership of the FD of the translated nexe after @@ -115,9 +113,8 @@ class PnaclCoordinator { // Wrapper for Plugin ReportLoadError. void ReportLoadError(const ErrorInfo& error); - - // Accessors for use by helper threads. + nacl::string resource_base_url() const { return resource_base_url_; } Plugin* plugin() const { return plugin_; } nacl::string llc_url() const { return llc_url_; } NaClSubprocess* llc_subprocess() const { return llc_subprocess_; } @@ -153,6 +150,7 @@ class PnaclCoordinator { pp::CompletionCallbackFactory<PnaclCoordinator> callback_factory_; // URLs used to lookup downloaded resources. + nacl::string resource_base_url_; nacl::string llc_url_; nacl::string ld_url_; diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc index afc3431..97059db 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc @@ -60,17 +60,23 @@ void PnaclResources::StartDownloads() { delayed_callback_.reset( new DelayedCallback(all_loaded_callback, resource_count)); + // All resource URLs are relative to the coordinator's resource_base_url(). + nacl::string resource_base_url = coordinator_->resource_base_url(); + // Schedule the downloads. CHECK(resource_urls_.size() > 0); for (size_t i = 0; i < resource_urls_.size(); ++i) { - const nacl::string& url = resource_urls_[i]; + const nacl::string& full_url = resource_base_url + resource_urls_[i]; pp::CompletionCallback ready_callback = - callback_factory_.NewCallback(&PnaclResources::ResourceReady, url); - if (!plugin_->StreamAsFile(url, ready_callback.pp_completion_callback())) { + callback_factory_.NewCallback(&PnaclResources::ResourceReady, + resource_urls_[i], + full_url); + if (!plugin_->StreamAsFile(full_url, + ready_callback.pp_completion_callback())) { ErrorInfo error_info; error_info.SetReport(ERROR_UNKNOWN, "PnaclCoordinator: Failed to download file: " + - url + "\n"); + resource_urls_[i] + "\n"); coordinator_->ReportLoadError(error_info); coordinator_->PnaclNonPpapiError(); break; @@ -80,12 +86,13 @@ void PnaclResources::StartDownloads() { } void PnaclResources::ResourceReady(int32_t pp_error, - const nacl::string& url) { + const nacl::string& url, + const nacl::string& full_url) { PLUGIN_PRINTF(("PnaclResources::ResourceReady (pp_error=%" NACL_PRId32", url=%s)\n", pp_error, url.c_str())); // pp_error is checked by GetLoadedFileDesc. int32_t fd = coordinator_->GetLoadedFileDesc(pp_error, - url, + full_url, "resource " + url); if (fd < 0) { coordinator_->PnaclPpapiError(pp_error); diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_resources.h b/ppapi/native_client/src/trusted/plugin/pnacl_resources.h index fa7edb0..d23d4d5 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_resources.h +++ b/ppapi/native_client/src/trusted/plugin/pnacl_resources.h @@ -35,6 +35,9 @@ class PnaclResources { void Initialize(); + // URLs are all relative to the coordinator's resource_base_url(). + + // Get the wrapper for the downloaded resource. nacl::DescWrapper* WrapperForUrl(const nacl::string& url) { return resource_wrappers_[url]; } @@ -50,7 +53,9 @@ class PnaclResources { NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); // Callback invoked each time one resource has been loaded. - void ResourceReady(int32_t pp_error, const nacl::string& url); + void ResourceReady(int32_t pp_error, + const nacl::string& url, + const nacl::string& full_url); // Callback invoked when all resources have been loaded. void AllLoaded(int32_t pp_error); |