Chromium Code Reviews| Index: chrome/browser/ui/browser_view_histogram_helper.cc |
| diff --git a/chrome/browser/ui/browser_view_histogram_helper.cc b/chrome/browser/ui/browser_view_histogram_helper.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..94861341476f21ac9f5f9854c47a48f462bb6f38 |
| --- /dev/null |
| +++ b/chrome/browser/ui/browser_view_histogram_helper.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/browser_view_histogram_helper.h" |
| + |
| +#include "components/startup_metric_utils/browser/startup_metric_utils.h" |
| +#include "ui/compositor/compositor.h" |
| + |
| +BrowserViewHistogramHelper::BrowserViewHistogramHelper() |
| + : scoped_observer_(this) {} |
| + |
| +BrowserViewHistogramHelper::~BrowserViewHistogramHelper() { |
| + RemoveCompositorObserver(); |
|
sky
2017/04/11 17:13:36
Doesn't ~ScopedObserver take care of this for you?
themblsha
2017/04/12 17:18:28
Correct. Removed the call but the destructor still
|
| +} |
| + |
| +void BrowserViewHistogramHelper::OnDidPaintChildren( |
| + ui::Compositor* compositor) { |
| + if (!did_first_paint_) { |
|
sky
2017/04/11 17:13:36
Early out rather than big conditional.
themblsha
2017/04/12 17:18:28
Done.
|
| + did_first_paint_ = true; |
| + |
| + startup_metric_utils::RecordBrowserViewFirstPaint(base::TimeTicks::Now()); |
| + |
| +#if defined(OS_MACOSX) |
| + if (!compositor) { |
| + // In Cocoa version of Chromium UI is rendered inside the main process |
| + // using CoreAnimation compositor, and at this point everything is already |
| + // visible to the user. |
| + startup_metric_utils::RecordBrowserViewFirstPaintCompositingEnded( |
| + base::TimeTicks::Now()); |
| + return; |
| + } |
| +#endif // OS_MACOSX |
| + |
| + scoped_observer_.Add(compositor); |
| + } |
| +} |
| + |
| +void BrowserViewHistogramHelper::RemoveCompositorObserver() { |
| + scoped_observer_.RemoveAll(); |
| +} |
| + |
| +// OnCompositingEnded was removed crbug.com/671202, this is the next best thing. |
| +void BrowserViewHistogramHelper::OnCompositingStarted( |
| + ui::Compositor* compositor, |
| + base::TimeTicks start_time) { |
| + startup_metric_utils::RecordBrowserViewFirstPaintCompositingEnded( |
| + base::TimeTicks::Now()); |
| + |
| + RemoveCompositorObserver(); |
| +} |
| + |
| +void BrowserViewHistogramHelper::OnCompositingShuttingDown( |
| + ui::Compositor* compositor) { |
| + RemoveCompositorObserver(); |
| +} |