OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
6 #define CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ | 6 #define CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // This class stores information about currently active media. | 21 // This class stores information about currently active media. |
22 // It's constructed on the UI thread but all of its methods are called on the IO | 22 // It's constructed on the UI thread but all of its methods are called on the IO |
23 // thread. | 23 // thread. |
24 class MediaInternals : public content::MediaObserver { | 24 class MediaInternals : public content::MediaObserver { |
25 public: | 25 public: |
26 virtual ~MediaInternals(); | 26 virtual ~MediaInternals(); |
27 | 27 |
28 static MediaInternals* GetInstance(); | 28 static MediaInternals* GetInstance(); |
29 | 29 |
30 // Overridden from content::MediaObserver: | 30 // Overridden from content::MediaObserver: |
31 virtual void OnDeleteAudioStream(void* host, int stream_id) OVERRIDE; | 31 virtual void OnDeleteAudioStream(int render_process_id, |
32 virtual void OnSetAudioStreamPlaying(void* host, | 32 int render_view_id, |
| 33 int stream_id) OVERRIDE; |
| 34 virtual void OnSetAudioStreamPlaying(int render_process_id, |
| 35 int render_view_id, |
33 int stream_id, | 36 int stream_id, |
34 bool playing) OVERRIDE; | 37 bool playing) OVERRIDE; |
35 virtual void OnSetAudioStreamStatus(void* host, | 38 virtual void OnSetAudioStreamStatus(int render_process_id, |
| 39 int render_view_id, |
36 int stream_id, | 40 int stream_id, |
37 const std::string& status) OVERRIDE; | 41 const std::string& status) OVERRIDE; |
38 virtual void OnSetAudioStreamVolume(void* host, | 42 virtual void OnSetAudioStreamVolume(int render_process_id, |
| 43 int render_view_id, |
39 int stream_id, | 44 int stream_id, |
40 double volume) OVERRIDE; | 45 double volume) OVERRIDE; |
41 virtual void OnMediaEvent(int render_process_id, | 46 virtual void OnMediaEvent(int render_process_id, |
42 const media::MediaLogEvent& event) OVERRIDE; | 47 const media::MediaLogEvent& event) OVERRIDE; |
43 virtual void OnCaptureDevicesOpened( | 48 virtual void OnCaptureDevicesOpened( |
44 int render_process_id, | 49 int render_process_id, |
45 int render_view_id, | 50 int render_view_id, |
46 const content::MediaStreamDevices& devices) OVERRIDE; | 51 const content::MediaStreamDevices& devices) OVERRIDE; |
47 virtual void OnCaptureDevicesClosed( | 52 virtual void OnCaptureDevicesClosed( |
48 int render_process_id, | 53 int render_process_id, |
49 int render_view_id, | 54 int render_view_id, |
50 const content::MediaStreamDevices& devices) OVERRIDE; | 55 const content::MediaStreamDevices& devices) OVERRIDE; |
51 | 56 |
52 // Methods for observers. | 57 // Methods for observers. |
53 // Observers should add themselves on construction and remove themselves | 58 // Observers should add themselves on construction and remove themselves |
54 // on destruction. | 59 // on destruction. |
55 void AddObserver(MediaInternalsObserver* observer); | 60 void AddObserver(MediaInternalsObserver* observer); |
56 void RemoveObserver(MediaInternalsObserver* observer); | 61 void RemoveObserver(MediaInternalsObserver* observer); |
57 void SendEverything(); | 62 void SendEverything(); |
58 | 63 |
59 private: | 64 private: |
60 friend class MediaInternalsTest; | 65 friend class MediaInternalsTest; |
61 friend struct DefaultSingletonTraits<MediaInternals>; | 66 friend struct DefaultSingletonTraits<MediaInternals>; |
62 | 67 |
63 MediaInternals(); | 68 MediaInternals(); |
64 | 69 |
65 // Sets |property| of an audio stream to |value| and notifies observers. | 70 // Sets |property| of an audio stream to |value| and notifies observers. |
66 // (host, stream_id) is a unique id for the audio stream. | 71 // (render_process_id, render_view_id, stream_id) is a unique id for the |
67 // |host| will never be dereferenced. | 72 // audio stream. |
68 void UpdateAudioStream(void* host, int stream_id, | 73 void UpdateAudioStream(int render_process_id, int render_view_id, |
| 74 int stream_id, |
69 const std::string& property, Value* value); | 75 const std::string& property, Value* value); |
70 | 76 |
71 // Removes |item| from |data_|. | 77 // Removes |item| from |data_|. |
72 void DeleteItem(const std::string& item); | 78 void DeleteItem(const std::string& item); |
73 | 79 |
74 // Sets data_.id.property = value and notifies attached UIs using update_fn. | 80 // Sets data_.id.property = value and notifies attached UIs using update_fn. |
75 // id may be any depth, e.g. "video.decoders.1.2.3" | 81 // id may be any depth, e.g. "video.decoders.1.2.3" |
76 void UpdateItem(const std::string& update_fn, const std::string& id, | 82 void UpdateItem(const std::string& update_fn, |
77 const std::string& property, Value* value); | 83 int render_process_id, int render_view_id, |
| 84 const std::string& id, const std::string& property, |
| 85 Value* value); |
78 | 86 |
79 // Calls javascript |function|(|value|) on each attached UI. | 87 // Calls javascript |function|(|value|) on each attached UI. |
80 void SendUpdate(const std::string& function, Value* value); | 88 void SendUpdate(const std::string& function, Value* value); |
81 | 89 |
82 static MediaInternals* instance_; | 90 static MediaInternals* instance_; |
83 DictionaryValue data_; | 91 DictionaryValue data_; |
84 ObserverList<MediaInternalsObserver> observers_; | 92 ObserverList<MediaInternalsObserver> observers_; |
85 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; | 93 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; |
86 | 94 |
87 DISALLOW_COPY_AND_ASSIGN(MediaInternals); | 95 DISALLOW_COPY_AND_ASSIGN(MediaInternals); |
88 }; | 96 }; |
89 | 97 |
90 #endif // CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ | 98 #endif // CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
OLD | NEW |