Index: chrome/browser/media/audio_stream_indicator.h |
diff --git a/chrome/browser/media/audio_stream_indicator.h b/chrome/browser/media/audio_stream_indicator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c0380746e557401c14943cbbe97135c569086d34 |
--- /dev/null |
+++ b/chrome/browser/media/audio_stream_indicator.h |
@@ -0,0 +1,53 @@ |
+// Copyright (c) 2012 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 CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |
+#define CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |
+ |
+#include <set> |
+ |
+#include "base/memory/ref_counted.h" |
+ |
+namespace content { |
+class WebContents; |
+} |
+ |
+class AudioStreamIndicator |
+ : public base::RefCountedThreadSafe<AudioStreamIndicator> { |
+ public: |
+ AudioStreamIndicator(); |
+ |
+ // This method should be called on the IO thread. |
+ void UpdateWebContentsStatus(int render_process_id, |
+ int render_view_id, |
+ bool playing); |
+ |
+ // This method should be called on the IO thread. |
+ bool IsPlayingAudio(content::WebContents* contents); |
+ |
+ private: |
+ struct RenderViewId { |
+ RenderViewId(int render_process_id, |
+ int render_view_id); |
+ |
+ // Required to use this struct in the std::multiset below. |
+ bool operator<(const RenderViewId& other) const; |
+ |
+ int render_process_id; |
+ int render_view_id; |
+ }; |
+ |
+ friend class base::RefCountedThreadSafe<AudioStreamIndicator>; |
+ virtual ~AudioStreamIndicator(); |
+ |
+ void UpdateWebContentsStatusOnUIThread(int render_process_id, |
+ int render_view_id, |
+ bool playing); |
+ |
+ // The set of RenderViews that currently have a stream playing (a multiset |
+ // because each RenderView might have more than one stream). |
+ std::multiset<RenderViewId> audio_streams_; |
+}; |
+ |
+#endif // CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |