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

Side by Side Diff: chrome/browser/ui/webui/extensions/extensions_ui.cc

Issue 2348383004: [Extensions] Fix crash in chrome://extensions 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" 5 #include "chrome/browser/ui/webui/extensions/extensions_ui.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void DidStartProvisionalLoadForFrame( 49 void DidStartProvisionalLoadForFrame(
50 content::RenderFrameHost* render_frame_host, 50 content::RenderFrameHost* render_frame_host,
51 const GURL& validated_url, 51 const GURL& validated_url,
52 bool is_error_page, 52 bool is_error_page,
53 bool is_iframe_srcdoc) override { 53 bool is_iframe_srcdoc) override {
54 timer_.reset(new base::ElapsedTimer()); 54 timer_.reset(new base::ElapsedTimer());
55 } 55 }
56 56
57 void DocumentLoadedInFrame( 57 void DocumentLoadedInFrame(
58 content::RenderFrameHost* render_frame_host) override { 58 content::RenderFrameHost* render_frame_host) override {
59 if (render_frame_host != web_contents()->GetMainFrame()) 59 if (render_frame_host != web_contents()->GetMainFrame() ||
60 !timer_) { // See comment in DocumentOnLoadCompletedInMainFrame()
60 return; 61 return;
62 }
61 if (is_md_) { 63 if (is_md_) {
62 UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.MD", 64 UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.MD",
63 timer_->Elapsed()); 65 timer_->Elapsed());
64 } else { 66 } else {
65 UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.Uber", 67 UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.Uber",
66 timer_->Elapsed()); 68 timer_->Elapsed());
67 } 69 }
68 } 70 }
69 71
70 void DocumentOnLoadCompletedInMainFrame() override { 72 void DocumentOnLoadCompletedInMainFrame() override {
73 // Sometimes*, DidStartProvisionalLoadForFrame() isn't called before this
74 // or DocumentLoadedInFrame(). Don't log anything in those cases.
75 // *This appears to be for in-page navigations like hash changes.
76 // TODO(devlin): The usefulness of these metrics remains to be seen.
77 if (!timer_)
78 return;
71 if (is_md_) { 79 if (is_md_) {
72 UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.MD", 80 UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.MD",
73 timer_->Elapsed()); 81 timer_->Elapsed());
74 } else { 82 } else {
75 UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.Uber", 83 UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.Uber",
76 timer_->Elapsed()); 84 timer_->Elapsed());
77 } 85 }
86 timer_.reset();
78 } 87 }
79 88
80 void WebContentsDestroyed() override { delete this; } 89 void WebContentsDestroyed() override { delete this; }
81 90
82 private: 91 private:
83 // Whether this is the MD version of the chrome://extensions page. 92 // Whether this is the MD version of the chrome://extensions page.
84 bool is_md_; 93 bool is_md_;
85 94
86 std::unique_ptr<base::ElapsedTimer> timer_; 95 std::unique_ptr<base::ElapsedTimer> timer_;
87 96
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 ExtensionsUI::~ExtensionsUI() {} 329 ExtensionsUI::~ExtensionsUI() {}
321 330
322 // static 331 // static
323 base::RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes( 332 base::RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes(
324 ui::ScaleFactor scale_factor) { 333 ui::ScaleFactor scale_factor) {
325 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 334 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
326 return rb.LoadDataResourceBytesForScale(IDR_EXTENSIONS_FAVICON, scale_factor); 335 return rb.LoadDataResourceBytesForScale(IDR_EXTENSIONS_FAVICON, scale_factor);
327 } 336 }
328 337
329 } // namespace extensions 338 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698