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

Unified Diff: chrome/browser/media/audio_stream_indicator.h

Issue 11573066: Add a method to tab_utils.h to find out whether a tab is playing audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/media/audio_stream_indicator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..03596b58c8ea3f42c28f0523bdcc1d8b11832b3e
--- /dev/null
+++ b/chrome/browser/media/audio_stream_indicator.h
@@ -0,0 +1,56 @@
+// 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 <map>
+#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,
+ int stream_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,
+ int stream_id,
+ bool playing);
+
+ // A map from RenderViews to sets of streams playing in them (each RenderView
+ // might have more than one stream).
+ std::map<RenderViewId, std::set<int> > audio_streams_;
+};
+
+#endif // CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_
« no previous file with comments | « no previous file | chrome/browser/media/audio_stream_indicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698