diff options
author | xhwang <xhwang@chromium.org> | 2015-07-16 19:31:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-17 02:32:13 +0000 |
commit | a5d19ad9039479d0446b6a63bf32f8ae9fdbcad1 (patch) | |
tree | 83f626eb7acd146f6e3825c28b0f8c4e6796024c /content/ppapi_plugin | |
parent | d6486a6280378ac0f858c1027e6c389ab6a342c6 (diff) | |
download | chromium_src-a5d19ad9039479d0446b6a63bf32f8ae9fdbcad1.zip chromium_src-a5d19ad9039479d0446b6a63bf32f8ae9fdbcad1.tar.gz chromium_src-a5d19ad9039479d0446b6a63bf32f8ae9fdbcad1.tar.bz2 |
Add UMA for ppapi plugin load time.
BUG=510234
TEST=Manually tested and verified in about://histograms.
Review URL: https://codereview.chromium.org/1235393007
Cr-Commit-Position: refs/heads/master@{#339203}
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 45 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.h | 4 |
2 files changed, 38 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 diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h index 730af85..ed09b1f 100644 --- a/content/ppapi_plugin/ppapi_thread.h +++ b/content/ppapi_plugin/ppapi_thread.h @@ -124,6 +124,10 @@ class PpapiThread : public ChildThreadImpl, void ReportLoadErrorCode(const base::FilePath& path, const base::NativeLibraryLoadError& error); + // Reports time to load the plugin. + void ReportLoadTime(const base::FilePath& path, + const base::TimeDelta load_time); + // True if running in a broker process rather than a normal plugin process. bool is_broker_; |