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

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

Issue 231243002: PPAPI: Move some of NexeFileDidOpen to NexeLoadManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix crash Created 6 years, 8 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 #ifdef _MSC_VER 5 #ifdef _MSC_VER
6 // Do not warn about use of std::copy with raw pointers. 6 // Do not warn about use of std::copy with raw pointers.
7 #pragma warning(disable : 4996) 7 #pragma warning(disable : 4996)
8 #endif 8 #endif
9 9
10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 "NaCl.LoadStatus.SelLdr.InstalledApp" : 184 "NaCl.LoadStatus.SelLdr.InstalledApp" :
185 "NaCl.LoadStatus.SelLdr.NotInstalledApp"; 185 "NaCl.LoadStatus.SelLdr.NotInstalledApp";
186 HistogramEnumerate(name, error_code, NACL_ERROR_CODE_MAX, 186 HistogramEnumerate(name, error_code, NACL_ERROR_CODE_MAX,
187 LOAD_STATUS_UNKNOWN); 187 LOAD_STATUS_UNKNOWN);
188 } 188 }
189 189
190 void Plugin::HistogramEnumerateManifestIsDataURI(bool is_data_uri) { 190 void Plugin::HistogramEnumerateManifestIsDataURI(bool is_data_uri) {
191 HistogramEnumerate("NaCl.Manifest.IsDataURI", is_data_uri, 2, -1); 191 HistogramEnumerate("NaCl.Manifest.IsDataURI", is_data_uri, 2, -1);
192 } 192 }
193 193
194 void Plugin::HistogramHTTPStatusCode(const std::string& name, 194 void Plugin::HistogramHTTPStatusCode(const std::string& name, int status) {
195 int status) {
196 // Log the status codes in rough buckets - 1XX, 2XX, etc. 195 // Log the status codes in rough buckets - 1XX, 2XX, etc.
197 int sample = status / 100; 196 int sample = status / 100;
198 // HTTP status codes only go up to 5XX, using "6" to indicate an internal 197 // HTTP status codes only go up to 5XX, using "6" to indicate an internal
199 // error. 198 // error.
200 // Note: installed files may have "0" for a status code. 199 // Note: installed files may have "0" for a status code.
201 if (status < 0 || status >= 600) 200 if (status < 0 || status >= 600)
202 sample = 6; 201 sample = 6;
203 HistogramEnumerate(name, sample, 7, 6); 202 HistogramEnumerate(name, sample, 7, 6);
204 } 203 }
205 204
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 void Plugin::HistogramStartupTimeMedium(const std::string& name, float dt) { 606 void Plugin::HistogramStartupTimeMedium(const std::string& name, float dt) {
608 int64_t nexe_size = nacl_interface_->GetNexeSize(pp_instance()); 607 int64_t nexe_size = nacl_interface_->GetNexeSize(pp_instance());
609 if (nexe_size > 0) { 608 if (nexe_size > 0) {
610 float size_in_MB = static_cast<float>(nexe_size) / (1024.f * 1024.f); 609 float size_in_MB = static_cast<float>(nexe_size) / (1024.f * 1024.f);
611 HistogramTimeMedium(name, static_cast<int64_t>(dt)); 610 HistogramTimeMedium(name, static_cast<int64_t>(dt));
612 HistogramTimeMedium(name + "PerMB", static_cast<int64_t>(dt / size_in_MB)); 611 HistogramTimeMedium(name + "PerMB", static_cast<int64_t>(dt / size_in_MB));
613 } 612 }
614 } 613 }
615 614
616 void Plugin::NexeFileDidOpen(int32_t pp_error) { 615 void Plugin::NexeFileDidOpen(int32_t pp_error) {
617 PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (pp_error=%" NACL_PRId32 ")\n",
618 pp_error));
619 NaClFileInfo tmp_info(nexe_downloader_.GetFileInfo()); 616 NaClFileInfo tmp_info(nexe_downloader_.GetFileInfo());
620 NaClFileInfoAutoCloser info(&tmp_info); 617 NaClFileInfoAutoCloser info(&tmp_info);
621 PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (file_desc=%" NACL_PRId32 ")\n", 618
622 info.get_desc())); 619 int64_t nexe_bytes_read = -1;
623 HistogramHTTPStatusCode( 620 if (pp_error == PP_OK && info.get_desc() != NACL_NO_FILE_DESC) {
624 nacl_interface_->GetIsInstalled(pp_instance()) ? 621 struct stat stat_buf;
625 "NaCl.HttpStatusCodeClass.Nexe.InstalledApp" : 622 if (0 == fstat(info.get_desc(), &stat_buf))
626 "NaCl.HttpStatusCodeClass.Nexe.NotInstalledApp", 623 nexe_bytes_read = stat_buf.st_size;
627 nexe_downloader_.status_code());
628 ErrorInfo error_info;
629 if (pp_error != PP_OK || info.get_desc() == NACL_NO_FILE_DESC) {
630 if (pp_error == PP_ERROR_ABORTED) {
631 ReportLoadAbort();
632 } else if (pp_error == PP_ERROR_NOACCESS) {
633 error_info.SetReport(PP_NACL_ERROR_NEXE_NOACCESS_URL,
634 "access to nexe url was denied.");
635 ReportLoadError(error_info);
636 } else {
637 error_info.SetReport(PP_NACL_ERROR_NEXE_LOAD_URL,
638 "could not load nexe url.");
639 ReportLoadError(error_info);
640 }
641 return;
642 } 624 }
643 struct stat stat_buf;
644 if (0 != fstat(info.get_desc(), &stat_buf)) {
645 error_info.SetReport(PP_NACL_ERROR_NEXE_STAT, "could not stat nexe file.");
646 ReportLoadError(error_info);
647 return;
648 }
649 size_t nexe_bytes_read = static_cast<size_t>(stat_buf.st_size);
650 625
651 nacl_interface_->SetNexeSize(pp_instance(), nexe_bytes_read); 626 nacl_interface_->NexeFileDidOpen(pp_instance(),
652 HistogramSizeKB("NaCl.Perf.Size.Nexe", 627 pp_error,
653 static_cast<int32_t>(nexe_bytes_read / 1024)); 628 info.get_desc(),
629 nexe_downloader_.status_code(),
630 nexe_bytes_read,
631 nexe_downloader_.url().c_str());
654 HistogramStartupTimeMedium( 632 HistogramStartupTimeMedium(
655 "NaCl.Perf.StartupTime.NexeDownload", 633 "NaCl.Perf.StartupTime.NexeDownload",
656 static_cast<float>(nexe_downloader_.TimeSinceOpenMilliseconds())); 634 static_cast<float>(nexe_downloader_.TimeSinceOpenMilliseconds()));
657 635
658 // Inform JavaScript that we successfully downloaded the nacl module.
659 EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS,
660 nexe_downloader_.url(),
661 LENGTH_IS_COMPUTABLE,
662 nexe_bytes_read,
663 nexe_bytes_read);
664
665 load_start_ = NaClGetTimeOfDayMicroseconds(); 636 load_start_ = NaClGetTimeOfDayMicroseconds();
666 nacl::scoped_ptr<nacl::DescWrapper> 637 nacl::scoped_ptr<nacl::DescWrapper>
667 wrapper(wrapper_factory()->MakeFileDesc(info.Release().desc, O_RDONLY)); 638 wrapper(wrapper_factory()->MakeFileDesc(info.Release().desc, O_RDONLY));
668 NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n"); 639 NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n");
669 LoadNaClModule( 640 LoadNaClModule(
670 wrapper.release(), 641 wrapper.release(),
671 uses_nonsfi_mode_, 642 uses_nonsfi_mode_,
672 true, /* enable_dyncode_syscalls */ 643 true, /* enable_dyncode_syscalls */
673 true, /* enable_exception_handling */ 644 true, /* enable_exception_handling */
674 false, /* enable_crash_throttling */ 645 false, /* enable_crash_throttling */
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 1197
1227 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, 1198 void Plugin::SetExitStatusOnMainThread(int32_t pp_error,
1228 int exit_status) { 1199 int exit_status) {
1229 DCHECK(pp::Module::Get()->core()->IsMainThread()); 1200 DCHECK(pp::Module::Get()->core()->IsMainThread());
1230 DCHECK(nacl_interface_); 1201 DCHECK(nacl_interface_);
1231 nacl_interface_->SetExitStatus(pp_instance(), exit_status); 1202 nacl_interface_->SetExitStatus(pp_instance(), exit_status);
1232 } 1203 }
1233 1204
1234 1205
1235 } // namespace plugin 1206 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/generators/test_cgen_range/versions.idl ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698