Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: ash/wm/video_detector.h

Issue 2472183003: Remove linked_ptr from ash (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 9 #include <set>
oshima 2016/11/04 18:31:43 include memory
limasdf 2016/11/05 06:12:57 Done.
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/common/shell_observer.h" 12 #include "ash/common/shell_observer.h"
13 #include "ash/common/wm_window_observer.h" 13 #include "ash/common/wm_window_observer.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/linked_ptr.h"
17 #include "base/observer_list.h" 16 #include "base/observer_list.h"
18 #include "base/scoped_observer.h" 17 #include "base/scoped_observer.h"
19 #include "base/time/time.h" 18 #include "base/time/time.h"
20 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
21 #include "ui/aura/env_observer.h" 20 #include "ui/aura/env_observer.h"
22 #include "ui/aura/window_observer.h" 21 #include "ui/aura/window_observer.h"
23 22
24 namespace aura { 23 namespace aura {
25 class Window; 24 class Window;
26 } 25 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // ShellObserver overrides. 101 // ShellObserver overrides.
103 void OnAppTerminating() override; 102 void OnAppTerminating() override;
104 void OnFullscreenStateChanged(bool is_fullscreen, 103 void OnFullscreenStateChanged(bool is_fullscreen,
105 WmWindow* root_window) override; 104 WmWindow* root_window) override;
106 105
107 // WmWindowObserver overrides. 106 // WmWindowObserver overrides.
108 void OnWindowDestroyed(WmWindow* window) override {} 107 void OnWindowDestroyed(WmWindow* window) override {}
109 void OnWindowDestroying(WmWindow* window) override; 108 void OnWindowDestroying(WmWindow* window) override;
110 109
111 private: 110 private:
112 class WindowInfo;
113 typedef std::map<aura::Window*, linked_ptr<WindowInfo>> WindowInfoMap;
114
115 // Called when video activity is observed in |window|. 111 // Called when video activity is observed in |window|.
116 void HandleVideoActivity(aura::Window* window, base::TimeTicks now); 112 void HandleVideoActivity(aura::Window* window, base::TimeTicks now);
117 113
118 // Called by |inactive_timer_| |kVideoTimeoutMs| after the last-observed video 114 // Called by |inactive_timer_| |kVideoTimeoutMs| after the last-observed video
119 // activity. 115 // activity.
120 void HandleVideoInactive(); 116 void HandleVideoInactive();
121 117
122 // Updates |state_| and notifies |observers_| if it changed. 118 // Updates |state_| and notifies |observers_| if it changed.
123 void UpdateState(); 119 void UpdateState();
124 120
125 // Current playback state. 121 // Current playback state.
126 State state_; 122 State state_;
127 123
128 // True if video has been observed in the last |kVideoTimeoutMs|. 124 // True if video has been observed in the last |kVideoTimeoutMs|.
129 bool video_is_playing_; 125 bool video_is_playing_;
130 126
131 // Currently-fullscreen root windows. 127 // Currently-fullscreen root windows.
132 std::set<WmWindow*> fullscreen_root_windows_; 128 std::set<WmWindow*> fullscreen_root_windows_;
133 129
134 // Maps from a window that we're tracking to information about it. 130 // Maps from a window that we're tracking to information about it.
131 class WindowInfo;
132 using WindowInfoMap = std::map<aura::Window*, std::unique_ptr<WindowInfo>>;
135 WindowInfoMap window_infos_; 133 WindowInfoMap window_infos_;
136 134
137 base::ObserverList<Observer> observers_; 135 base::ObserverList<Observer> observers_;
138 136
139 // Calls HandleVideoInactive(). 137 // Calls HandleVideoInactive().
140 base::OneShotTimer video_inactive_timer_; 138 base::OneShotTimer video_inactive_timer_;
141 139
142 // If set, used when the current time is needed. This can be set by tests to 140 // If set, used when the current time is needed. This can be set by tests to
143 // simulate the passage of time. 141 // simulate the passage of time.
144 base::TimeTicks now_for_test_; 142 base::TimeTicks now_for_test_;
145 143
146 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_manager_; 144 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_manager_;
147 ScopedObserver<WmWindow, WmWindowObserver> wm_window_observer_manager_; 145 ScopedObserver<WmWindow, WmWindowObserver> wm_window_observer_manager_;
148 146
149 bool is_shutting_down_; 147 bool is_shutting_down_;
150 148
151 DISALLOW_COPY_AND_ASSIGN(VideoDetector); 149 DISALLOW_COPY_AND_ASSIGN(VideoDetector);
152 }; 150 };
153 151
154 } // namespace ash 152 } // namespace ash
155 153
156 #endif // ASH_WM_VIDEO_DETECTOR_H_ 154 #endif // ASH_WM_VIDEO_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698