Index: content/browser/media/media_internals.h |
=================================================================== |
--- content/browser/media/media_internals.h (revision 179909) |
+++ content/browser/media/media_internals.h (working copy) |
@@ -2,97 +2,66 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
-#define CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
+#ifndef CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
+#define CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
#include <string> |
+#include <vector> |
#include "base/memory/ref_counted.h" |
#include "base/memory/singleton.h" |
-#include "base/observer_list.h" |
+#include "base/string16.h" |
#include "base/values.h" |
-#include "content/public/browser/media_observer.h" |
+#include "content/common/content_export.h" |
#include "content/public/common/media_stream_request.h" |
-class MediaCaptureDevicesDispatcher; |
-class MediaInternalsObserver; |
-class MediaStreamCaptureIndicator; |
-class Profile; |
- |
namespace media { |
- |
struct MediaLogEvent; |
- |
-// Helper to get the default devices which can be used by the media request, |
-// if the return list is empty, it means there is no available device on the OS. |
-// Called on the UI thread. |
-void GetDefaultDevicesForProfile(Profile* profile, |
- bool audio, |
- bool video, |
- content::MediaStreamDevices* devices); |
- |
-// Helper for picking the device that was requested for an OpenDevice request. |
-// If the device requested is not available it will revert to using the first |
-// available one instead or will return an empty list if no devices of the |
-// requested kind are present. |
-void GetRequestedDevice(const std::string& requested_device_id, |
- bool audio, |
- bool video, |
- content::MediaStreamDevices* devices); |
} |
+namespace content { |
+ |
// This class stores information about currently active media. |
// It's constructed on the UI thread but all of its methods are called on the IO |
// thread. |
-class MediaInternals : public content::MediaObserver { |
+class CONTENT_EXPORT MediaInternals { |
public: |
virtual ~MediaInternals(); |
static MediaInternals* GetInstance(); |
- // Overridden from content::MediaObserver: |
- virtual void OnDeleteAudioStream(void* host, int stream_id) OVERRIDE; |
- virtual void OnSetAudioStreamPlaying(void* host, |
- int stream_id, |
- bool playing) OVERRIDE; |
- virtual void OnSetAudioStreamStatus(void* host, |
- int stream_id, |
- const std::string& status) OVERRIDE; |
- virtual void OnSetAudioStreamVolume(void* host, |
- int stream_id, |
- double volume) OVERRIDE; |
+ // The following methods are virtual for gmock. |
+ |
+ // Called when an audio stream is deleted. |
+ virtual void OnDeleteAudioStream(void* host, int stream_id); |
+ |
+ // Called when an audio stream is set to playing or paused. |
+ virtual void OnSetAudioStreamPlaying(void* host, int stream_id, |
+ bool playing); |
+ |
+ // Called when the status of an audio stream is set to "created", "flushed", |
+ // "closed", or "error". |
+ virtual void OnSetAudioStreamStatus(void* host, int stream_id, |
+ const std::string& status); |
+ |
+ // Called when the volume of an audio stream is set. |
+ virtual void OnSetAudioStreamVolume(void* host, int stream_id, |
+ double volume); |
+ |
+ // Called when a MediaEvent occurs. |
virtual void OnMediaEvent(int render_process_id, |
- const media::MediaLogEvent& event) OVERRIDE; |
- virtual void OnCaptureDevicesOpened( |
- int render_process_id, |
- int render_view_id, |
- const content::MediaStreamDevices& devices) OVERRIDE; |
- virtual void OnCaptureDevicesClosed( |
- int render_process_id, |
- int render_view_id, |
- const content::MediaStreamDevices& devices) OVERRIDE; |
- virtual void OnAudioCaptureDevicesChanged( |
- const content::MediaStreamDevices& devices) OVERRIDE; |
- virtual void OnVideoCaptureDevicesChanged( |
- const content::MediaStreamDevices& devices) OVERRIDE; |
- virtual void OnMediaRequestStateChanged( |
- int render_process_id, |
- int render_view_id, |
- const content::MediaStreamDevice& device, |
- content::MediaRequestState state) OVERRIDE; |
+ const media::MediaLogEvent& event); |
- // Methods for observers. |
- // Observers should add themselves on construction and remove themselves |
- // on destruction. |
- void AddObserver(MediaInternalsObserver* observer); |
- void RemoveObserver(MediaInternalsObserver* observer); |
+ // Called with the update string. |
+ typedef base::Callback<void(const string16&)> UpdateCallback; |
+ |
+ // Add/remove update callbacks (see above). |
+ void AddUpdateCallback(const UpdateCallback& callback); |
+ void RemoveUpdateCallback(const UpdateCallback& callback); |
void SendEverything(); |
- scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator(); |
- scoped_refptr<MediaCaptureDevicesDispatcher> |
- GetMediaCaptureDevicesDispatcher(); |
- |
private: |
+ friend class MockMediaInternals; |
friend class MediaInternalsTest; |
friend struct DefaultSingletonTraits<MediaInternals>; |
@@ -116,11 +85,12 @@ |
void SendUpdate(const std::string& function, Value* value); |
DictionaryValue data_; |
- ObserverList<MediaInternalsObserver> observers_; |
- scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; |
- scoped_refptr<MediaCaptureDevicesDispatcher> media_devices_dispatcher_; |
+ std::vector<UpdateCallback> update_callbacks_; |
+ |
DISALLOW_COPY_AND_ASSIGN(MediaInternals); |
}; |
-#endif // CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_ |