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

Unified Diff: chrome/browser/ui/webui/extensions/extensions_ui.cc

Issue 2341553002: [MD Extensions] Add some performance metrics (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/extensions/extensions_ui.cc
diff --git a/chrome/browser/ui/webui/extensions/extensions_ui.cc b/chrome/browser/ui/webui/extensions/extensions_ui.cc
index d9a7e937311636003a7403786712b0fa74416864..71fffdc2b79ef5477e70a6782502513ba9c48977 100644
--- a/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/ui/webui/extensions/extensions_ui.h"
Dan Beam 2016/09/13 23:40:13 nit: #include <memory> for std::unique_ptr
Devlin 2016/09/14 00:33:48 Done.
+#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/timer/elapsed_timer.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
@@ -19,6 +21,8 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.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_data_source.h"
#include "extensions/common/extension_urls.h"
@@ -34,6 +38,54 @@ namespace extensions {
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());
Dan Beam 2016/09/13 23:40:13 i assume this captures reloads correctly?
Devlin 2016/09/14 00:33:48 Yep, it seems to. FWIW, this is also what setting
+ }
+
+ 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* source =
content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost);
@@ -216,7 +268,10 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource* source = nullptr;
- if (base::FeatureList::IsEnabled(features::kMaterialDesignExtensions)) {
+ bool is_md =
+ base::FeatureList::IsEnabled(features::kMaterialDesignExtensions);
+
+ if (is_md) {
source = CreateMdExtensionsSource();
InstallExtensionHandler* install_extension_handler =
new InstallExtensionHandler();
@@ -256,6 +311,8 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
}
content::WebUIDataSource::Add(profile, source);
+ // Handles its own lifetime.
+ new ExtensionWebUiTimer(web_ui->GetWebContents(), is_md);
}
ExtensionsUI::~ExtensionsUI() {}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698