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..95603f90aed08dac4bac68bc91e2563d6fdf902b |
--- /dev/null |
+++ b/content/browser/android/audio_monitor_android.h |
@@ -0,0 +1,58 @@ |
+// 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.
|
+// 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 |
+// 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.
|
+// several players. |
+// The audible state is true if at least one player is playing a sound. |
+// Whenever the audible state of the tab changes, this class sends |
+// notification to the WebContents that represents the tab. |
+class AudioMonitorAndroid { |
+ public: |
+ // Constructor, web_contents represents the tab. |
+ 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_ |