OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_MEDIA_SESSION_AUDIO_FOCUS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_AUDIO_FOCUS_MANAGER_H_ |
6 #define CONTENT_BROWSER_MEDIA_SESSION_AUDIO_FOCUS_MANAGER_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_AUDIO_FOCUS_MANAGER_H_ |
7 | 7 |
8 #include <list> | |
8 #include <unordered_map> | 9 #include <unordered_map> |
9 | 10 |
10 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
12 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 class MediaSession; | 17 class MediaSession; |
17 class WebContents; | 18 class WebContents; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 AudioFocusType type_; | 54 AudioFocusType type_; |
54 | 55 |
55 DISALLOW_COPY_AND_ASSIGN(AudioFocusEntry); | 56 DISALLOW_COPY_AND_ASSIGN(AudioFocusEntry); |
56 }; | 57 }; |
57 | 58 |
58 AudioFocusManager(); | 59 AudioFocusManager(); |
59 ~AudioFocusManager(); | 60 ~AudioFocusManager(); |
60 | 61 |
61 void OnWebContentsDestroyed(WebContents* web_contents); | 62 void OnWebContentsDestroyed(WebContents* web_contents); |
62 | 63 |
63 // Internal usage of AbandonAudioFocus using WebContents. | |
64 void AbandonAudioFocusInternal(WebContents* web_contents); | |
65 | |
66 // This method is meant to be called when a new session is of type | |
67 // GainTransientMayDuck. If it is the first one, other clients will be asked | |
68 // to duck. | |
69 void MaybeStartDucking() const; | |
70 | |
71 // This method is meant to be called when a session is no longer of type | |
72 // GainTransientMayDuck. If it was the last one, other clients will be asked | |
73 // to no longer duck. | |
74 void MaybeStopDucking() const; | |
75 | |
76 // Returns how many sessions require current audio focused session to duck. | |
77 int TransientMayDuckEntriesCount() const; | |
78 | |
79 // Internal method to request audio focus of type AudioFocusType::Gain. | |
80 void RequestAudioFocusGain(WebContents* web_contents); | |
81 | |
82 // Removes the entry associated with |web_contents| from the | |
83 // |transient_entries_| if there is one. | |
84 void MaybeRemoveTransientEntry(WebContents* web_contents); | |
85 | |
86 // Removes the focused session if it is associated with |web_contents|. | |
87 void MaybeRemoveFocusEntry(WebContents* web_contents); | 64 void MaybeRemoveFocusEntry(WebContents* web_contents); |
88 | 65 |
89 std::unordered_map<WebContents*, std::unique_ptr<AudioFocusEntry>> | 66 std::list<std::unique_ptr<AudioFocusEntry>> audio_focus_stack_; |
whywhat
2016/08/30 21:09:37
nit: why not std::stack if it is a stack? why call
Zhiqiang Zhang (Slow)
2016/08/31 14:37:34
I think it is better to use an linked-list impleme
whywhat
2016/08/31 18:37:09
That's why I posted a second question. If you use
| |
90 transient_entries_; | |
91 std::unique_ptr<AudioFocusEntry> focus_entry_; | |
92 }; | 67 }; |
93 | 68 |
94 } // namespace content | 69 } // namespace content |
95 | 70 |
96 #endif // CONTENT_BROWSER_MEDIA_SESSION_AUDIO_FOCUS_MANAGER_H_ | 71 #endif // CONTENT_BROWSER_MEDIA_SESSION_AUDIO_FOCUS_MANAGER_H_ |
OLD | NEW |