Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc

Issue 10827109: Simplify Pnacl translation thread code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/portability_io.h" 10 #include "native_client/src/include/portability_io.h"
11 #include "native_client/src/shared/platform/nacl_check.h" 11 #include "native_client/src/shared/platform/nacl_check.h"
12 #include "native_client/src/trusted/plugin/local_temp_file.h" 12 #include "native_client/src/trusted/plugin/local_temp_file.h"
13 #include "native_client/src/trusted/plugin/manifest.h" 13 #include "native_client/src/trusted/plugin/manifest.h"
14 #include "native_client/src/trusted/plugin/plugin.h" 14 #include "native_client/src/trusted/plugin/plugin.h"
15 #include "native_client/src/trusted/plugin/plugin_error.h" 15 #include "native_client/src/trusted/plugin/plugin_error.h"
16 #include "native_client/src/trusted/plugin/pnacl_streaming_translate_thread.h"
17 #include "native_client/src/trusted/plugin/pnacl_translate_thread.h" 16 #include "native_client/src/trusted/plugin/pnacl_translate_thread.h"
18 #include "native_client/src/trusted/plugin/service_runtime.h" 17 #include "native_client/src/trusted/plugin/service_runtime.h"
19 #include "native_client/src/trusted/plugin/temporary_file.h" 18 #include "native_client/src/trusted/plugin/temporary_file.h"
20 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" 19 #include "native_client/src/trusted/service_runtime/include/sys/stat.h"
21 20
22 #include "ppapi/c/pp_errors.h" 21 #include "ppapi/c/pp_errors.h"
23 #include "ppapi/c/ppb_file_io.h" 22 #include "ppapi/c/ppb_file_io.h"
24 #include "ppapi/cpp/file_io.h" 23 #include "ppapi/cpp/file_io.h"
25 24
26 namespace { 25 namespace {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 PLUGIN_PRINTF(("PnaclCoordinator::CachedFileDidOpen (pp_error=%" 432 PLUGIN_PRINTF(("PnaclCoordinator::CachedFileDidOpen (pp_error=%"
434 NACL_PRId32")\n", pp_error)); 433 NACL_PRId32")\n", pp_error));
435 if (pp_error == PP_OK) { 434 if (pp_error == PP_OK) {
436 NexeReadDidOpen(PP_OK); 435 NexeReadDidOpen(PP_OK);
437 return; 436 return;
438 } 437 }
439 438
440 // Create the translation thread object immediately. This ensures that any 439 // Create the translation thread object immediately. This ensures that any
441 // pieces of the file that get downloaded before the compilation thread 440 // pieces of the file that get downloaded before the compilation thread
442 // is accepting SRPCs won't get dropped. 441 // is accepting SRPCs won't get dropped.
443 translate_thread_.reset(new PnaclStreamingTranslateThread()); 442 translate_thread_.reset(new PnaclTranslateThread());
444 if (translate_thread_ == NULL) { 443 if (translate_thread_ == NULL) {
445 ReportNonPpapiError("could not allocate translation thread."); 444 ReportNonPpapiError("could not allocate translation thread.");
446 return; 445 return;
447 } 446 }
448 // In the streaming case we also want to open the object file now so the 447 // In the streaming case we also want to open the object file now so the
449 // translator can start writing to it during streaming translation. 448 // translator can start writing to it during streaming translation.
450 // In the non-streaming case this can wait until the bitcode download is 449 // In the non-streaming case this can wait until the bitcode download is
451 // finished. 450 // finished.
452 obj_file_.reset(new TempFile(plugin_)); 451 obj_file_.reset(new TempFile(plugin_));
453 pp::CompletionCallback obj_cb = 452 pp::CompletionCallback obj_cb =
(...skipping 23 matching lines...) Expand all
477 error_info_.SetReport(ERROR_UNKNOWN, 476 error_info_.SetReport(ERROR_UNKNOWN,
478 nacl::string("PnaclCoordinator: pexe load failed.")); 477 nacl::string("PnaclCoordinator: pexe load failed."));
479 translate_thread_->SetSubprocessesShouldDie(); 478 translate_thread_->SetSubprocessesShouldDie();
480 } 479 }
481 } 480 }
482 481
483 void PnaclCoordinator::BitcodeStreamGotData(int32_t pp_error, 482 void PnaclCoordinator::BitcodeStreamGotData(int32_t pp_error,
484 FileStreamData data) { 483 FileStreamData data) {
485 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamGotData (pp_error=%" 484 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamGotData (pp_error=%"
486 NACL_PRId32", data=%p)\n", pp_error, data ? &(*data)[0] : 0)); 485 NACL_PRId32", data=%p)\n", pp_error, data ? &(*data)[0] : 0));
487 PnaclStreamingTranslateThread* thread = 486 DCHECK(translate_thread_.get());
488 static_cast<PnaclStreamingTranslateThread*>(translate_thread_.get()); 487 translate_thread_->PutBytes(data, pp_error);
489 DCHECK(thread);
490 thread->PutBytes(data, pp_error);
491 } 488 }
492 489
493 StreamCallback PnaclCoordinator::GetCallback() { 490 StreamCallback PnaclCoordinator::GetCallback() {
494 return callback_factory_.NewCallbackWithOutput( 491 return callback_factory_.NewCallbackWithOutput(
495 &PnaclCoordinator::BitcodeStreamGotData); 492 &PnaclCoordinator::BitcodeStreamGotData);
496 } 493 }
497 494
498 void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { 495 void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) {
499 PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%" 496 PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%"
500 NACL_PRId32")\n", pp_error)); 497 NACL_PRId32")\n", pp_error));
(...skipping 23 matching lines...) Expand all
524 manifest_.get(), 521 manifest_.get(),
525 ld_manifest_.get(), 522 ld_manifest_.get(),
526 obj_file_.get(), 523 obj_file_.get(),
527 nexe_file_.get(), 524 nexe_file_.get(),
528 &error_info_, 525 &error_info_,
529 resources_.get(), 526 resources_.get(),
530 plugin_); 527 plugin_);
531 } 528 }
532 529
533 } // namespace plugin 530 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698