Chromium Code Reviews| Index: chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc |
| diff --git a/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc b/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc |
| index c7a4141e4793ca838045d9205710b82f3ddc0f6d..1bcb5cd63cc43a167c7bcec9b9a46da925f67e9f 100644 |
| --- a/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc |
| +++ b/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc |
| @@ -42,6 +42,10 @@ namespace StartAudioDebugRecordings = |
| api::webrtc_logging_private::StartAudioDebugRecordings; |
| namespace StopAudioDebugRecordings = |
| api::webrtc_logging_private::StopAudioDebugRecordings; |
| +namespace StartWebRtcEventLogging = |
| + api::webrtc_logging_private::StartWebRtcEventLogging; |
|
tommi (sloooow) - chröme
2016/04/07 12:44:29
instead of using 'namespace' for this, can we use
terelius-chromium
2016/04/13 08:52:05
I've tried it. The problem is that StartWebRtcEven
tommi (sloooow) - chröme
2016/04/13 14:45:16
ah, thanks for that. strange that it's a namespace
|
| +namespace StopWebRtcEventLogging = |
| + api::webrtc_logging_private::StopWebRtcEventLogging; |
| namespace { |
| std::string HashIdWithOrigin(const std::string& security_origin, |
| @@ -96,7 +100,8 @@ WebrtcLoggingPrivateFunction::LoggingHandlerFromRequest( |
| if (!host) |
| return nullptr; |
| - return base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host); |
| + return base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get( |
| + host, WebRtcLoggingHandlerHost::kWebRtcLoggingHandlerHostKey); |
| } |
| scoped_refptr<WebRtcLoggingHandlerHost> |
| @@ -130,19 +135,19 @@ void WebrtcLoggingPrivateFunctionWithUploadCallback::FireCallback( |
| SendResponse(success); |
| } |
| -void WebrtcLoggingPrivateFunctionWithAudioDebugRecordingsCallback:: |
| - FireErrorCallback(const std::string& error_message) { |
| +void WebrtcLoggingPrivateFunctionWithRecordingDoneCallback::FireErrorCallback( |
| + const std::string& error_message) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| SetError(error_message); |
| SendResponse(false); |
| } |
| -void WebrtcLoggingPrivateFunctionWithAudioDebugRecordingsCallback::FireCallback( |
| +void WebrtcLoggingPrivateFunctionWithRecordingDoneCallback::FireCallback( |
| const std::string& prefix_path, |
| bool did_stop, |
| bool did_manual_stop) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| - api::webrtc_logging_private::AudioDebugRecordingsInfo result; |
| + api::webrtc_logging_private::RecordingInfo result; |
| result.prefix_path = prefix_path; |
| result.did_stop = did_stop; |
| result.did_manual_stop = did_manual_stop; |
| @@ -318,7 +323,8 @@ bool WebrtcLoggingPrivateStartRtpDumpFunction::RunAsync() { |
| return false; |
| scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host( |
| - base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host)); |
| + base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get( |
| + host, WebRtcLoggingHandlerHost::kWebRtcLoggingHandlerHostKey)); |
| WebRtcLoggingHandlerHost::GenericDoneCallback callback = base::Bind( |
| &WebrtcLoggingPrivateStartRtpDumpFunction::FireCallback, this); |
| @@ -360,7 +366,8 @@ bool WebrtcLoggingPrivateStopRtpDumpFunction::RunAsync() { |
| return false; |
| scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host( |
| - base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host)); |
| + base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get( |
| + host, WebRtcLoggingHandlerHost::kWebRtcLoggingHandlerHostKey)); |
| WebRtcLoggingHandlerHost::GenericDoneCallback callback = base::Bind( |
| &WebrtcLoggingPrivateStopRtpDumpFunction::FireCallback, this); |
| @@ -394,10 +401,11 @@ bool WebrtcLoggingPrivateStartAudioDebugRecordingsFunction::RunAsync() { |
| if (!host) |
| return false; |
| - scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host( |
| - base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host)); |
| + scoped_refptr<AudioDebugRecordingsHandler> audio_debug_recordings_handler( |
| + base::UserDataAdapter<AudioDebugRecordingsHandler>::Get( |
| + host, AudioDebugRecordingsHandler::kAudioDebugRecordingsHandlerKey)); |
| - webrtc_logging_handler_host->StartAudioDebugRecordings( |
| + audio_debug_recordings_handler->StartAudioDebugRecordings( |
| host, base::TimeDelta::FromSeconds(params->seconds), |
| base::Bind( |
| &WebrtcLoggingPrivateStartAudioDebugRecordingsFunction::FireCallback, |
| @@ -423,10 +431,11 @@ bool WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::RunAsync() { |
| if (!host) |
| return false; |
| - scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host( |
| - base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host)); |
| + scoped_refptr<AudioDebugRecordingsHandler> audio_debug_recordings_handler( |
| + base::UserDataAdapter<AudioDebugRecordingsHandler>::Get( |
| + host, AudioDebugRecordingsHandler::kAudioDebugRecordingsHandlerKey)); |
| - webrtc_logging_handler_host->StopAudioDebugRecordings( |
| + audio_debug_recordings_handler->StopAudioDebugRecordings( |
| host, |
| base::Bind( |
| &WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::FireCallback, |
| @@ -437,4 +446,69 @@ bool WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::RunAsync() { |
| return true; |
| } |
| +bool WebrtcLoggingPrivateStartWebRtcEventLoggingFunction::RunAsync() { |
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableWebRtcEventLoggingFromExtension)) { |
| + return false; |
| + } |
| + |
| + scoped_ptr<StartWebRtcEventLogging::Params> params( |
| + StartWebRtcEventLogging::Params::Create(*args_)); |
| + EXTENSION_FUNCTION_VALIDATE(params.get()); |
| + |
| + if (params->seconds < 0) { |
| + FireErrorCallback("seconds must be greater than or equal to 0"); |
| + return true; |
| + } |
| + |
| + content::RenderProcessHost* host = |
| + RphFromRequest(params->request, params->security_origin); |
| + if (!host) |
| + return false; |
| + |
| + scoped_refptr<WebRtcEventLogHandler> webrtc_event_log_handler( |
| + base::UserDataAdapter<WebRtcEventLogHandler>::Get( |
| + host, WebRtcEventLogHandler::kWebRtcEventLogHandlerKey)); |
| + |
| + webrtc_event_log_handler->StartWebRtcEventLogging( |
| + host, base::TimeDelta::FromSeconds(params->seconds), |
| + base::Bind( |
| + &WebrtcLoggingPrivateStartWebRtcEventLoggingFunction::FireCallback, |
| + this), |
| + base::Bind(&WebrtcLoggingPrivateStartWebRtcEventLoggingFunction:: |
| + FireErrorCallback, |
| + this)); |
| + return true; |
| +} |
| + |
| +bool WebrtcLoggingPrivateStopWebRtcEventLoggingFunction::RunAsync() { |
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableWebRtcEventLoggingFromExtension)) { |
| + return false; |
| + } |
| + |
| + scoped_ptr<StopWebRtcEventLogging::Params> params( |
| + StopWebRtcEventLogging::Params::Create(*args_)); |
| + EXTENSION_FUNCTION_VALIDATE(params.get()); |
| + |
| + content::RenderProcessHost* host = |
| + RphFromRequest(params->request, params->security_origin); |
| + if (!host) |
| + return false; |
| + |
| + scoped_refptr<WebRtcEventLogHandler> webrtc_event_log_handler( |
| + base::UserDataAdapter<WebRtcEventLogHandler>::Get( |
| + host, WebRtcEventLogHandler::kWebRtcEventLogHandlerKey)); |
| + |
| + webrtc_event_log_handler->StopWebRtcEventLogging( |
| + host, |
| + base::Bind( |
| + &WebrtcLoggingPrivateStopWebRtcEventLoggingFunction::FireCallback, |
| + this), |
| + base::Bind(&WebrtcLoggingPrivateStopWebRtcEventLoggingFunction:: |
|
tommi (sloooow) - chröme
2016/04/07 12:44:29
nit: looks like this Bind() and the one on the lin
terelius-chromium
2016/04/13 08:52:05
Yes. I have changed it multiple times, but |git cl
tommi (sloooow) - chröme
2016/04/13 14:45:16
looks good now
|
| + FireErrorCallback, |
| + this)); |
| + return true; |
| +} |
| + |
| } // namespace extensions |