OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_WM_VIDEO_DETECTOR_H_ | 5 #ifndef ASH_WM_VIDEO_DETECTOR_H_ |
6 #define ASH_WM_VIDEO_DETECTOR_H_ | 6 #define ASH_WM_VIDEO_DETECTOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 | 11 |
11 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
12 #include "ash/common/shell_observer.h" | 13 #include "ash/common/shell_observer.h" |
13 #include "ash/common/wm_window_observer.h" | 14 #include "ash/common/wm_window_observer.h" |
14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/linked_ptr.h" | |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/scoped_observer.h" | 18 #include "base/scoped_observer.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
21 #include "ui/aura/env_observer.h" | 21 #include "ui/aura/env_observer.h" |
22 #include "ui/aura/window_observer.h" | 22 #include "ui/aura/window_observer.h" |
23 | 23 |
24 namespace aura { | 24 namespace aura { |
25 class Window; | 25 class Window; |
26 } | 26 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // ShellObserver overrides. | 102 // ShellObserver overrides. |
103 void OnAppTerminating() override; | 103 void OnAppTerminating() override; |
104 void OnFullscreenStateChanged(bool is_fullscreen, | 104 void OnFullscreenStateChanged(bool is_fullscreen, |
105 WmWindow* root_window) override; | 105 WmWindow* root_window) override; |
106 | 106 |
107 // WmWindowObserver overrides. | 107 // WmWindowObserver overrides. |
108 void OnWindowDestroyed(WmWindow* window) override {} | 108 void OnWindowDestroyed(WmWindow* window) override {} |
109 void OnWindowDestroying(WmWindow* window) override; | 109 void OnWindowDestroying(WmWindow* window) override; |
110 | 110 |
111 private: | 111 private: |
112 class WindowInfo; | |
113 typedef std::map<aura::Window*, linked_ptr<WindowInfo>> WindowInfoMap; | |
114 | |
115 // Called when video activity is observed in |window|. | 112 // Called when video activity is observed in |window|. |
116 void HandleVideoActivity(aura::Window* window, base::TimeTicks now); | 113 void HandleVideoActivity(aura::Window* window, base::TimeTicks now); |
117 | 114 |
118 // Called by |inactive_timer_| |kVideoTimeoutMs| after the last-observed video | 115 // Called by |inactive_timer_| |kVideoTimeoutMs| after the last-observed video |
119 // activity. | 116 // activity. |
120 void HandleVideoInactive(); | 117 void HandleVideoInactive(); |
121 | 118 |
122 // Updates |state_| and notifies |observers_| if it changed. | 119 // Updates |state_| and notifies |observers_| if it changed. |
123 void UpdateState(); | 120 void UpdateState(); |
124 | 121 |
125 // Current playback state. | 122 // Current playback state. |
126 State state_; | 123 State state_; |
127 | 124 |
128 // True if video has been observed in the last |kVideoTimeoutMs|. | 125 // True if video has been observed in the last |kVideoTimeoutMs|. |
129 bool video_is_playing_; | 126 bool video_is_playing_; |
130 | 127 |
131 // Currently-fullscreen root windows. | 128 // Currently-fullscreen root windows. |
132 std::set<WmWindow*> fullscreen_root_windows_; | 129 std::set<WmWindow*> fullscreen_root_windows_; |
133 | 130 |
134 // Maps from a window that we're tracking to information about it. | 131 // Maps from a window that we're tracking to information about it. |
| 132 class WindowInfo; |
| 133 using WindowInfoMap = std::map<aura::Window*, std::unique_ptr<WindowInfo>>; |
135 WindowInfoMap window_infos_; | 134 WindowInfoMap window_infos_; |
136 | 135 |
137 base::ObserverList<Observer> observers_; | 136 base::ObserverList<Observer> observers_; |
138 | 137 |
139 // Calls HandleVideoInactive(). | 138 // Calls HandleVideoInactive(). |
140 base::OneShotTimer video_inactive_timer_; | 139 base::OneShotTimer video_inactive_timer_; |
141 | 140 |
142 // If set, used when the current time is needed. This can be set by tests to | 141 // If set, used when the current time is needed. This can be set by tests to |
143 // simulate the passage of time. | 142 // simulate the passage of time. |
144 base::TimeTicks now_for_test_; | 143 base::TimeTicks now_for_test_; |
145 | 144 |
146 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_manager_; | 145 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_manager_; |
147 ScopedObserver<WmWindow, WmWindowObserver> wm_window_observer_manager_; | 146 ScopedObserver<WmWindow, WmWindowObserver> wm_window_observer_manager_; |
148 | 147 |
149 bool is_shutting_down_; | 148 bool is_shutting_down_; |
150 | 149 |
151 DISALLOW_COPY_AND_ASSIGN(VideoDetector); | 150 DISALLOW_COPY_AND_ASSIGN(VideoDetector); |
152 }; | 151 }; |
153 | 152 |
154 } // namespace ash | 153 } // namespace ash |
155 | 154 |
156 #endif // ASH_WM_VIDEO_DETECTOR_H_ | 155 #endif // ASH_WM_VIDEO_DETECTOR_H_ |
OLD | NEW |