OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 CHROMECAST_GRAPHICS_CAST_VSYNC_SETTINGS_H_ | |
6 #define CHROMECAST_GRAPHICS_CAST_VSYNC_SETTINGS_H_ | |
7 | |
8 #include "base/lazy_instance.h" | |
9 #include "base/macros.h" | |
10 #include "base/observer_list.h" | |
11 #include "base/time/time.h" | |
12 | |
13 namespace chromecast { | |
14 | |
15 // Provides a central place to manage VSync interval, supports observers | |
16 // to be notified of changes. | |
17 // TODO(halliwell): plumb this via Ozone or ui::Display instead. | |
18 class CastVSyncSettings { | |
19 public: | |
20 class Observer { | |
21 public: | |
22 virtual ~Observer() {} | |
23 virtual void OnVSyncIntervalChanged(base::TimeDelta interval) = 0; | |
24 }; | |
25 | |
26 static CastVSyncSettings* GetInstance(); | |
27 | |
28 base::TimeDelta GetVSyncInterval() const; | |
29 void SetVSyncInterval(base::TimeDelta interval); | |
30 | |
31 void AddObserver(Observer* observer); | |
32 void RemoveObserver(Observer* observer); | |
33 | |
34 private: | |
35 friend struct base::LazyInstanceTraitsBase<CastVSyncSettings>; | |
36 | |
37 CastVSyncSettings(); | |
38 ~CastVSyncSettings(); | |
39 | |
40 base::TimeDelta interval_; | |
41 base::ObserverList<Observer> observers_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(CastVSyncSettings); | |
44 }; | |
45 | |
46 } // namespace chromecast | |
47 | |
48 #endif // CHROMECAST_GRAPHICS_CAST_VSYNC_SETTINGS_H_ | |
OLD | NEW |