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 #ifndef CHROME_BROWSER_METRICS_BROWSER_WINDOW_HISTOGRAM_HELPER_H_ |
| 6 #define CHROME_BROWSER_METRICS_BROWSER_WINDOW_HISTOGRAM_HELPER_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/scoped_observer.h" |
| 12 #include "base/time/time.h" |
| 13 #include "ui/compositor/compositor_observer.h" |
| 14 |
| 15 // Class that encapsulates logic of recording |
| 16 // Startup.BrowserWindow.FirstPaint* histograms. |
| 17 // |
| 18 // There's a dependency on ui/compositor therefore it can't be moved to |
| 19 // components/startup_metrics_utils. |
| 20 class BrowserWindowHistogramHelper : public ui::CompositorObserver { |
| 21 public: |
| 22 ~BrowserWindowHistogramHelper() override; |
| 23 |
| 24 // Call this when the Browser finishes painting its UI, and the user will see |
| 25 // it after next Compositor frame swap. |
| 26 // |compositor| is the compositor that composites the just-painted Browser |
| 27 // widget, or nullptr in Cocoa (we're using CoreAnimation's compositor there). |
| 28 // Returned object should stay alive until next |OnCompositingStarted| |
| 29 // callback. |
| 30 static std::unique_ptr<BrowserWindowHistogramHelper> |
| 31 MaybeRecordValueAndCreateInstanceOnBrowserPaint(ui::Compositor* compositor); |
| 32 |
| 33 private: |
| 34 explicit BrowserWindowHistogramHelper(ui::Compositor* compositor); |
| 35 |
| 36 // ui::CompositorObserver: |
| 37 void OnCompositingDidCommit(ui::Compositor* compositor) override {} |
| 38 void OnCompositingStarted(ui::Compositor* compositor, |
| 39 base::TimeTicks start_time) override {} |
| 40 void OnCompositingEnded(ui::Compositor* compositor) override; |
| 41 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} |
| 42 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
| 43 |
| 44 ScopedObserver<ui::Compositor, ui::CompositorObserver> scoped_observer_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(BrowserWindowHistogramHelper); |
| 47 }; |
| 48 |
| 49 #endif // CHROME_BROWSER_METRICS_BROWSER_WINDOW_HISTOGRAM_HELPER_H_ |
OLD | NEW |