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

Unified Diff: components/nacl/renderer/nexe_load_manager.cc

Issue 231243002: PPAPI: Move some of NexeFileDidOpen to NexeLoadManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: components/nacl/renderer/nexe_load_manager.cc
diff --git a/components/nacl/renderer/nexe_load_manager.cc b/components/nacl/renderer/nexe_load_manager.cc
index e01627b2c79c90a11731e7407ba726e9328eff4e..536b622d4b87a132552cfa036ebe372eb50e9b1a 100644
--- a/components/nacl/renderer/nexe_load_manager.cc
+++ b/components/nacl/renderer/nexe_load_manager.cc
@@ -40,6 +40,24 @@
namespace {
+void HistogramCustomCounts(const std::string& name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count) {
+ base::HistogramBase* counter =
+ base::Histogram::FactoryGet(
+ name,
+ min,
+ max,
+ bucket_count,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ // The histogram can be NULL if it is constructed with bad arguments. Ignore
+ // that data for this API. An error message will be logged.
+ if (counter)
+ counter->Add(sample);
+}
+
void HistogramEnumerate(const std::string& name,
int32_t sample,
int32_t boundary_value) {
@@ -135,6 +153,27 @@ void HistogramStartupTimeMedium(const std::string& name,
}
}
+void HistogramSizeKB(const std::string& name, int32_t sample) {
+ if (sample < 0) return;
+ HistogramCustomCounts(name,
+ sample,
+ 1,
+ 512 * 1024, // A very large .nexe.
+ 100);
+}
+
+void HistogramHTTPStatusCode(const std::string& name,
+ int32_t status) {
+ // Log the status codes in rough buckets - 1XX, 2XX, etc.
+ int sample = status / 100;
+ // HTTP status codes only go up to 5XX, using "6" to indicate an internal
+ // error.
+ // Note: installed files may have "0" for a status code.
+ if (status < 0 || status >= 600)
+ sample = 6;
+ HistogramEnumerate(name, sample, 7);
+}
+
blink::WebString EventTypeToString(PP_NaClEventType event_type) {
switch (event_type) {
case PP_NACL_EVENT_LOADSTART:
@@ -191,6 +230,51 @@ NexeLoadManager::~NexeLoadManager() {
}
}
+void NexeLoadManager::NexeFileDidOpen(int32_t pp_error,
+ int32_t fd,
+ int32_t http_status,
+ int64_t nexe_bytes_read,
+ const std::string& url) {
+ VLOG(1) << "Plugin::NexeFileDidOpen (pp_error=" << pp_error << ")";
+ VLOG(1) << "Plugin::NexeFileDidOpen (file_desc=" << fd << ")";
+ HistogramHTTPStatusCode(
+ is_installed_ ? "NaCl.HttpStatusCodeClass.Nexe.InstalledApp" :
+ "NaCl.HttpStatusCodeClass.Nexe.NotInstalledApp",
+ http_status);
+ // TODO(dmichael): fd is only used for error reporting here currently, and
+ // the trusted Plugin is responsible for using it and closing it.
+ // Note -1 is NACL_NO_FILE_DESC from nacl_macros.h.
+ if (pp_error != PP_OK || fd == -1) {
+ if (pp_error == PP_ERROR_ABORTED) {
+ ReportLoadAbort();
+ } else if (pp_error == PP_ERROR_NOACCESS) {
+ ReportLoadError(PP_NACL_ERROR_NEXE_NOACCESS_URL,
+ "access to nexe url was denied.");
+ } else {
+ ReportLoadError(PP_NACL_ERROR_NEXE_LOAD_URL,
+ "could not load nexe url.");
+ }
+ return;
+ } else if (nexe_bytes_read == -1) {
+ ReportLoadError(PP_NACL_ERROR_NEXE_STAT, "could not stat nexe file.");
+ return;
+ }
+
+ // TODO(dmichael): Can we avoid stashing away so much state?
+ nexe_size_ = nexe_bytes_read;
+ HistogramSizeKB("NaCl.Perf.Size.Nexe",
+ static_cast<int32_t>(nexe_size_ / 1024));
+
+ // Inform JavaScript that we successfully downloaded the nacl module.
+ ProgressEvent progress_event(pp_instance_, PP_NACL_EVENT_PROGRESS, url, true,
+ nexe_size_, nexe_size_);
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(&NexeLoadManager::DispatchEvent,
+ weak_factory_.GetWeakPtr(),
+ progress_event));
+}
+
void NexeLoadManager::ReportLoadSuccess(const std::string& url,
uint64_t loaded_bytes,
uint64_t total_bytes) {

Powered by Google App Engine
This is Rietveld 408576698