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

Side by Side Diff: chrome/browser/media/media_internals.cc

Issue 10835025: Plumb render view ID to media observer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/media/media_internals.h" 5 #include "chrome/browser/media/media_internals.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/media/media_internals_observer.h" 10 #include "chrome/browser/media/media_internals_observer.h"
11 #include "chrome/browser/media/media_stream_capture_indicator.h" 11 #include "chrome/browser/media/media_stream_capture_indicator.h"
12 #include "chrome/browser/tab_contents/tab_util.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_ui.h" 15 #include "content/public/browser/web_ui.h"
14 #include "media/base/media_log.h" 16 #include "media/base/media_log.h"
15 #include "media/base/media_log_event.h" 17 #include "media/base/media_log_event.h"
16 18
19 #include "base/utf_string_conversions.h"
20
17 using content::BrowserThread; 21 using content::BrowserThread;
18 22
19 MediaInternals* MediaInternals::GetInstance() { 23 MediaInternals* MediaInternals::GetInstance() {
20 return Singleton<MediaInternals>::get(); 24 return Singleton<MediaInternals>::get();
21 } 25 }
22 26
23 MediaInternals::~MediaInternals() {} 27 MediaInternals::~MediaInternals() {}
24 28
25 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) { 29 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
27 std::string stream = base::StringPrintf("audio_streams.%p:%d", 31 std::string stream = base::StringPrintf("audio_streams.%p:%d",
28 host, stream_id); 32 host, stream_id);
29 DeleteItem(stream); 33 DeleteItem(stream);
30 } 34 }
31 35
32 void MediaInternals::OnSetAudioStreamPlaying( 36 void MediaInternals::OnSetAudioStreamPlaying(
33 void* host, int stream_id, bool playing) { 37 void* host, int stream_id, bool playing) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
35 UpdateAudioStream(host, stream_id, 39 UpdateAudioStream(host, stream_id,
36 "playing", Value::CreateBooleanValue(playing)); 40 "playing", Value::CreateBooleanValue(playing));
37 } 41 }
38 42
39 void MediaInternals::OnSetAudioStreamStatus( 43 void MediaInternals::OnSetAudioStreamStatus(
40 void* host, int stream_id, const std::string& status) { 44 void* host,
45 int stream_id,
46 int render_process_id,
47 int render_view_id,
48 const std::string& status) {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
42 UpdateAudioStream(host, stream_id, 50 UpdateAudioStream(host, stream_id,
43 "status", Value::CreateStringValue(status)); 51 "status", Value::CreateStringValue(status));
52
53 content::WebContents* web_content =
54 tab_util::GetWebContentsByID(render_process_id, render_view_id);
55 if (web_content) {
56 string16 tab_title = web_content->GetTitle();
57 fprintf(stderr, "%s (%d, %d) - title: '%s'\n",
58 __PRETTY_FUNCTION__, render_process_id, render_view_id,
59 UTF16ToUTF8(tab_title).c_str());
60 UpdateAudioStream(host, stream_id,
61 "tabtitle",
62 Value::CreateStringValue(tab_title));
63 } else {
64 fprintf(stderr, "%s (%d, %d) - NULL web_contents\n",
65 __PRETTY_FUNCTION__, render_process_id, render_view_id);
66 }
44 } 67 }
45 68
46 void MediaInternals::OnSetAudioStreamVolume( 69 void MediaInternals::OnSetAudioStreamVolume(
47 void* host, int stream_id, double volume) { 70 void* host, int stream_id, double volume) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
49 UpdateAudioStream(host, stream_id, 72 UpdateAudioStream(host, stream_id,
50 "volume", Value::CreateDoubleValue(volume)); 73 "volume", Value::CreateDoubleValue(volume));
51 } 74 }
52 75
53 void MediaInternals::OnMediaEvent( 76 void MediaInternals::OnMediaEvent(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 154
132 void MediaInternals::SendUpdate(const std::string& function, Value* value) { 155 void MediaInternals::SendUpdate(const std::string& function, Value* value) {
133 // Only bother serializing the update to JSON if someone is watching. 156 // Only bother serializing the update to JSON if someone is watching.
134 if (observers_.size()) { 157 if (observers_.size()) {
135 std::vector<const Value*> args; 158 std::vector<const Value*> args;
136 args.push_back(value); 159 args.push_back(value);
137 string16 update = content::WebUI::GetJavascriptCall(function, args); 160 string16 update = content::WebUI::GetJavascriptCall(function, args);
138 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); 161 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update));
139 } 162 }
140 } 163 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_internals.h ('k') | content/browser/renderer_host/media/audio_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698