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

Side by Side Diff: content/browser/android/audio_monitor_android.h

Issue 896673003: Propagate audible state from player to the containing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed MediaSourcePlayerTest compilation. Created 5 years, 10 months 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
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
Ted C 2015/02/07 00:07:15 no (c) anymore in the copyright (applies to all fi
Tima Vaisburd 2015/02/07 03:00:23 Done.
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 CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_
6 #define CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_
7
8 #include <map>
9 #include "base/macros.h"
10
11 namespace content {
12
13 class WebContents;
14 class RenderFrameHost;
15
16 // This class maintains the audible state of many players
17 // together. That state is accociated with one Chrome tab that might have
Ted C 2015/02/07 00:07:15 The concept of "tab" is a chrome/ level awareness.
Tima Vaisburd 2015/02/07 03:00:23 Done.
18 // several players.
19 // The audible state is true if at least one player is playing a sound.
20 // Whenever the audible state of the tab changes, this class sends
21 // notification to the WebContents that represents the tab.
22 class AudioMonitorAndroid {
23 public:
24 // Constructor, web_contents represents the tab.
25 explicit AudioMonitorAndroid(WebContents* web_contents);
26 ~AudioMonitorAndroid();
27
28 // Returns the audible state of the whole tab.
29 bool is_audible() const { return is_audible_; }
30
31 // These methods constitute the observer pattern, should
32 // be called when corresponding event happens. They will notify
33 // WebContents whenever the whole tab audible state changes.
34 void OnAudibleStateChanged(RenderFrameHost* rfh, int player_id,
35 bool is_audible);
36 void RemovePlayer(RenderFrameHost* rfh, int player_id);
37 void RenderFrameDeleted(RenderFrameHost* rfh);
38
39 private:
40 void UpdateStatusAndNotify();
41
42 // Contents of the tab this monitor is associated with
43 WebContents* web_contents_;
44
45 // Audible status per player ID and frame
46 typedef std::pair<RenderFrameHost*, int> Key;
47 typedef std::map<Key, bool> StatusMap;
48 StatusMap audio_status_map_;
49
50 // The audible state of the whole tab
51 bool is_audible_;
52
53 DISALLOW_COPY_AND_ASSIGN(AudioMonitorAndroid);
54 };
55
56 } // namespace content
57
58 #endif // CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/android/audio_monitor_android.cc » ('j') | content/browser/android/audio_monitor_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698