Chromium Code Reviews| Index: content/browser/renderer_host/media/media_stream_manager.cc |
| diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc |
| index 8a865fc2903a495faf5e9eb90a614de71607d4db..6cea0ad994a28dfbc0381bfc5ab1fc39098218cb 100644 |
| --- a/content/browser/renderer_host/media/media_stream_manager.cc |
| +++ b/content/browser/renderer_host/media/media_stream_manager.cc |
| @@ -14,17 +14,20 @@ |
| #include "base/rand_util.h" |
| #include "base/run_loop.h" |
| #include "base/threading/thread.h" |
| +#include "content/browser/browser_main_loop.h" |
| #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| #include "content/browser/renderer_host/media/device_request_message_filter.h" |
| #include "content/browser/renderer_host/media/media_stream_requester.h" |
| #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
| #include "content/browser/renderer_host/media/video_capture_manager.h" |
| #include "content/browser/renderer_host/media/web_contents_capture_util.h" |
| +#include "content/browser/renderer_host/render_process_host_impl.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/content_browser_client.h" |
| #include "content/public/browser/media_device_id.h" |
| #include "content/public/browser/media_observer.h" |
| #include "content/public/browser/media_request_state.h" |
| +#include "content/public/browser/render_process_host.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/media_stream_request.h" |
| #include "media/audio/audio_manager_base.h" |
| @@ -36,6 +39,13 @@ |
| #include "base/win/scoped_com_initializer.h" |
| #endif |
| +static void DoAddLogMessage(const std::string& message) { |
| + // Must be on the UI thread to access BrowserMainLoop. |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| + content::BrowserMainLoop::GetInstance()->media_stream_manager()-> |
| + AddLogMessageOnUIThread(message); |
| +} |
| + |
| namespace content { |
| namespace { |
| @@ -1392,8 +1402,19 @@ void MediaStreamManager::Closed(MediaStreamType stream_type, |
| void MediaStreamManager::DevicesEnumerated( |
| MediaStreamType stream_type, const StreamDeviceInfoArray& devices) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - DVLOG(1) << "DevicesEnumerated(" |
| - << ", {stream_type = " << stream_type << "})"; |
| + std::stringstream devices_msg; |
|
Henrik Grunell
2014/01/22 07:05:24
I think someone told me in a CL not to use strings
perkj_chrome
2014/01/22 10:03:29
Streams are only allowed for logging:
http://googl
vrk (LEFT CHROMIUM)
2014/01/23 21:46:32
Going to keep as-is. Let's fix this in a follow-up
|
| + devices_msg << "DevicesEnumerated(" |
| + << "{stream_type = " << stream_type << "})" << std::endl; |
| + for (StreamDeviceInfoArray::const_iterator it = devices.begin(); |
| + it != devices.end(); ++it) { |
| + devices_msg << " " << it->device.name << " (" |
| + << it->device.id << ")" << std::endl; |
| + } |
| + if (devices.empty()) |
| + devices_msg << "No devices found."; |
| + |
| + DVLOG(1) << devices_msg; |
| + AddLogMessage(devices_msg.str()); |
| // Only cache the device list when the device list has been changed. |
| bool need_update_clients = false; |
| @@ -1466,6 +1487,34 @@ void MediaStreamManager::DevicesEnumerated( |
| DCHECK_GE(active_enumeration_ref_count_[stream_type], 0); |
| } |
| +// static |
| +void MediaStreamManager::AddLogMessage(const std::string& message) { |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + base::Bind(::DoAddLogMessage, message)); |
| +} |
| + |
| +void MediaStreamManager::AddLogMessageOnUIThread(const std::string& message) { |
| + // Must be on the UI thread to access RenderProcessHost from process ID. |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + // Add logs for each pending request. |
| + for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end(); |
|
perkj_chrome
2014/01/22 10:03:29
Are you aware that a request is "Pending" as long
vrk (LEFT CHROMIUM)
2014/01/22 18:30:30
I think this behavior is acceptable in practice. W
vrk (LEFT CHROMIUM)
2014/01/23 21:46:32
Talked offline. This is hard to fix and I think th
|
| + ++it) { |
| + DeviceRequest* request = it->second; |
| + // Log the message to all renderers that are requesting a MediaStream or |
| + // device enumeration. |
|
perkj_chrome
2014/01/22 10:03:29
Can you add this comment to the header file as wel
vrk (LEFT CHROMIUM)
2014/01/23 21:46:32
Done, though reworded.
|
| + if (request->request_type == MEDIA_GENERATE_STREAM || |
| + request->request_type == MEDIA_ENUMERATE_DEVICES) { |
| + content::RenderProcessHostImpl* render_process_host_impl = |
| + static_cast<content::RenderProcessHostImpl*>( |
| + content::RenderProcessHost::FromID( |
| + request->requesting_process_id)); |
| + render_process_host_impl->WebRtcLogMessage(message); |
| + } |
| + } |
| +} |
| + |
| void MediaStreamManager::HandleAccessRequestResponse( |
| const std::string& label, |
| const MediaStreamDevices& devices) { |