Index: content/browser/android/audio_monitor_android.h |
diff --git a/content/browser/android/audio_monitor_android.h b/content/browser/android/audio_monitor_android.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..27d42875bb20330040af4cea834075262369efec |
--- /dev/null |
+++ b/content/browser/android/audio_monitor_android.h |
@@ -0,0 +1,58 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_ |
+#define CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_ |
+ |
+#include <map> |
+#include "base/macros.h" |
+ |
+namespace content { |
+ |
+class WebContents; |
+class RenderFrameHost; |
+ |
+// This class maintains the audible state of many players |
no sievers
2015/02/10 01:33:03
You should say that this class is associated with
Tima Vaisburd
2015/02/11 03:34:05
Changed the wording, please verify.
|
+// together. That state is accociated with a WebContents that might have |
+// several players. |
+// The audible state is true if at least one player is playing a sound. |
+// Whenever the audible state of the WebContents as a whole changes, this |
+// class sends notification to it. |
+class AudioMonitorAndroid { |
+ public: |
+ // Constructor, web_contents represents the tab. |
no sievers
2015/02/10 01:33:03
Let's avoid talking about 'tabs' here and below wh
Tima Vaisburd
2015/02/11 03:34:05
Done.
|
+ explicit AudioMonitorAndroid(WebContents* web_contents); |
+ ~AudioMonitorAndroid(); |
+ |
+ // Returns the audible state of the whole tab. |
+ bool is_audible() const { return is_audible_; } |
+ |
+ // These methods constitute the observer pattern, should |
+ // be called when corresponding event happens. They will notify |
+ // WebContents whenever the whole tab audible state changes. |
+ void OnAudibleStateChanged(RenderFrameHost* rfh, int player_id, |
+ bool is_audible); |
+ void RemovePlayer(RenderFrameHost* rfh, int player_id); |
+ void RenderFrameDeleted(RenderFrameHost* rfh); |
+ |
+ private: |
+ void UpdateStatusAndNotify(); |
+ |
+ // Contents of the tab this monitor is associated with |
+ WebContents* web_contents_; |
+ |
+ // Audible status per player ID and frame |
+ typedef std::pair<RenderFrameHost*, int> Key; |
+ typedef std::map<Key, bool> StatusMap; |
+ StatusMap audio_status_map_; |
+ |
+ // The audible state of the whole tab |
+ bool is_audible_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioMonitorAndroid); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_ |