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/ui/browser_view_histogram_helper.h" | |
6 | |
7 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | |
8 #include "ui/compositor/compositor.h" | |
9 | |
10 BrowserViewHistogramHelper::BrowserViewHistogramHelper() | |
11 : scoped_observer_(this) {} | |
12 | |
13 BrowserViewHistogramHelper::~BrowserViewHistogramHelper() { | |
14 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
| |
15 } | |
16 | |
17 void BrowserViewHistogramHelper::OnDidPaintChildren( | |
18 ui::Compositor* compositor) { | |
19 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.
| |
20 did_first_paint_ = true; | |
21 | |
22 startup_metric_utils::RecordBrowserViewFirstPaint(base::TimeTicks::Now()); | |
23 | |
24 #if defined(OS_MACOSX) | |
25 if (!compositor) { | |
26 // In Cocoa version of Chromium UI is rendered inside the main process | |
27 // using CoreAnimation compositor, and at this point everything is already | |
28 // visible to the user. | |
29 startup_metric_utils::RecordBrowserViewFirstPaintCompositingEnded( | |
30 base::TimeTicks::Now()); | |
31 return; | |
32 } | |
33 #endif // OS_MACOSX | |
34 | |
35 scoped_observer_.Add(compositor); | |
36 } | |
37 } | |
38 | |
39 void BrowserViewHistogramHelper::RemoveCompositorObserver() { | |
40 scoped_observer_.RemoveAll(); | |
41 } | |
42 | |
43 // OnCompositingEnded was removed crbug.com/671202, this is the next best thing. | |
44 void BrowserViewHistogramHelper::OnCompositingStarted( | |
45 ui::Compositor* compositor, | |
46 base::TimeTicks start_time) { | |
47 startup_metric_utils::RecordBrowserViewFirstPaintCompositingEnded( | |
48 base::TimeTicks::Now()); | |
49 | |
50 RemoveCompositorObserver(); | |
51 } | |
52 | |
53 void BrowserViewHistogramHelper::OnCompositingShuttingDown( | |
54 ui::Compositor* compositor) { | |
55 RemoveCompositorObserver(); | |
56 } | |
OLD | NEW |