OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 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 CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |
| 6 #define CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 |
| 12 namespace content { |
| 13 class WebContents; |
| 14 } |
| 15 |
| 16 class AudioStreamIndicator |
| 17 : public base::RefCountedThreadSafe<AudioStreamIndicator> { |
| 18 public: |
| 19 AudioStreamIndicator(); |
| 20 |
| 21 // This method should be called on the IO thread. |
| 22 void UpdateWebContentsStatus(int render_process_id, |
| 23 int render_view_id, |
| 24 bool playing); |
| 25 |
| 26 // This method should be called on the IO thread. |
| 27 bool IsPlayingAudio(content::WebContents* contents); |
| 28 |
| 29 private: |
| 30 struct RenderViewId { |
| 31 RenderViewId(int render_process_id, |
| 32 int render_view_id); |
| 33 |
| 34 // Required to use this struct in the std::multiset below. |
| 35 bool operator<(const RenderViewId& other) const; |
| 36 |
| 37 int render_process_id; |
| 38 int render_view_id; |
| 39 }; |
| 40 |
| 41 friend class base::RefCountedThreadSafe<AudioStreamIndicator>; |
| 42 virtual ~AudioStreamIndicator(); |
| 43 |
| 44 void UpdateWebContentsStatusOnUIThread(int render_process_id, |
| 45 int render_view_id, |
| 46 bool playing); |
| 47 |
| 48 // The set of RenderViews that currently have a stream playing (a multiset |
| 49 // because each RenderView might have more than one stream). |
| 50 std::multiset<RenderViewId> audio_streams_; |
| 51 }; |
| 52 |
| 53 #endif // CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |
OLD | NEW |