Commit de40667e authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[MD Extensions] Add some performance metrics

Add some performance metrics for the MD and non-MD extensions pages so
we can begin gathering data. To start, use the signals for
DocumentLoadedInFrame() for the main frame and
DocumentOnLoadCompletedInMainFrame().

BUG=529395

Review-Url: https://codereview.chromium.org/2341553002
Cr-Commit-Position: refs/heads/master@{#418692}
parent cdf40b4b
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
#include "chrome/browser/ui/webui/extensions/extensions_ui.h" #include "chrome/browser/ui/webui/extensions/extensions_ui.h"
#include <memory>
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/timer/elapsed_timer.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -19,6 +23,8 @@ ...@@ -19,6 +23,8 @@
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h" #include "chrome/grit/theme_resources.h"
#include "components/google/core/browser/google_util.h" #include "components/google/core/browser/google_util.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "extensions/common/extension_urls.h" #include "extensions/common/extension_urls.h"
...@@ -34,6 +40,54 @@ namespace extensions { ...@@ -34,6 +40,54 @@ namespace extensions {
namespace { namespace {
class ExtensionWebUiTimer : public content::WebContentsObserver {
public:
explicit ExtensionWebUiTimer(content::WebContents* web_contents, bool is_md)
: content::WebContentsObserver(web_contents), is_md_(is_md) {}
~ExtensionWebUiTimer() override {}
void DidStartProvisionalLoadForFrame(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
bool is_error_page,
bool is_iframe_srcdoc) override {
timer_.reset(new base::ElapsedTimer());
}
void DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) override {
if (render_frame_host != web_contents()->GetMainFrame())
return;
if (is_md_) {
UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.MD",
timer_->Elapsed());
} else {
UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.Uber",
timer_->Elapsed());
}
}
void DocumentOnLoadCompletedInMainFrame() override {
if (is_md_) {
UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.MD",
timer_->Elapsed());
} else {
UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.Uber",
timer_->Elapsed());
}
}
void WebContentsDestroyed() override { delete this; }
private:
// Whether this is the MD version of the chrome://extensions page.
bool is_md_;
std::unique_ptr<base::ElapsedTimer> timer_;
DISALLOW_COPY_AND_ASSIGN(ExtensionWebUiTimer);
};
content::WebUIDataSource* CreateMdExtensionsSource() { content::WebUIDataSource* CreateMdExtensionsSource() {
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost); content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost);
...@@ -216,7 +270,10 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) { ...@@ -216,7 +270,10 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui); Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource* source = nullptr; content::WebUIDataSource* source = nullptr;
if (base::FeatureList::IsEnabled(features::kMaterialDesignExtensions)) { bool is_md =
base::FeatureList::IsEnabled(features::kMaterialDesignExtensions);
if (is_md) {
source = CreateMdExtensionsSource(); source = CreateMdExtensionsSource();
InstallExtensionHandler* install_extension_handler = InstallExtensionHandler* install_extension_handler =
new InstallExtensionHandler(); new InstallExtensionHandler();
...@@ -256,6 +313,8 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) { ...@@ -256,6 +313,8 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
} }
content::WebUIDataSource::Add(profile, source); content::WebUIDataSource::Add(profile, source);
// Handles its own lifetime.
new ExtensionWebUiTimer(web_ui->GetWebContents(), is_md);
} }
ExtensionsUI::~ExtensionsUI() {} ExtensionsUI::~ExtensionsUI() {}
......
...@@ -16938,6 +16938,25 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -16938,6 +16938,25 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Extensions.WebUi.DocumentLoadedInMainFrameTime" units="ms">
<owner>rdevlin.cronin@chromium.org</owner>
<summary>
The amount of time between starting the provisional load and fully loading
the document in the main frame of the chrome://extensions page. This
corresponds to the WebContentsObserver::DocumentLoadedInFrame method.
</summary>
</histogram>
<histogram name="Extensions.WebUi.LoadCompletedInMainFrame" units="ms">
<owner>rdevlin.cronin@chromium.org</owner>
<summary>
The amount of time between starting the provisional load and having
completed the onload handler in the main frame of the chrome://extensions
page. This corresponds to the
WebContentsObserver::DocumentOnLoadCompletedInMainFrame method.
</summary>
</histogram>
<histogram name="ExtensionService.AddVerified" enum="BooleanSuccess"> <histogram name="ExtensionService.AddVerified" enum="BooleanSuccess">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary> <summary>
...@@ -101250,6 +101269,13 @@ To add a new entry, add it with any value and run test to compute valid value. ...@@ -101250,6 +101269,13 @@ To add a new entry, add it with any value and run test to compute valid value.
<affected-histogram name="Extensions.Database.Restore"/> <affected-histogram name="Extensions.Database.Restore"/>
</histogram_suffixes> </histogram_suffixes>
<histogram_suffixes name="ExtensionWebUiPageType" separator=".">
<suffix name="MD" label="The Material Design chrome://extensions page."/>
<suffix name="Uber" label="The Uber chrome://extensions page."/>
<affected-histogram name="Extensions.WebUi.DocumentLoadedInMainFrameTime"/>
<affected-histogram name="Extensions.WebUi.LoadCompletedInMainFrame"/>
</histogram_suffixes>
<histogram_suffixes name="ExternalExtensionEvent" separator=""> <histogram_suffixes name="ExternalExtensionEvent" separator="">
<suffix name="NonWebstore" <suffix name="NonWebstore"
label="sideloaded extensions that don't update from the webstore"/> label="sideloaded extensions that don't update from the webstore"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment