#ifndef CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_
#define CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_
#include <string>
#include <vector>
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/lazy_instance.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "content/common/content_export.h"
#include "media/audio/audio_logging.h"
namespace media {
class AudioParameters;
struct MediaLogEvent;
}
namespace content {
class CONTENT_EXPORT MediaInternals
: NON_EXPORTED_BASE(public media::AudioLogFactory) {
public:
static MediaInternals* GetInstance();
virtual ~MediaInternals();
void OnMediaEvents(int render_process_id,
const std::vector<media::MediaLogEvent>& events);
typedef base::Callback<void(const base::string16&)> UpdateCallback;
void AddUpdateCallback(const UpdateCallback& callback);
void RemoveUpdateCallback(const UpdateCallback& callback);
void SendEverything();
virtual scoped_ptr<media::AudioLog> CreateAudioLog(
AudioComponent component) OVERRIDE;
private:
friend class AudioLogImpl;
friend class MediaInternalsTest;
friend struct base::DefaultLazyInstanceTraits<MediaInternals>;
MediaInternals();
void SendUpdate(const base::string16& update);
void SendUpdateAndCache(const std::string& cache_key,
const std::string& function,
const base::DictionaryValue* value);
void SendUpdateAndPurgeCache(const std::string& cache_key,
const std::string& function,
const base::DictionaryValue* value);
std::vector<UpdateCallback> update_callbacks_;
base::Lock lock_;
base::DictionaryValue cached_data_;
int owner_ids_[AUDIO_COMPONENT_MAX];
DISALLOW_COPY_AND_ASSIGN(MediaInternals);
};
}
#endif