Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/metrics/browser_window_histogram_helper.h" | |
| 6 | |
| 7 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | |
| 8 #include "ui/compositor/compositor.h" | |
| 9 | |
| 10 BrowserWindowHistogramHelper::BrowserWindowHistogramHelper( | |
| 11 ui::Compositor* compositor) | |
| 12 : scoped_observer_(this) { | |
| 13 startup_metric_utils::RecordBrowserWindowFirstPaint(base::TimeTicks::Now()); | |
| 14 | |
| 15 #if defined(OS_MACOSX) | |
| 16 if (!compositor) { | |
| 17 // In Cocoa version of Chromium UI is rendered inside the main process using | |
|
Alexei Svitkine (slow)
2017/04/18 16:01:31
Nit: Add a , after Chromium
themblsha
2017/04/19 15:06:09
Done.
| |
| 18 // CoreAnimation compositor, and at this point everything is already visible | |
| 19 // to the user. | |
| 20 startup_metric_utils::RecordBrowserWindowFirstPaintCompositingEnded( | |
| 21 base::TimeTicks::Now()); | |
| 22 return; | |
| 23 } | |
| 24 #endif // OS_MACOSX | |
| 25 | |
| 26 scoped_observer_.Add(compositor); | |
| 27 } | |
| 28 | |
| 29 BrowserWindowHistogramHelper::~BrowserWindowHistogramHelper() {} | |
| 30 | |
| 31 // static | |
| 32 std::unique_ptr<BrowserWindowHistogramHelper> | |
| 33 BrowserWindowHistogramHelper::OnBrowserPainted(ui::Compositor* compositor) { | |
|
Alexei Svitkine (slow)
2017/04/18 16:01:31
Can this be named in some way that makes it clear
themblsha
2017/04/19 15:06:09
Done.
| |
| 34 static bool did_first_paint = false; | |
| 35 if (did_first_paint) | |
| 36 return std::unique_ptr<BrowserWindowHistogramHelper>(); | |
| 37 | |
| 38 did_first_paint = true; | |
| 39 | |
| 40 return std::unique_ptr<BrowserWindowHistogramHelper>( | |
|
Alexei Svitkine (slow)
2017/04/18 16:01:32
Nit: MakeUnique
themblsha
2017/04/19 15:06:09
I was unable to make it work with private construc
| |
| 41 new BrowserWindowHistogramHelper(compositor)); | |
| 42 } | |
| 43 | |
| 44 // OnCompositingEnded was removed crbug.com/671202, this is the next best thing. | |
| 45 void BrowserWindowHistogramHelper::OnCompositingStarted( | |
| 46 ui::Compositor* compositor, | |
| 47 base::TimeTicks start_time) { | |
| 48 startup_metric_utils::RecordBrowserWindowFirstPaintCompositingEnded( | |
| 49 base::TimeTicks::Now()); | |
| 50 | |
| 51 scoped_observer_.RemoveAll(); | |
| 52 } | |
| 53 | |
| 54 void BrowserWindowHistogramHelper::OnCompositingShuttingDown( | |
| 55 ui::Compositor* compositor) { | |
| 56 scoped_observer_.RemoveAll(); | |
| 57 } | |
| OLD | NEW |