diff options
Diffstat (limited to 'content/ppapi_plugin/ppapi_thread.cc')
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index 3b88a8e..d220244 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -308,11 +308,16 @@ void PpapiThread::OnLoadPlugin(const base::FilePath& path, if (plugin_entry_points_.initialize_module == NULL) { // Load the plugin from the specified library. base::NativeLibraryLoadError error; + base::TimeDelta load_time; { TRACE_EVENT1("ppapi", "PpapiThread::LoadPlugin", "path", path.MaybeAsASCII()); + + base::TimeTicks start = base::TimeTicks::Now(); library.Reset(base::LoadNativeLibrary(path, &error)); + load_time = base::TimeTicks::Now() - start; } + if (!library.is_valid()) { LOG(ERROR) << "Failed to load Pepper module from " << path.value() << " (error: " << error.ToString() << ")"; @@ -326,6 +331,9 @@ void PpapiThread::OnLoadPlugin(const base::FilePath& path, return; } + // Only report load time for success loads. + ReportLoadTime(path, load_time); + // Get the GetInterface function (required). plugin_entry_points_.get_interface = reinterpret_cast<PP_GetInterface_Func>( @@ -556,17 +564,21 @@ void PpapiThread::SavePluginName(const base::FilePath& path) { } } +static std::string GetHistogramName(bool is_broker, + const std::string& metric_name, + const base::FilePath& path) { + return std::string("Plugin.Ppapi") + (is_broker ? "Broker" : "Plugin") + + metric_name + "_" + path.BaseName().MaybeAsASCII(); +} + void PpapiThread::ReportLoadResult(const base::FilePath& path, LoadResult result) { DCHECK_LT(result, LOAD_RESULT_MAX); - std::string histogram_name = std::string("Plugin.Ppapi") + - (is_broker_ ? "Broker" : "Plugin") + - "LoadResult_" + path.BaseName().MaybeAsASCII(); // Note: This leaks memory, which is expected behavior. base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( - histogram_name, + GetHistogramName(is_broker_, "LoadResult", path), 1, LOAD_RESULT_MAX, LOAD_RESULT_MAX + 1, @@ -578,17 +590,28 @@ void PpapiThread::ReportLoadResult(const base::FilePath& path, void PpapiThread::ReportLoadErrorCode( const base::FilePath& path, const base::NativeLibraryLoadError& error) { +// Only report load error code on Windows because that's the only platform that +// has a numerical error value. #if defined(OS_WIN) - // Only report load error code on Windows because that's the only platform - // that has a numerical error value. - std::string histogram_name = - std::string("Plugin.Ppapi") + (is_broker_ ? "Broker" : "Plugin") + - "LoadErrorCode_" + path.BaseName().MaybeAsASCII(); - // For sparse histograms, we can use the macro, as it does not incorporate a // static. - UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name, error.code); + UMA_HISTOGRAM_SPARSE_SLOWLY( + GetHistogramName(is_broker_, "LoadErrorCode", path), error.code); #endif } +void PpapiThread::ReportLoadTime(const base::FilePath& path, + const base::TimeDelta load_time) { + // Note: This leaks memory, which is expected behavior. + base::HistogramBase* histogram = + base::Histogram::FactoryTimeGet( + GetHistogramName(is_broker_, "LoadTime", path), + base::TimeDelta::FromMilliseconds(1), + base::TimeDelta::FromSeconds(10), + 50, + base::HistogramBase::kUmaTargetedHistogramFlag); + + histogram->AddTime(load_time); +} + } // namespace content |