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 "native_client/src/trusted/plugin/pnacl_coordinator.h" | 5 #include "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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 // All of the component files are native (do not require pnacl translate). | 83 // All of the component files are native (do not require pnacl translate). |
84 pnacl_options->set_translate(false); | 84 pnacl_options->set_translate(false); |
85 // We can only resolve keys in the files/ namespace. | 85 // We can only resolve keys in the files/ namespace. |
86 const nacl::string kFilesPrefix = "files/"; | 86 const nacl::string kFilesPrefix = "files/"; |
87 size_t files_prefix_pos = key.find(kFilesPrefix); | 87 size_t files_prefix_pos = key.find(kFilesPrefix); |
88 if (files_prefix_pos == nacl::string::npos) { | 88 if (files_prefix_pos == nacl::string::npos) { |
89 error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL, | 89 error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL, |
90 "key did not start with files/"); | 90 "key did not start with files/"); |
91 return false; | 91 return false; |
92 } | 92 } |
93 // Append what follows files to the pnacl URL prefix. | 93 // Append what follows files to the pnacl URL prefix. |
jvoung (off chromium)
2013/05/23 20:33:19
also comment that this now adds the expected archi
eliben
2013/05/23 20:54:25
Done.
| |
94 nacl::string key_basename = key.substr(kFilesPrefix.length()); | 94 nacl::string key_basename = key.substr(kFilesPrefix.length()); |
95 return ResolveURL(key_basename, full_url, error_info); | 95 return ResolveURL(PnaclUrls::PrependPlatformPrefix(key_basename), |
96 full_url, error_info); | |
96 } | 97 } |
97 | 98 |
98 private: | 99 private: |
99 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest); | 100 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest); |
100 | 101 |
101 nacl::string manifest_base_url_; | 102 nacl::string manifest_base_url_; |
102 }; | 103 }; |
103 | 104 |
104 ////////////////////////////////////////////////////////////////////// | 105 ////////////////////////////////////////////////////////////////////// |
105 // UMA stat helpers. | 106 // UMA stat helpers. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 pnacl_options, | 231 pnacl_options, |
231 translate_notify_callback); | 232 translate_notify_callback); |
232 coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds(); | 233 coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds(); |
233 coordinator->off_the_record_ = | 234 coordinator->off_the_record_ = |
234 plugin->nacl_interface()->IsOffTheRecord(); | 235 plugin->nacl_interface()->IsOffTheRecord(); |
235 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, " | 236 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, " |
236 "off_the_record=%d)\n", | 237 "off_the_record=%d)\n", |
237 reinterpret_cast<const void*>(coordinator->manifest_.get()), | 238 reinterpret_cast<const void*>(coordinator->manifest_.get()), |
238 coordinator->off_the_record_)); | 239 coordinator->off_the_record_)); |
239 | 240 |
240 // Load llc and ld. | 241 // Load llc and ld. |
jvoung (off chromium)
2013/05/23 20:33:19
remove comment about llc and ld, or somehow incorp
eliben
2013/05/23 20:54:25
Changed comment, and also added below.
| |
241 std::vector<nacl::string> resource_urls; | |
242 resource_urls.push_back(PnaclUrls::GetLlcUrl()); | |
243 resource_urls.push_back(PnaclUrls::GetLdUrl()); | |
244 pp::CompletionCallback resources_cb = | |
245 coordinator->callback_factory_.NewCallback( | |
246 &PnaclCoordinator::ResourcesDidLoad); | |
247 coordinator->resources_.reset( | 242 coordinator->resources_.reset( |
248 new PnaclResources(plugin, | 243 new PnaclResources(plugin, |
249 coordinator, | 244 coordinator, |
250 coordinator->manifest_.get(), | 245 coordinator->manifest_.get())); |
251 resource_urls, | |
252 resources_cb)); | |
253 CHECK(coordinator->resources_ != NULL); | 246 CHECK(coordinator->resources_ != NULL); |
254 coordinator->resources_->StartLoad(); | 247 |
255 // ResourcesDidLoad will be invoked when all resources have been received. | 248 // The first step of loading resources: read the resource info file. |
249 pp::CompletionCallback resource_info_read_cb = | |
250 coordinator->callback_factory_.NewCallback( | |
251 &PnaclCoordinator::ResourceInfoWasRead); | |
252 coordinator->resources_->ReadResourceInfo(PnaclUrls::GetResourceInfoUrl(), | |
253 resource_info_read_cb); | |
256 return coordinator; | 254 return coordinator; |
257 } | 255 } |
258 | 256 |
259 PnaclCoordinator::PnaclCoordinator( | 257 PnaclCoordinator::PnaclCoordinator( |
260 Plugin* plugin, | 258 Plugin* plugin, |
261 const nacl::string& pexe_url, | 259 const nacl::string& pexe_url, |
262 const PnaclOptions& pnacl_options, | 260 const PnaclOptions& pnacl_options, |
263 const pp::CompletionCallback& translate_notify_callback) | 261 const pp::CompletionCallback& translate_notify_callback) |
264 : translate_finish_error_(PP_OK), | 262 : translate_finish_error_(PP_OK), |
265 plugin_(plugin), | 263 plugin_(plugin), |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 | 640 |
643 // Transfer ownership of cache/temp file's wrapper to the coordinator. | 641 // Transfer ownership of cache/temp file's wrapper to the coordinator. |
644 if (cached_nexe_file_ != NULL) { | 642 if (cached_nexe_file_ != NULL) { |
645 translated_fd_.reset(cached_nexe_file_->release_read_wrapper()); | 643 translated_fd_.reset(cached_nexe_file_->release_read_wrapper()); |
646 } else { | 644 } else { |
647 translated_fd_.reset(temp_nexe_file_->release_read_wrapper()); | 645 translated_fd_.reset(temp_nexe_file_->release_read_wrapper()); |
648 } | 646 } |
649 translate_notify_callback_.Run(pp_error); | 647 translate_notify_callback_.Run(pp_error); |
650 } | 648 } |
651 | 649 |
650 void PnaclCoordinator::ResourceInfoWasRead(int32_t pp_error) { | |
651 PLUGIN_PRINTF(("PluginCoordinator::ResourceInfoWasRead (pp_error=%" | |
652 NACL_PRId32")\n", pp_error)); | |
653 pp::CompletionCallback resources_cb = | |
654 callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad); | |
655 resources_->StartLoad(resources_cb); | |
656 } | |
657 | |
652 void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { | 658 void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { |
653 PLUGIN_PRINTF(("PnaclCoordinator::ResourcesDidLoad (pp_error=%" | 659 PLUGIN_PRINTF(("PnaclCoordinator::ResourcesDidLoad (pp_error=%" |
654 NACL_PRId32")\n", pp_error)); | 660 NACL_PRId32")\n", pp_error)); |
655 if (pp_error != PP_OK) { | 661 if (pp_error != PP_OK) { |
656 // Finer-grained error code should have already been reported by | 662 // Finer-grained error code should have already been reported by |
657 // the PnaclResources class. | 663 // the PnaclResources class. |
658 return; | 664 return; |
659 } | 665 } |
660 | 666 |
661 if (!off_the_record_) { | 667 if (!off_the_record_) { |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
916 obj_file_.get(), | 922 obj_file_.get(), |
917 temp_nexe_file_.get(), | 923 temp_nexe_file_.get(), |
918 &error_info_, | 924 &error_info_, |
919 resources_.get(), | 925 resources_.get(), |
920 &pnacl_options_, | 926 &pnacl_options_, |
921 this, | 927 this, |
922 plugin_); | 928 plugin_); |
923 } | 929 } |
924 | 930 |
925 } // namespace plugin | 931 } // namespace plugin |
OLD | NEW |