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..c2542938c689540bcc2dd59daf924af71de64cdc 100644 |
| --- a/content/browser/renderer_host/media/media_stream_manager.cc |
| +++ b/content/browser/renderer_host/media/media_stream_manager.cc |
| @@ -14,6 +14,7 @@ |
| #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" |
| @@ -25,6 +26,7 @@ |
| #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 +38,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 { |
| @@ -253,6 +262,8 @@ class MediaStreamManager::DeviceRequest { |
| StreamDeviceInfoArray devices; |
| + AddWebRtcLogCallback logging_callback; |
| + |
| // Callback to the requester which audio/video devices have been selected. |
| // It can be null if the requester has no interest to know the result. |
| // Currently it is only used by |DEVICE_ACCESS| type. |
| @@ -1301,8 +1312,8 @@ void MediaStreamManager::InitializeDeviceManagersOnIOThread() { |
| this, device_thread_->message_loop_proxy().get()); |
| video_capture_manager_ = new VideoCaptureManager(); |
| - video_capture_manager_->Register(this, |
| - device_thread_->message_loop_proxy().get()); |
| + video_capture_manager_->Register( |
| + this, device_thread_->message_loop_proxy().get()); |
|
Henrik Grunell
2014/01/17 08:51:25
Nit: AFAICT from the style guide, the code layout
perkj_chrome
2014/01/20 11:07:08
I think Henrik is wrong and vrk is correct :->
Henrik Grunell
2014/01/20 16:23:08
I don't have a very strong opinion on this, do wha
vrk (LEFT CHROMIUM)
2014/01/22 02:25:42
I believe either way is acceptable, but I reverted
|
| // We want to be notified of IO message loop destruction to delete the thread |
| // and the device managers. |
| @@ -1466,6 +1477,32 @@ 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(); |
| + ++it) { |
| + DeviceRequest* request = it->second; |
| + // Log the message to all renderers that are requesting a MediaStream or |
| + // device enumeration. |
| + if (request->request_type == MEDIA_GENERATE_STREAM || |
| + request->request_type == MEDIA_ENUMERATE_DEVICES) { |
| + content::RenderProcessHost* render_process_host = |
| + content::RenderProcessHost::FromID(request->requesting_process_id); |
| + render_process_host->WebRtcLogMessage(message); |
| + } |
| + } |
| +} |
| + |
| void MediaStreamManager::HandleAccessRequestResponse( |
| const std::string& label, |
| const MediaStreamDevices& devices) { |