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

Unified Diff: chrome/browser/metrics/first_web_contents_profiler.cc

Issue 1415773004: Refactor ownership model for FirstWebContentsProfiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a1_more_abandons_and_umabandons
Patch Set: rebase on leak fix (https://codereview.chromium.org/1449933002) Created 5 years, 1 month 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 | « chrome/browser/metrics/first_web_contents_profiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/first_web_contents_profiler.cc
diff --git a/chrome/browser/metrics/first_web_contents_profiler.cc b/chrome/browser/metrics/first_web_contents_profiler.cc
index 8efb2c878c499f6e52390e9a45ca049e2420b427..72d47f98384877cce0de6ddbf17aee806f8f20f4 100644
--- a/chrome/browser/metrics/first_web_contents_profiler.cc
+++ b/chrome/browser/metrics/first_web_contents_profiler.cc
@@ -20,32 +20,29 @@
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
#include "content/public/browser/navigation_handle.h"
-scoped_ptr<FirstWebContentsProfiler>
-FirstWebContentsProfiler::CreateProfilerForFirstWebContents(
- Delegate* delegate) {
- DCHECK(delegate);
- for (chrome::BrowserIterator iterator; !iterator.done(); iterator.Next()) {
- Browser* browser = *iterator;
+// static
+void FirstWebContentsProfiler::Start() {
+ for (chrome::BrowserIterator browser_it; !browser_it.done();
+ browser_it.Next()) {
content::WebContents* web_contents =
- browser->tab_strip_model()->GetActiveWebContents();
+ browser_it->tab_strip_model()->GetActiveWebContents();
if (web_contents) {
- return scoped_ptr<FirstWebContentsProfiler>(
- new FirstWebContentsProfiler(web_contents, delegate));
+ // FirstWebContentsProfiler owns itself and is also bound to
+ // |web_contents|'s lifetime by observing WebContentsDestroyed().
+ new FirstWebContentsProfiler(web_contents);
+ return;
}
}
- return nullptr;
}
FirstWebContentsProfiler::FirstWebContentsProfiler(
- content::WebContents* web_contents,
- Delegate* delegate)
+ content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
collected_paint_metric_(false),
collected_load_metric_(false),
collected_main_navigation_start_metric_(false),
collected_main_navigation_finished_metric_(false),
- finished_(false),
- delegate_(delegate) {}
+ finished_(false) {}
void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() {
if (collected_paint_metric_)
@@ -177,7 +174,7 @@ void FirstWebContentsProfiler::FinishedCollectingMetrics(
if (IsFinishedCollectingMetrics() ||
finish_reason == FinishReason::ABANDON_CONTENT_DESTROYED ||
finish_reason == FinishReason::ABANDON_BLOCKING_UI) {
- delegate_->ProfilerFinishedCollectingMetrics();
+ delete this;
}
}
« no previous file with comments | « chrome/browser/metrics/first_web_contents_profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698