| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 pp_error, | 329 pp_error, |
| 330 "Failed to open translated nexe."); | 330 "Failed to open translated nexe."); |
| 331 return; | 331 return; |
| 332 } | 332 } |
| 333 | 333 |
| 334 translate_notify_callback_.Run(pp_error); | 334 translate_notify_callback_.Run(pp_error); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void PnaclCoordinator::OpenBitcodeStream() { | 337 void PnaclCoordinator::OpenBitcodeStream() { |
| 338 // Now open the pexe stream. | 338 // Now open the pexe stream. |
| 339 streaming_downloader_.reset(new FileDownloader()); | 339 streaming_downloader_.reset(new FileDownloader(plugin_)); |
| 340 streaming_downloader_->Initialize(plugin_); | |
| 341 // Mark the request as requesting a PNaCl bitcode file, | 340 // Mark the request as requesting a PNaCl bitcode file, |
| 342 // so that component updater can detect this user action. | 341 // so that component updater can detect this user action. |
| 343 streaming_downloader_->set_request_headers( | 342 streaming_downloader_->set_request_headers( |
| 344 "Accept: application/x-pnacl, */*"); | 343 "Accept: application/x-pnacl, */*"); |
| 345 | 344 |
| 346 // Even though we haven't started downloading, create the translation | 345 // Even though we haven't started downloading, create the translation |
| 347 // thread object immediately. This ensures that any pieces of the file | 346 // thread object immediately. This ensures that any pieces of the file |
| 348 // that get downloaded before the compilation thread is accepting | 347 // that get downloaded before the compilation thread is accepting |
| 349 // SRPCs won't get dropped. | 348 // SRPCs won't get dropped. |
| 350 translate_thread_.reset(new PnaclTranslateThread()); | 349 translate_thread_.reset(new PnaclTranslateThread()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, | 466 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, |
| 468 pp_error, | 467 pp_error, |
| 469 "Failed to open scratch object file."); | 468 "Failed to open scratch object file."); |
| 470 } else { | 469 } else { |
| 471 num_object_files_opened_++; | 470 num_object_files_opened_++; |
| 472 } | 471 } |
| 473 } | 472 } |
| 474 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); | 473 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); |
| 475 | 474 |
| 476 // Meanwhile, a miss means we know we need to stream the bitcode, so stream | 475 // Meanwhile, a miss means we know we need to stream the bitcode, so stream |
| 477 // the rest of it now. (Calling FinishStreaming means that the downloader | 476 // the rest of it now. (Calling BeginStreaming means that the downloader |
| 478 // will begin handing data to the coordinator, which is safe any time after | 477 // will begin handing data to the coordinator, which is safe any time after |
| 479 // the translate_thread_ object has been initialized). | 478 // the translate_thread_ object has been initialized). |
| 480 pp::CompletionCallback finish_cb = callback_factory_.NewCallback( | 479 pp::CompletionCallback finish_cb = callback_factory_.NewCallback( |
| 481 &PnaclCoordinator::BitcodeStreamDidFinish); | 480 &PnaclCoordinator::BitcodeStreamDidFinish); |
| 482 streaming_downloader_->FinishStreaming(finish_cb); | 481 streaming_downloader_->BeginStreaming(finish_cb); |
| 483 | 482 |
| 484 if (num_object_files_opened_ == split_module_count_) { | 483 if (num_object_files_opened_ == split_module_count_) { |
| 485 // Open the nexe file for connecting ld and sel_ldr. | 484 // Open the nexe file for connecting ld and sel_ldr. |
| 486 // Start translation when done with this last step of setup! | 485 // Start translation when done with this last step of setup! |
| 487 RunTranslate(temp_nexe_file_->Open(true)); | 486 RunTranslate(temp_nexe_file_->Open(true)); |
| 488 } | 487 } |
| 489 } | 488 } |
| 490 } | 489 } |
| 491 | 490 |
| 492 void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) { | 491 void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 invalid_desc_wrapper_.get(), | 606 invalid_desc_wrapper_.get(), |
| 608 &error_info_, | 607 &error_info_, |
| 609 resources_.get(), | 608 resources_.get(), |
| 610 &pnacl_options_, | 609 &pnacl_options_, |
| 611 architecture_attributes_, | 610 architecture_attributes_, |
| 612 this, | 611 this, |
| 613 plugin_); | 612 plugin_); |
| 614 } | 613 } |
| 615 | 614 |
| 616 } // namespace plugin | 615 } // namespace plugin |
| OLD | NEW |