Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5732)

Unified Diff: chrome/browser/media/media_internals.cc

Issue 10823097: Part 2: Plumb render view ID to content::MediaObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/media_internals.h ('k') | chrome/browser/media/media_internals_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/media_internals.cc
diff --git a/chrome/browser/media/media_internals.cc b/chrome/browser/media/media_internals.cc
index cca5c7650b2cfa132099abedff26a1649a81176b..69d9a5bd753e6e2f7181e874f23cb024fbd68f7d 100644
--- a/chrome/browser/media/media_internals.cc
+++ b/chrome/browser/media/media_internals.cc
@@ -9,44 +9,63 @@
#include "base/stringprintf.h"
#include "chrome/browser/media/media_internals_observer.h"
#include "chrome/browser/media/media_stream_capture_indicator.h"
+#include "chrome/browser/tab_contents/tab_util.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "media/base/media_log.h"
#include "media/base/media_log_event.h"
using content::BrowserThread;
+namespace {
+
+std::string GetStreamID(int render_process_id,
+ int render_view_id,
+ int stream_id) {
+ return base::StringPrintf("audio_streams.%d:%d:%d",
+ render_process_id, render_view_id, stream_id);
+}
+
+}
+
MediaInternals* MediaInternals::GetInstance() {
return Singleton<MediaInternals>::get();
}
MediaInternals::~MediaInternals() {}
-void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) {
+void MediaInternals::OnDeleteAudioStream(int render_process_id,
+ int render_view_id,
+ int stream_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- std::string stream = base::StringPrintf("audio_streams.%p:%d",
- host, stream_id);
- DeleteItem(stream);
+ DeleteItem(GetStreamID(render_process_id, render_view_id, stream_id));
}
-void MediaInternals::OnSetAudioStreamPlaying(
- void* host, int stream_id, bool playing) {
+void MediaInternals::OnSetAudioStreamPlaying(int render_process_id,
+ int render_view_id,
+ int stream_id,
+ bool playing) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- UpdateAudioStream(host, stream_id,
+ UpdateAudioStream(render_process_id, render_view_id, stream_id,
"playing", Value::CreateBooleanValue(playing));
}
-void MediaInternals::OnSetAudioStreamStatus(
- void* host, int stream_id, const std::string& status) {
+void MediaInternals::OnSetAudioStreamStatus(int render_process_id,
+ int render_view_id,
+ int stream_id,
+ const std::string& status) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- UpdateAudioStream(host, stream_id,
+ UpdateAudioStream(render_process_id, render_view_id, stream_id,
"status", Value::CreateStringValue(status));
}
-void MediaInternals::OnSetAudioStreamVolume(
- void* host, int stream_id, double volume) {
+void MediaInternals::OnSetAudioStreamVolume(int render_process_id,
+ int render_view_id,
+ int stream_id,
+ double volume) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- UpdateAudioStream(host, stream_id,
+ UpdateAudioStream(render_process_id, render_view_id, stream_id,
"volume", Value::CreateDoubleValue(volume));
}
@@ -103,11 +122,15 @@ void MediaInternals::SendEverything() {
MediaInternals::MediaInternals() {}
-void MediaInternals::UpdateAudioStream(
- void* host, int stream_id, const std::string& property, Value* value) {
- std::string stream = base::StringPrintf("audio_streams.%p:%d",
- host, stream_id);
- UpdateItem("media.addAudioStream", stream, property, value);
+void MediaInternals::UpdateAudioStream(int render_process_id,
+ int render_view_id,
+ int stream_id,
+ const std::string& property,
+ Value* value) {
+ const std::string id = GetStreamID(
+ render_process_id, render_view_id, stream_id);
+ UpdateItem("media.addAudioStream", render_process_id, render_view_id, id,
+ property, value);
}
void MediaInternals::DeleteItem(const std::string& item) {
@@ -117,8 +140,12 @@ void MediaInternals::DeleteItem(const std::string& item) {
}
void MediaInternals::UpdateItem(
- const std::string& update_fn, const std::string& id,
- const std::string& property, Value* value) {
+ const std::string& update_fn,
+ int render_process_id,
+ int render_view_id,
+ const std::string& id,
+ const std::string& property,
+ Value* value) {
DictionaryValue* item_properties;
if (!data_.GetDictionary(id, &item_properties)) {
item_properties = new DictionaryValue();
@@ -126,6 +153,14 @@ void MediaInternals::UpdateItem(
item_properties->SetString("id", id);
}
item_properties->Set(property, value);
+
+ content::WebContents* web_contents =
+ tab_util::GetWebContentsByID(render_process_id, render_view_id);
+ if (web_contents) {
+ string16 tab_title = web_contents->GetTitle();
+ item_properties->Set("tab_title", Value::CreateStringValue(tab_title));
+ }
+
SendUpdate(update_fn, item_properties);
}
« no previous file with comments | « chrome/browser/media/media_internals.h ('k') | chrome/browser/media/media_internals_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698