| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" | 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "native_client/src/include/checked_cast.h" | 10 #include "native_client/src/include/checked_cast.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Pnacl-specific manifest support. | 30 // Pnacl-specific manifest support. |
| 31 ////////////////////////////////////////////////////////////////////// | 31 ////////////////////////////////////////////////////////////////////// |
| 32 | 32 |
| 33 // The PNaCl linker gets file descriptors via the service runtime's | 33 // The PNaCl linker gets file descriptors via the service runtime's |
| 34 // reverse service lookup. The reverse service lookup requires a manifest. | 34 // reverse service lookup. The reverse service lookup requires a manifest. |
| 35 // Normally, that manifest is an NMF containing mappings for shared libraries. | 35 // Normally, that manifest is an NMF containing mappings for shared libraries. |
| 36 // Here, we provide a manifest that redirects to PNaCl component files | 36 // Here, we provide a manifest that redirects to PNaCl component files |
| 37 // that are part of Chrome. | 37 // that are part of Chrome. |
| 38 class PnaclManifest : public Manifest { | 38 class PnaclManifest : public Manifest { |
| 39 public: | 39 public: |
| 40 PnaclManifest() : manifest_base_url_(PnaclUrls::GetBaseUrl()) { } | 40 PnaclManifest(const nacl::string& sandbox_arch) |
| 41 : manifest_base_url_(PnaclUrls::GetBaseUrl()), |
| 42 sandbox_arch_(sandbox_arch) { } |
| 43 |
| 41 virtual ~PnaclManifest() { } | 44 virtual ~PnaclManifest() { } |
| 42 | 45 |
| 43 virtual bool GetProgramURL(nacl::string* full_url, | 46 virtual bool GetProgramURL(nacl::string* full_url, |
| 44 PnaclOptions* pnacl_options, | 47 PnaclOptions* pnacl_options, |
| 45 bool* uses_nonsfi_mode, | 48 bool* uses_nonsfi_mode, |
| 46 ErrorInfo* error_info) const { | 49 ErrorInfo* error_info) const { |
| 47 // Does not contain program urls. | 50 // Does not contain program urls. |
| 48 UNREFERENCED_PARAMETER(full_url); | 51 UNREFERENCED_PARAMETER(full_url); |
| 49 UNREFERENCED_PARAMETER(pnacl_options); | 52 UNREFERENCED_PARAMETER(pnacl_options); |
| 50 UNREFERENCED_PARAMETER(uses_nonsfi_mode); | 53 UNREFERENCED_PARAMETER(uses_nonsfi_mode); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 const nacl::string kFilesPrefix = "files/"; | 85 const nacl::string kFilesPrefix = "files/"; |
| 83 size_t files_prefix_pos = key.find(kFilesPrefix); | 86 size_t files_prefix_pos = key.find(kFilesPrefix); |
| 84 if (files_prefix_pos == nacl::string::npos) { | 87 if (files_prefix_pos == nacl::string::npos) { |
| 85 error_info->SetReport(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | 88 error_info->SetReport(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
| 86 "key did not start with files/"); | 89 "key did not start with files/"); |
| 87 return false; | 90 return false; |
| 88 } | 91 } |
| 89 // Resolve the full URL to the file. Provide it with a platform-specific | 92 // Resolve the full URL to the file. Provide it with a platform-specific |
| 90 // prefix. | 93 // prefix. |
| 91 nacl::string key_basename = key.substr(kFilesPrefix.length()); | 94 nacl::string key_basename = key.substr(kFilesPrefix.length()); |
| 92 return ResolveURL(PnaclUrls::PrependPlatformPrefix(key_basename), | 95 return ResolveURL(sandbox_arch_ + "/" + key_basename, |
| 93 full_url, error_info); | 96 full_url, error_info); |
| 94 } | 97 } |
| 95 | 98 |
| 96 private: | 99 private: |
| 97 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest); | 100 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest); |
| 98 | 101 |
| 99 nacl::string manifest_base_url_; | 102 nacl::string manifest_base_url_; |
| 103 nacl::string sandbox_arch_; |
| 100 }; | 104 }; |
| 101 | 105 |
| 102 ////////////////////////////////////////////////////////////////////// | 106 ////////////////////////////////////////////////////////////////////// |
| 103 // UMA stat helpers. | 107 // UMA stat helpers. |
| 104 ////////////////////////////////////////////////////////////////////// | 108 ////////////////////////////////////////////////////////////////////// |
| 105 | 109 |
| 106 namespace { | 110 namespace { |
| 107 | 111 |
| 108 // Assume translation time metrics *can be* large. | 112 // Assume translation time metrics *can be* large. |
| 109 // Up to 12 minutes. | 113 // Up to 12 minutes. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 219 |
| 216 PnaclCoordinator::PnaclCoordinator( | 220 PnaclCoordinator::PnaclCoordinator( |
| 217 Plugin* plugin, | 221 Plugin* plugin, |
| 218 const nacl::string& pexe_url, | 222 const nacl::string& pexe_url, |
| 219 const PnaclOptions& pnacl_options, | 223 const PnaclOptions& pnacl_options, |
| 220 const pp::CompletionCallback& translate_notify_callback) | 224 const pp::CompletionCallback& translate_notify_callback) |
| 221 : translate_finish_error_(PP_OK), | 225 : translate_finish_error_(PP_OK), |
| 222 plugin_(plugin), | 226 plugin_(plugin), |
| 223 translate_notify_callback_(translate_notify_callback), | 227 translate_notify_callback_(translate_notify_callback), |
| 224 translation_finished_reported_(false), | 228 translation_finished_reported_(false), |
| 225 manifest_(new PnaclManifest()), | 229 manifest_(new PnaclManifest(plugin->nacl_interface()->GetSandboxArch())), |
| 226 pexe_url_(pexe_url), | 230 pexe_url_(pexe_url), |
| 227 pnacl_options_(pnacl_options), | 231 pnacl_options_(pnacl_options), |
| 228 split_module_count_(1), | 232 split_module_count_(1), |
| 229 num_object_files_opened_(0), | 233 num_object_files_opened_(0), |
| 230 is_cache_hit_(PP_FALSE), | 234 is_cache_hit_(PP_FALSE), |
| 231 error_already_reported_(false), | 235 error_already_reported_(false), |
| 232 pnacl_init_time_(0), | 236 pnacl_init_time_(0), |
| 233 pexe_size_(0), | 237 pexe_size_(0), |
| 234 pexe_bytes_compiled_(0), | 238 pexe_bytes_compiled_(0), |
| 235 expected_pexe_size_(-1) { | 239 expected_pexe_size_(-1) { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 plugin_->nacl_interface()->GetNexeFd( | 505 plugin_->nacl_interface()->GetNexeFd( |
| 502 plugin_->pp_instance(), | 506 plugin_->pp_instance(), |
| 503 streaming_downloader_->full_url().c_str(), | 507 streaming_downloader_->full_url().c_str(), |
| 504 // TODO(dschuff): Get this value from the pnacl json file after it | 508 // TODO(dschuff): Get this value from the pnacl json file after it |
| 505 // rolls in from NaCl. | 509 // rolls in from NaCl. |
| 506 1, | 510 1, |
| 507 pnacl_options_.opt_level(), | 511 pnacl_options_.opt_level(), |
| 508 parser.GetHeader("last-modified").c_str(), | 512 parser.GetHeader("last-modified").c_str(), |
| 509 parser.GetHeader("etag").c_str(), | 513 parser.GetHeader("etag").c_str(), |
| 510 PP_FromBool(parser.CacheControlNoStore()), | 514 PP_FromBool(parser.CacheControlNoStore()), |
| 511 GetSandboxISA(), | 515 plugin_->nacl_interface()->GetSandboxArch(), |
| 512 "", // No extra compile flags yet. | 516 "", // No extra compile flags yet. |
| 513 &is_cache_hit_, | 517 &is_cache_hit_, |
| 514 temp_nexe_file_->existing_handle(), | 518 temp_nexe_file_->existing_handle(), |
| 515 cb.pp_completion_callback()); | 519 cb.pp_completion_callback()); |
| 516 if (nexe_fd_err < PP_OK_COMPLETIONPENDING) { | 520 if (nexe_fd_err < PP_OK_COMPLETIONPENDING) { |
| 517 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, nexe_fd_err, | 521 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, nexe_fd_err, |
| 518 nacl::string("Call to GetNexeFd failed")); | 522 nacl::string("Call to GetNexeFd failed")); |
| 519 } | 523 } |
| 520 } | 524 } |
| 521 | 525 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 temp_nexe_file_.get(), | 694 temp_nexe_file_.get(), |
| 691 invalid_desc_wrapper_.get(), | 695 invalid_desc_wrapper_.get(), |
| 692 &error_info_, | 696 &error_info_, |
| 693 resources_.get(), | 697 resources_.get(), |
| 694 &pnacl_options_, | 698 &pnacl_options_, |
| 695 this, | 699 this, |
| 696 plugin_); | 700 plugin_); |
| 697 } | 701 } |
| 698 | 702 |
| 699 } // namespace plugin | 703 } // namespace plugin |
| OLD | NEW |