| 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 20 matching lines...) Expand all Loading... |
| 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(const nacl::string& sandbox_arch) | 40 PnaclManifest(const nacl::string& sandbox_arch) |
| 41 : manifest_base_url_(PnaclUrls::GetBaseUrl()), | 41 : sandbox_arch_(sandbox_arch) { } |
| 42 sandbox_arch_(sandbox_arch) { } | |
| 43 | 42 |
| 44 virtual ~PnaclManifest() { } | 43 virtual ~PnaclManifest() { } |
| 45 | 44 |
| 46 virtual bool GetProgramURL(nacl::string* full_url, | 45 virtual bool GetProgramURL(nacl::string* full_url, |
| 47 PnaclOptions* pnacl_options, | 46 PnaclOptions* pnacl_options, |
| 48 bool* uses_nonsfi_mode, | 47 bool* uses_nonsfi_mode, |
| 49 ErrorInfo* error_info) const { | 48 ErrorInfo* error_info) const { |
| 50 // Does not contain program urls. | 49 // Does not contain program urls. |
| 51 UNREFERENCED_PARAMETER(full_url); | 50 UNREFERENCED_PARAMETER(full_url); |
| 52 UNREFERENCED_PARAMETER(pnacl_options); | 51 UNREFERENCED_PARAMETER(pnacl_options); |
| 53 UNREFERENCED_PARAMETER(uses_nonsfi_mode); | 52 UNREFERENCED_PARAMETER(uses_nonsfi_mode); |
| 54 UNREFERENCED_PARAMETER(error_info); | 53 UNREFERENCED_PARAMETER(error_info); |
| 55 PLUGIN_PRINTF(("PnaclManifest does not contain a program\n")); | 54 PLUGIN_PRINTF(("PnaclManifest does not contain a program\n")); |
| 56 error_info->SetReport(PP_NACL_ERROR_MANIFEST_GET_NEXE_URL, | 55 error_info->SetReport(PP_NACL_ERROR_MANIFEST_GET_NEXE_URL, |
| 57 "pnacl manifest does not contain a program."); | 56 "pnacl manifest does not contain a program."); |
| 58 return false; | 57 return false; |
| 59 } | 58 } |
| 60 | 59 |
| 61 virtual bool ResolveURL(const nacl::string& relative_url, | |
| 62 nacl::string* full_url, | |
| 63 ErrorInfo* error_info) const { | |
| 64 // Does not do general URL resolution, simply appends relative_url to | |
| 65 // the end of manifest_base_url_. | |
| 66 UNREFERENCED_PARAMETER(error_info); | |
| 67 *full_url = manifest_base_url_ + relative_url; | |
| 68 return true; | |
| 69 } | |
| 70 | |
| 71 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { | 60 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { |
| 72 // Does not support enumeration. | 61 // Does not support enumeration. |
| 73 PLUGIN_PRINTF(("PnaclManifest does not support key enumeration\n")); | 62 PLUGIN_PRINTF(("PnaclManifest does not support key enumeration\n")); |
| 74 UNREFERENCED_PARAMETER(keys); | 63 UNREFERENCED_PARAMETER(keys); |
| 75 return false; | 64 return false; |
| 76 } | 65 } |
| 77 | 66 |
| 78 virtual bool ResolveKey(const nacl::string& key, | 67 virtual bool ResolveKey(const nacl::string& key, |
| 79 nacl::string* full_url, | 68 nacl::string* full_url, |
| 80 PnaclOptions* pnacl_options, | 69 PnaclOptions* pnacl_options, |
| 81 ErrorInfo* error_info) const { | 70 ErrorInfo* error_info) const { |
| 82 // All of the component files are native (do not require pnacl translate). | 71 // All of the component files are native (do not require pnacl translate). |
| 83 pnacl_options->set_translate(false); | 72 pnacl_options->set_translate(false); |
| 84 // We can only resolve keys in the files/ namespace. | 73 // We can only resolve keys in the files/ namespace. |
| 85 const nacl::string kFilesPrefix = "files/"; | 74 const nacl::string kFilesPrefix = "files/"; |
| 86 size_t files_prefix_pos = key.find(kFilesPrefix); | 75 size_t files_prefix_pos = key.find(kFilesPrefix); |
| 87 if (files_prefix_pos == nacl::string::npos) { | 76 if (files_prefix_pos == nacl::string::npos) { |
| 88 error_info->SetReport(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | 77 error_info->SetReport(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
| 89 "key did not start with files/"); | 78 "key did not start with files/"); |
| 90 return false; | 79 return false; |
| 91 } | 80 } |
| 92 // Resolve the full URL to the file. Provide it with a platform-specific | 81 // Resolve the full URL to the file. Provide it with a platform-specific |
| 93 // prefix. | 82 // prefix. |
| 94 nacl::string key_basename = key.substr(kFilesPrefix.length()); | 83 nacl::string key_basename = key.substr(kFilesPrefix.length()); |
| 95 return ResolveURL(sandbox_arch_ + "/" + key_basename, | 84 *full_url = PnaclUrls::GetBaseUrl() + sandbox_arch_ + "/" + key_basename; |
| 96 full_url, error_info); | 85 return true; |
| 97 } | 86 } |
| 98 | 87 |
| 99 private: | 88 private: |
| 100 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest); | 89 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest); |
| 101 | 90 |
| 102 nacl::string manifest_base_url_; | |
| 103 nacl::string sandbox_arch_; | 91 nacl::string sandbox_arch_; |
| 104 }; | 92 }; |
| 105 | 93 |
| 106 ////////////////////////////////////////////////////////////////////// | 94 ////////////////////////////////////////////////////////////////////// |
| 107 // UMA stat helpers. | 95 // UMA stat helpers. |
| 108 ////////////////////////////////////////////////////////////////////// | 96 ////////////////////////////////////////////////////////////////////// |
| 109 | 97 |
| 110 namespace { | 98 namespace { |
| 111 | 99 |
| 112 // Assume translation time metrics *can be* large. | 100 // Assume translation time metrics *can be* large. |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 BitcodeStreamDidFinish(pp_error); | 432 BitcodeStreamDidFinish(pp_error); |
| 445 // We have not spun up the translation process yet, so we need to call | 433 // We have not spun up the translation process yet, so we need to call |
| 446 // TranslateFinished here. | 434 // TranslateFinished here. |
| 447 TranslateFinished(pp_error); | 435 TranslateFinished(pp_error); |
| 448 return; | 436 return; |
| 449 } | 437 } |
| 450 | 438 |
| 451 // The component updater's resource throttles + OnDemand update/install | 439 // The component updater's resource throttles + OnDemand update/install |
| 452 // should block the URL request until the compiler is present. Now we | 440 // should block the URL request until the compiler is present. Now we |
| 453 // can load the resources (e.g. llc and ld nexes). | 441 // can load the resources (e.g. llc and ld nexes). |
| 454 resources_.reset(new PnaclResources(plugin_, this, this->manifest_.get())); | 442 resources_.reset(new PnaclResources(plugin_, this)); |
| 455 CHECK(resources_ != NULL); | 443 CHECK(resources_ != NULL); |
| 456 | 444 |
| 457 // The first step of loading resources: read the resource info file. | 445 // The first step of loading resources: read the resource info file. |
| 458 pp::CompletionCallback resource_info_read_cb = | 446 pp::CompletionCallback resource_info_read_cb = |
| 459 callback_factory_.NewCallback(&PnaclCoordinator::ResourceInfoWasRead); | 447 callback_factory_.NewCallback(&PnaclCoordinator::ResourceInfoWasRead); |
| 460 resources_->ReadResourceInfo(PnaclUrls::GetResourceInfoUrl(), | 448 resources_->ReadResourceInfo(PnaclUrls::GetResourceInfoUrl(), |
| 461 resource_info_read_cb); | 449 resource_info_read_cb); |
| 462 } | 450 } |
| 463 | 451 |
| 464 void PnaclCoordinator::ResourceInfoWasRead(int32_t pp_error) { | 452 void PnaclCoordinator::ResourceInfoWasRead(int32_t pp_error) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 temp_nexe_file_.get(), | 688 temp_nexe_file_.get(), |
| 701 invalid_desc_wrapper_.get(), | 689 invalid_desc_wrapper_.get(), |
| 702 &error_info_, | 690 &error_info_, |
| 703 resources_.get(), | 691 resources_.get(), |
| 704 &pnacl_options_, | 692 &pnacl_options_, |
| 705 this, | 693 this, |
| 706 plugin_); | 694 plugin_); |
| 707 } | 695 } |
| 708 | 696 |
| 709 } // namespace plugin | 697 } // namespace plugin |
| OLD | NEW |