summaryrefslogtreecommitdiffstats
path: root/chrome/browser/media/media_internals.cc
diff options
context:
space:
mode:
authorscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-08 23:11:21 +0000
committerscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-08 23:11:21 +0000
commit0d9f6f050e9396ddd9e4222a357b62233fd99bbd (patch)
treed59833def42f91a4c26cebeba53d347590c71bc6 /chrome/browser/media/media_internals.cc
parent6d2e1ec46fd727af4962e9e6a1c5b84a761a6526 (diff)
downloadchromium_src-0d9f6f050e9396ddd9e4222a357b62233fd99bbd.zip
chromium_src-0d9f6f050e9396ddd9e4222a357b62233fd99bbd.tar.gz
chromium_src-0d9f6f050e9396ddd9e4222a357b62233fd99bbd.tar.bz2
Pass AudioRendererHost data to MediaInternals.
BUG=none TEST=compiles, unittests Review URL: http://codereview.chromium.org/7217025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/media/media_internals.cc')
-rw-r--r--chrome/browser/media/media_internals.cc39
1 files changed, 26 insertions, 13 deletions
diff --git a/chrome/browser/media/media_internals.cc b/chrome/browser/media/media_internals.cc
index 40b342e..78d66f3 100644
--- a/chrome/browser/media/media_internals.cc
+++ b/chrome/browser/media/media_internals.cc
@@ -12,17 +12,31 @@
#include "content/browser/webui/web_ui.h"
// The names of the javascript functions to call with updates.
+static const char kDeleteItemFunction[] = "onItemDeleted";
static const char kAudioUpdateFunction[] = "onAudioUpdate";
static const char kSendEverythingFunction[] = "onReceiveEverything";
MediaInternals::~MediaInternals() {}
+void MediaInternals::OnDeleteAudioStream(
+ void* host, int32 render_view, int stream_id) {
+ std::string stream = base::StringPrintf("audio_streams.%p:%d:%d",
+ host, render_view, stream_id);
+ DeleteItem(stream);
+}
+
void MediaInternals::OnSetAudioStreamPlaying(
void* host, int32 render_view, int stream_id, bool playing) {
UpdateAudioStream(host, render_view, stream_id,
"playing", Value::CreateBooleanValue(playing));
}
+void MediaInternals::OnSetAudioStreamStatus(
+ void* host, int32 render_view, int stream_id, const std::string& status) {
+ UpdateAudioStream(host, render_view, stream_id,
+ "status", Value::CreateStringValue(status));
+}
+
void MediaInternals::OnSetAudioStreamVolume(
void* host, int32 render_view, int stream_id, double volume) {
UpdateAudioStream(host, render_view, stream_id,
@@ -38,10 +52,7 @@ void MediaInternals::RemoveUI(MediaInternalsObserver* ui) {
}
void MediaInternals::SendEverything() {
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(
- this, &MediaInternals::SendUpdateOnIOThread,
- std::string(kSendEverythingFunction), &data_));
+ SendUpdate(kSendEverythingFunction, &data_);
}
MediaInternals::MediaInternals()
@@ -50,15 +61,18 @@ MediaInternals::MediaInternals()
void MediaInternals::UpdateAudioStream(
void* host, int32 render_view, int stream_id,
const std::string& property, Value* value) {
- std::string stream = base::StringPrintf("audio_streams.%p.%d.%d",
+ std::string stream = base::StringPrintf("audio_streams.%p:%d:%d",
host, render_view, stream_id);
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(
- this, &MediaInternals::UpdateItemOnIOThread,
- std::string(kAudioUpdateFunction), stream, property, value));
+ UpdateItem(kAudioUpdateFunction, stream, property, value);
+}
+
+void MediaInternals::DeleteItem(const std::string& item) {
+ data_.Remove(item, NULL);
+ scoped_ptr<Value> value(Value::CreateStringValue(item));
+ SendUpdate(kDeleteItemFunction, value.get());
}
-void MediaInternals::UpdateItemOnIOThread(
+void MediaInternals::UpdateItem(
const std::string& update_fn, const std::string& id,
const std::string& property, Value* value) {
DictionaryValue* item_properties;
@@ -68,11 +82,10 @@ void MediaInternals::UpdateItemOnIOThread(
item_properties->SetString("id", id);
}
item_properties->Set(property, value);
- SendUpdateOnIOThread(update_fn, item_properties);
+ SendUpdate(update_fn, item_properties);
}
-void MediaInternals::SendUpdateOnIOThread(const std::string& function,
- Value* value) {
+void MediaInternals::SendUpdate(const std::string& function, Value* value) {
scoped_ptr<std::vector<const Value*> > args(new std::vector<const Value*>());
args->push_back(value);
string16 update = WebUI::GetJavascriptCall(function, *args.get());