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

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

Issue 11881038: Refine PNaCl pexe fetch UMA errors to know if the user aborted, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rearrange Created 7 years, 11 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/checked_cast.h" 10 #include "native_client/src/include/checked_cast.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // For now, tolerate bitcode that is missing a cache identity, and 342 // For now, tolerate bitcode that is missing a cache identity, and
343 // tolerate the lack of caching in incognito mode. 343 // tolerate the lack of caching in incognito mode.
344 PLUGIN_PRINTF(("PnaclCoordinator -- not caching.\n")); 344 PLUGIN_PRINTF(("PnaclCoordinator -- not caching.\n"));
345 NexeReadDidOpen(PP_OK); 345 NexeReadDidOpen(PP_OK);
346 } 346 }
347 } 347 }
348 348
349 void PnaclCoordinator::CachedNexeOpenedForWrite(int32_t pp_error) { 349 void PnaclCoordinator::CachedNexeOpenedForWrite(int32_t pp_error) {
350 if (pp_error != PP_OK) { 350 if (pp_error != PP_OK) {
351 if (pp_error == PP_ERROR_NOACCESS) { 351 if (pp_error == PP_ERROR_NOACCESS) {
352 ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOACCESS, 352 ReportPpapiError(
353 pp_error, 353 ERROR_PNACL_CACHE_FILEOPEN_NOACCESS,
354 "PNaCl translation cache failed to open file for write." 354 pp_error,
355 " No access."); 355 "PNaCl translation cache failed to open file for write "
356 "(no access).");
356 return; 357 return;
357 } 358 }
358 if (pp_error == PP_ERROR_NOQUOTA) { 359 if (pp_error == PP_ERROR_NOQUOTA) {
359 ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA, 360 ReportPpapiError(
360 pp_error, 361 ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA,
361 "PNaCl translation cache failed to open file for write." 362 pp_error,
362 " No quota."); 363 "PNaCl translation cache failed to open file for write "
364 "(no quota).");
363 return; 365 return;
364 } 366 }
365 if (pp_error == PP_ERROR_NOSPACE) { 367 if (pp_error == PP_ERROR_NOSPACE) {
366 ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOSPACE, 368 ReportPpapiError(
367 pp_error, 369 ERROR_PNACL_CACHE_FILEOPEN_NOSPACE,
368 "PNaCl translation cache failed to open file for write." 370 pp_error,
369 " No space."); 371 "PNaCl translation cache failed to open file for write "
372 "(no space).");
370 return; 373 return;
371 } 374 }
372 if (pp_error == PP_ERROR_NOTAFILE) { 375 if (pp_error == PP_ERROR_NOTAFILE) {
373 ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE, 376 ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE,
374 pp_error, 377 pp_error,
375 "PNaCl translation cache failed to open file for write." 378 "PNaCl translation cache failed to open file for write."
376 " File already exists as a directory."); 379 " File already exists as a directory.");
377 return; 380 return;
378 } 381 }
379 ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_OTHER, 382 ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_OTHER,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 cached_nexe_file_->write_file_io()->Write(next_offset, buf, num_read, cb); 470 cached_nexe_file_->write_file_io()->Write(next_offset, buf, num_read, cb);
468 } 471 }
469 472
470 void PnaclCoordinator::NexeWasCopiedToCache(int32_t pp_error) { 473 void PnaclCoordinator::NexeWasCopiedToCache(int32_t pp_error) {
471 if (pp_error != PP_OK) { 474 if (pp_error != PP_OK) {
472 // TODO(jvoung): This should try to delete the partially written 475 // TODO(jvoung): This should try to delete the partially written
473 // cache file before returning... 476 // cache file before returning...
474 if (pp_error == PP_ERROR_NOQUOTA) { 477 if (pp_error == PP_ERROR_NOQUOTA) {
475 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA, 478 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA,
476 pp_error, 479 pp_error,
477 "Failed to copy translated nexe to cache. No quota."); 480 "Failed to copy translated nexe to cache (no quota).");
478 return; 481 return;
479 } 482 }
480 if (pp_error == PP_ERROR_NOSPACE) { 483 if (pp_error == PP_ERROR_NOSPACE) {
481 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE, 484 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE,
482 pp_error, 485 pp_error,
483 "Failed to copy translated nexe to cache. No space."); 486 "Failed to copy translated nexe to cache (no space).");
484 return; 487 return;
485 } 488 }
486 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER, 489 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER,
487 pp_error, 490 pp_error,
488 "Failed to copy translated nexe to cache."); 491 "Failed to copy translated nexe to cache.");
489 return; 492 return;
490 } 493 }
491 // Rename the cached_nexe_file_ file to the cache id, to finalize. 494 // Rename the cached_nexe_file_ file to the cache id, to finalize.
492 pp::CompletionCallback cb = 495 pp::CompletionCallback cb =
493 callback_factory_.NewCallback(&PnaclCoordinator::NexeFileWasRenamed); 496 callback_factory_.NewCallback(&PnaclCoordinator::NexeFileWasRenamed);
494 cached_nexe_file_->Rename(cache_identity_, cb); 497 cached_nexe_file_->Rename(cache_identity_, cb);
495 } 498 }
496 499
497 void PnaclCoordinator::NexeFileWasRenamed(int32_t pp_error) { 500 void PnaclCoordinator::NexeFileWasRenamed(int32_t pp_error) {
498 PLUGIN_PRINTF(("PnaclCoordinator::NexeFileWasRenamed (pp_error=%" 501 PLUGIN_PRINTF(("PnaclCoordinator::NexeFileWasRenamed (pp_error=%"
499 NACL_PRId32")\n", pp_error)); 502 NACL_PRId32")\n", pp_error));
500 if (pp_error != PP_OK) { 503 if (pp_error != PP_OK) {
501 if (pp_error == PP_ERROR_NOACCESS) { 504 if (pp_error == PP_ERROR_NOACCESS) {
502 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS, 505 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS,
503 pp_error, 506 pp_error,
504 "Failed to finalize cached translation. No access."); 507 "Failed to finalize cached translation (no access).");
505 return; 508 return;
506 } else if (pp_error != PP_ERROR_FILEEXISTS) { 509 } else if (pp_error != PP_ERROR_FILEEXISTS) {
507 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER, 510 ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER,
508 pp_error, 511 pp_error,
509 "Failed to finalize cached translation."); 512 "Failed to finalize cached translation.");
510 return; 513 return;
511 } else { // pp_error == PP_ERROR_FILEEXISTS. 514 } else { // pp_error == PP_ERROR_FILEEXISTS.
512 // NOTE: if the file already existed, it looks like the rename will 515 // NOTE: if the file already existed, it looks like the rename will
513 // happily succeed. However, we should add a test for this. 516 // happily succeed. However, we should add a test for this.
514 // Could be a hash collision, or it could also be two tabs racing to 517 // Could be a hash collision, or it could also be two tabs racing to
(...skipping 18 matching lines...) Expand all
533 cached_nexe_file_->OpenRead(cb); 536 cached_nexe_file_->OpenRead(cb);
534 } 537 }
535 538
536 void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) { 539 void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) {
537 PLUGIN_PRINTF(("PnaclCoordinator::NexeReadDidOpen (pp_error=%" 540 PLUGIN_PRINTF(("PnaclCoordinator::NexeReadDidOpen (pp_error=%"
538 NACL_PRId32")\n", pp_error)); 541 NACL_PRId32")\n", pp_error));
539 if (pp_error != PP_OK) { 542 if (pp_error != PP_OK) {
540 if (pp_error == PP_ERROR_FILENOTFOUND) { 543 if (pp_error == PP_ERROR_FILENOTFOUND) {
541 ReportPpapiError(ERROR_PNACL_CACHE_FETCH_NOTFOUND, 544 ReportPpapiError(ERROR_PNACL_CACHE_FETCH_NOTFOUND,
542 pp_error, 545 pp_error,
543 "Failed to open translated nexe. Not found."); 546 "Failed to open translated nexe (not found).");
544 return; 547 return;
545 } 548 }
546 if (pp_error == PP_ERROR_NOACCESS) { 549 if (pp_error == PP_ERROR_NOACCESS) {
547 ReportPpapiError(ERROR_PNACL_CACHE_FETCH_NOACCESS, 550 ReportPpapiError(ERROR_PNACL_CACHE_FETCH_NOACCESS,
548 pp_error, 551 pp_error,
549 "Failed to open translated nexe. No access."); 552 "Failed to open translated nexe (no access).");
550 return; 553 return;
551 } 554 }
552 ReportPpapiError(ERROR_PNACL_CACHE_FETCH_OTHER, 555 ReportPpapiError(ERROR_PNACL_CACHE_FETCH_OTHER,
553 pp_error, 556 pp_error,
554 "Failed to open translated nexe."); 557 "Failed to open translated nexe.");
555 return; 558 return;
556 } 559 }
557 560
558 // Transfer ownership of cache/temp file's wrapper to the coordinator. 561 // Transfer ownership of cache/temp file's wrapper to the coordinator.
559 if (cached_nexe_file_ != NULL) { 562 if (cached_nexe_file_ != NULL) {
(...skipping 21 matching lines...) Expand all
581 int32_t open_error = file_system_->Open(0, cb); 584 int32_t open_error = file_system_->Open(0, cb);
582 if (open_error != PP_OK_COMPLETIONPENDING) { 585 if (open_error != PP_OK_COMPLETIONPENDING) {
583 // At this point, no async request has kicked off to check for 586 // At this point, no async request has kicked off to check for
584 // permissions, space, etc., so the only error that can be detected 587 // permissions, space, etc., so the only error that can be detected
585 // now is that an open() is already in progress (or a really terrible 588 // now is that an open() is already in progress (or a really terrible
586 // error). 589 // error).
587 if (pp_error == PP_ERROR_INPROGRESS) { 590 if (pp_error == PP_ERROR_INPROGRESS) {
588 ReportPpapiError( 591 ReportPpapiError(
589 ERROR_PNACL_CACHE_OPEN_INPROGRESS, 592 ERROR_PNACL_CACHE_OPEN_INPROGRESS,
590 pp_error, 593 pp_error,
591 "File system for PNaCl translation cache failed to open." 594 "File system for PNaCl translation cache failed to open "
592 " In progress."); 595 "(in progress).");
593 return; 596 return;
594 } 597 }
595 ReportPpapiError( 598 ReportPpapiError(
596 ERROR_PNACL_CACHE_OPEN_OTHER, 599 ERROR_PNACL_CACHE_OPEN_OTHER,
597 pp_error, 600 pp_error,
598 "File system for PNaCl translation cache failed to open."); 601 "File system for PNaCl translation cache failed to open.");
599 } 602 }
600 } else { 603 } else {
601 // We don't have a cache, so do the non-cached codepath. 604 // We don't have a cache, so do the non-cached codepath.
602 CachedFileDidOpen(PP_ERROR_FAILED); 605 CachedFileDidOpen(PP_ERROR_FAILED);
603 } 606 }
604 } 607 }
605 608
606 void PnaclCoordinator::FileSystemDidOpen(int32_t pp_error) { 609 void PnaclCoordinator::FileSystemDidOpen(int32_t pp_error) {
607 PLUGIN_PRINTF(("PnaclCoordinator::FileSystemDidOpen (pp_error=%" 610 PLUGIN_PRINTF(("PnaclCoordinator::FileSystemDidOpen (pp_error=%"
608 NACL_PRId32")\n", pp_error)); 611 NACL_PRId32")\n", pp_error));
609 if (pp_error != PP_OK) { 612 if (pp_error != PP_OK) {
610 if (pp_error == PP_ERROR_NOACCESS) { 613 if (pp_error == PP_ERROR_NOACCESS) {
611 ReportPpapiError(ERROR_PNACL_CACHE_OPEN_NOACCESS, 614 ReportPpapiError(
612 pp_error, 615 ERROR_PNACL_CACHE_OPEN_NOACCESS,
613 "File system for PNaCl translation cache failed to open." 616 pp_error,
614 " No access."); 617 "File system for PNaCl translation cache failed to open "
618 "(no access).");
615 return; 619 return;
616 } 620 }
617 if (pp_error == PP_ERROR_NOQUOTA) { 621 if (pp_error == PP_ERROR_NOQUOTA) {
618 ReportPpapiError(ERROR_PNACL_CACHE_OPEN_NOQUOTA, 622 ReportPpapiError(
619 pp_error, 623 ERROR_PNACL_CACHE_OPEN_NOQUOTA,
620 "File system for PNaCl translation cache failed to open." 624 pp_error,
621 " No quota."); 625 "File system for PNaCl translation cache failed to open "
626 "(no quota).");
622 return; 627 return;
623 } 628 }
624 if (pp_error == PP_ERROR_NOSPACE) { 629 if (pp_error == PP_ERROR_NOSPACE) {
625 ReportPpapiError(ERROR_PNACL_CACHE_OPEN_NOSPACE, 630 ReportPpapiError(
626 pp_error, 631 ERROR_PNACL_CACHE_OPEN_NOSPACE,
627 "File system for PNaCl translation cache failed to open." 632 pp_error,
628 " No space."); 633 "File system for PNaCl translation cache failed to open "
634 "(no space).");
629 return; 635 return;
630 } 636 }
631 ReportPpapiError(ERROR_PNACL_CACHE_OPEN_OTHER, 637 ReportPpapiError(ERROR_PNACL_CACHE_OPEN_OTHER,
632 pp_error, 638 pp_error,
633 "File system for PNaCl translation cache failed to open."); 639 "File system for PNaCl translation cache failed to open.");
634 } 640 }
635 dir_ref_.reset(new pp::FileRef(*file_system_, kPnaclTempDir)); 641 dir_ref_.reset(new pp::FileRef(*file_system_, kPnaclTempDir));
636 // Attempt to create the directory. 642 // Attempt to create the directory.
637 pp::CompletionCallback cb = 643 pp::CompletionCallback cb =
638 callback_factory_.NewCallback(&PnaclCoordinator::DirectoryWasCreated); 644 callback_factory_.NewCallback(&PnaclCoordinator::DirectoryWasCreated);
639 dir_ref_->MakeDirectory(cb); 645 dir_ref_->MakeDirectory(cb);
640 } 646 }
641 647
642 void PnaclCoordinator::DirectoryWasCreated(int32_t pp_error) { 648 void PnaclCoordinator::DirectoryWasCreated(int32_t pp_error) {
643 PLUGIN_PRINTF(("PnaclCoordinator::DirectoryWasCreated (pp_error=%" 649 PLUGIN_PRINTF(("PnaclCoordinator::DirectoryWasCreated (pp_error=%"
644 NACL_PRId32")\n", pp_error)); 650 NACL_PRId32")\n", pp_error));
645 if (pp_error != PP_ERROR_FILEEXISTS && pp_error != PP_OK) { 651 if (pp_error != PP_ERROR_FILEEXISTS && pp_error != PP_OK) {
646 // Directory did not exist and could not be created. 652 // Directory did not exist and could not be created.
647 if (pp_error == PP_ERROR_NOACCESS) { 653 if (pp_error == PP_ERROR_NOACCESS) {
648 ReportPpapiError( 654 ReportPpapiError(
649 ERROR_PNACL_CACHE_DIRECTORY_CREATE, 655 ERROR_PNACL_CACHE_DIRECTORY_CREATE,
650 pp_error, 656 pp_error,
651 "PNaCl translation cache directory creation/check failed. " 657 "PNaCl translation cache directory creation/check failed "
652 "No access."); 658 "(no access).");
653 return; 659 return;
654 } 660 }
655 ReportPpapiError( 661 ReportPpapiError(
656 ERROR_PNACL_CACHE_DIRECTORY_CREATE, 662 ERROR_PNACL_CACHE_DIRECTORY_CREATE,
657 pp_error, 663 pp_error,
658 "PNaCl translation cache directory creation/check failed."); 664 "PNaCl translation cache directory creation/check failed.");
659 return; 665 return;
660 } 666 }
661 if (cache_identity_ != "") { 667 if (cache_identity_ != "") {
662 cached_nexe_file_.reset(new LocalTempFile(plugin_, file_system_.get(), 668 cached_nexe_file_.reset(new LocalTempFile(plugin_, file_system_.get(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 pp::CompletionCallback obj_cb = 702 pp::CompletionCallback obj_cb =
697 callback_factory_.NewCallback(&PnaclCoordinator::ObjectFileDidOpen); 703 callback_factory_.NewCallback(&PnaclCoordinator::ObjectFileDidOpen);
698 obj_file_->Open(obj_cb); 704 obj_file_->Open(obj_cb);
699 705
700 streaming_downloader_.reset(new FileDownloader()); 706 streaming_downloader_.reset(new FileDownloader());
701 streaming_downloader_->Initialize(plugin_); 707 streaming_downloader_->Initialize(plugin_);
702 pp::CompletionCallback cb = 708 pp::CompletionCallback cb =
703 callback_factory_.NewCallback( 709 callback_factory_.NewCallback(
704 &PnaclCoordinator::BitcodeStreamDidFinish); 710 &PnaclCoordinator::BitcodeStreamDidFinish);
705 711
706 // TODO(dschuff): need to use url_util_->ResolveRelativeToURL?
707 if (!streaming_downloader_->OpenStream(pexe_url_, cb, this)) { 712 if (!streaming_downloader_->OpenStream(pexe_url_, cb, this)) {
708 ReportNonPpapiError(ERROR_PNACL_PEXE_FETCH, 713 ReportNonPpapiError(ERROR_PNACL_PEXE_FETCH_OTHER,
709 nacl::string("failed to open stream ") + pexe_url_); 714 nacl::string("failed to open stream ") + pexe_url_);
710 } 715 }
711 } 716 }
712 717
713 void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) { 718 void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) {
714 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamDidFinish (pp_error=%" 719 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamDidFinish (pp_error=%"
715 NACL_PRId32")\n", pp_error)); 720 NACL_PRId32")\n", pp_error));
716 if (pp_error != PP_OK) { 721 if (pp_error != PP_OK) {
717 // Defer reporting the error and cleanup until after the translation 722 // Defer reporting the error and cleanup until after the translation
718 // thread returns, because it may be accessing the coordinator's 723 // thread returns, because it may be accessing the coordinator's
719 // objects or writing to the files. 724 // objects or writing to the files.
720 // TODO(dschuff,jvoung): If this is a PP_ERROR_ABORTED, we probably
721 // want the UMA stat to show that the user aborted the action
722 // (vs a network error).
723 // We also want to track the total number of bytes of the pexe
724 // to know the typical application sizes.
725 translate_finish_error_ = pp_error; 725 translate_finish_error_ = pp_error;
726 nacl::stringstream ss; 726 if (pp_error == PP_ERROR_ABORTED) {
727 ss << "PnaclCoordinator: pexe load failed (pp_error=" << pp_error << ")."; 727 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_ABORTED,
728 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH, ss.str()); 728 "PnaclCoordinator: pexe load failed (aborted).");
729 }
730 if (pp_error == PP_ERROR_NOACCESS) {
731 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_NOACCESS,
732 "PnaclCoordinator: pexe load failed (no access).");
733 } else {
734 nacl::stringstream ss;
735 ss << "PnaclCoordinator: pexe load failed (pp_error=" << pp_error << ").";
736 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_OTHER, ss.str());
737 }
729 translate_thread_->AbortSubprocesses(); 738 translate_thread_->AbortSubprocesses();
730 } 739 }
731 } 740 }
732 741
733 void PnaclCoordinator::BitcodeStreamGotData(int32_t pp_error, 742 void PnaclCoordinator::BitcodeStreamGotData(int32_t pp_error,
734 FileStreamData data) { 743 FileStreamData data) {
735 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamGotData (pp_error=%" 744 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamGotData (pp_error=%"
736 NACL_PRId32", data=%p)\n", pp_error, data ? &(*data)[0] : 0)); 745 NACL_PRId32", data=%p)\n", pp_error, data ? &(*data)[0] : 0));
737 DCHECK(translate_thread_.get()); 746 DCHECK(translate_thread_.get());
738 translate_thread_->PutBytes(data, pp_error); 747 translate_thread_->PutBytes(data, pp_error);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 manifest_.get(), 782 manifest_.get(),
774 ld_manifest_.get(), 783 ld_manifest_.get(),
775 obj_file_.get(), 784 obj_file_.get(),
776 temp_nexe_file_.get(), 785 temp_nexe_file_.get(),
777 &error_info_, 786 &error_info_,
778 resources_.get(), 787 resources_.get(),
779 plugin_); 788 plugin_);
780 } 789 }
781 790
782 } // namespace plugin 791 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698