Chromium Code Reviews| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER, | 268 ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER, |
| 269 pp_error, | 269 pp_error, |
| 270 "Failed to open translated nexe."); | 270 "Failed to open translated nexe."); |
| 271 return; | 271 return; |
| 272 } | 272 } |
| 273 | 273 |
| 274 translate_notify_callback_.Run(PP_OK); | 274 translate_notify_callback_.Run(PP_OK); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void PnaclCoordinator::OpenBitcodeStream() { | 277 void PnaclCoordinator::OpenBitcodeStream() { |
| 278 // The component updater's resource throttles + OnDemand update/install | |
| 279 // should block the URL request until the compiler is present. Now we | |
| 280 // can load the resources (e.g. llc and ld nexes). | |
| 281 resources_.reset(new PnaclResources(plugin_)); | |
| 282 CHECK(resources_ != NULL); | |
| 283 | |
| 284 // The first step of loading resources: read the resource info file. | |
| 285 if (!resources_->ReadResourceInfo()) { | |
| 286 ExitWithError(); | |
| 287 return; | |
| 288 } | |
| 289 | |
| 290 // Second step of loading resources: call StartLoad to load pnacl-llc | |
| 291 // and pnacl-ld, based on the filenames found in the resource info file. | |
| 292 if (!resources_->StartLoad()) { | |
| 293 ReportNonPpapiError( | |
| 294 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, | |
| 295 nacl::string("The Portable Native Client (pnacl) component is not " | |
| 296 "installed. Please consult chrome://components for more " | |
| 297 "information.")); | |
| 298 return; | |
| 299 } | |
| 300 | |
| 301 // Even though we haven't started downloading, create the translation | 278 // Even though we haven't started downloading, create the translation |
| 302 // thread object immediately. This ensures that any pieces of the file | 279 // thread object immediately. This ensures that any pieces of the file |
| 303 // that get downloaded before the compilation thread is accepting | 280 // that get downloaded before the compilation thread is accepting |
| 304 // SRPCs won't get dropped. | 281 // SRPCs won't get dropped. |
| 305 translate_thread_.reset(new PnaclTranslateThread()); | 282 translate_thread_.reset(new PnaclTranslateThread()); |
| 306 if (translate_thread_ == NULL) { | 283 if (translate_thread_ == NULL) { |
| 307 ReportNonPpapiError( | 284 ReportNonPpapiError( |
| 308 PP_NACL_ERROR_PNACL_THREAD_CREATE, | 285 PP_NACL_ERROR_PNACL_THREAD_CREATE, |
| 309 "PnaclCoordinator: could not allocate translation thread."); | 286 "PnaclCoordinator: could not allocate translation thread."); |
| 310 return; | 287 return; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 326 BitcodeStreamDidFinish(PP_ERROR_FAILED); | 303 BitcodeStreamDidFinish(PP_ERROR_FAILED); |
| 327 return; | 304 return; |
| 328 } | 305 } |
| 329 temp_nexe_file_.reset(new TempFile(plugin_, handle)); | 306 temp_nexe_file_.reset(new TempFile(plugin_, handle)); |
| 330 // Open it for reading as the cached nexe file. | 307 // Open it for reading as the cached nexe file. |
| 331 NexeReadDidOpen(temp_nexe_file_->Open(false)); | 308 NexeReadDidOpen(temp_nexe_file_->Open(false)); |
| 332 } | 309 } |
| 333 | 310 |
| 334 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size, | 311 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size, |
| 335 PP_FileHandle nexe_handle) { | 312 PP_FileHandle nexe_handle) { |
| 313 // The component updater's resource throttles + OnDemand update/install | |
|
dmichael (off chromium)
2014/08/08 20:51:34
Maybe right before this paragraph, say:
IMPORTANT:
| |
| 314 // should block the URL request until the compiler is present. Now we | |
| 315 // can load the resources (e.g. llc and ld nexes). | |
| 316 resources_.reset(new PnaclResources(plugin_)); | |
| 317 CHECK(resources_ != NULL); | |
| 318 | |
| 319 // The first step of loading resources: read the resource info file. | |
| 320 if (!resources_->ReadResourceInfo()) { | |
| 321 ExitWithError(); | |
| 322 return; | |
| 323 } | |
| 324 | |
| 325 // Second step of loading resources: call StartLoad to load pnacl-llc | |
| 326 // and pnacl-ld, based on the filenames found in the resource info file. | |
| 327 if (!resources_->StartLoad()) { | |
| 328 ReportNonPpapiError( | |
| 329 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, | |
| 330 nacl::string("The Portable Native Client (pnacl) component is not " | |
| 331 "installed. Please consult chrome://components for more " | |
| 332 "information.")); | |
| 333 return; | |
| 334 } | |
| 335 | |
| 336 expected_pexe_size_ = expected_pexe_size; | 336 expected_pexe_size_ = expected_pexe_size; |
| 337 | 337 |
| 338 for (int i = 0; i < split_module_count_; i++) { | 338 for (int i = 0; i < split_module_count_; i++) { |
| 339 PP_FileHandle obj_handle = | 339 PP_FileHandle obj_handle = |
| 340 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); | 340 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); |
| 341 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle)); | 341 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle)); |
| 342 int32_t pp_error = temp_file->Open(true); | 342 int32_t pp_error = temp_file->Open(true); |
| 343 if (pp_error != PP_OK) { | 343 if (pp_error != PP_OK) { |
| 344 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, | 344 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, |
| 345 pp_error, | 345 pp_error, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 invalid_desc_wrapper_.get(), | 452 invalid_desc_wrapper_.get(), |
| 453 &error_info_, | 453 &error_info_, |
| 454 resources_.get(), | 454 resources_.get(), |
| 455 &pnacl_options_, | 455 &pnacl_options_, |
| 456 architecture_attributes_, | 456 architecture_attributes_, |
| 457 this, | 457 this, |
| 458 plugin_); | 458 plugin_); |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace plugin | 461 } // namespace plugin |
| OLD | NEW |