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

Unified Diff: chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc

Issue 1650133002: Start and stop RTC event logs from private extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create a new handler for the internal WebRTC logs instead of using WebRTCLoggingHandlerHost. Created 4 years, 11 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
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 a1387eaa5c0ffa301e4a27cfef4cae96203e151d..fdddd9364f1cd163b2ae4f9a5a05d7a7407c1fd8 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 StartRtcEventLogging =
+ api::webrtc_logging_private::StartRtcEventLogging;
+namespace StopRtcEventLogging =
+ api::webrtc_logging_private::StopRtcEventLogging;
namespace {
std::string HashIdWithOrigin(const std::string& security_origin,
@@ -130,19 +134,19 @@ void WebrtcLoggingPrivateFunctionWithUploadCallback::FireCallback(
SendResponse(success);
}
-void WebrtcLoggingPrivateFunctionWithAudioDebugRecordingsCallback::
+void WebrtcLoggingPrivateFunctionWithTimeLimitedRecordingCallback::
FireErrorCallback(const std::string& error_message) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
SetError(error_message);
SendResponse(false);
}
-void WebrtcLoggingPrivateFunctionWithAudioDebugRecordingsCallback::FireCallback(
+void WebrtcLoggingPrivateFunctionWithTimeLimitedRecordingCallback::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::TimeLimitedRecordingInfo result;
result.prefix_path = prefix_path;
result.did_stop = did_stop;
result.did_manual_stop = did_manual_stop;
@@ -394,10 +398,10 @@ bool WebrtcLoggingPrivateStartAudioDebugRecordingsFunction::RunAsync() {
if (!host)
return false;
- scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host(
- base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host));
+ scoped_refptr<WebRtcInternalLogHandlerHost> webrtc_internal_log_handler_host(
+ base::UserDataAdapter<WebRtcInternalLogHandlerHost>::Get(host, host));
- webrtc_logging_handler_host->StartAudioDebugRecordings(
+ webrtc_internal_log_handler_host->StartAudioDebugRecordings(
host, base::TimeDelta::FromSeconds(params->seconds),
base::Bind(
&WebrtcLoggingPrivateStartAudioDebugRecordingsFunction::FireCallback,
@@ -423,10 +427,10 @@ bool WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::RunAsync() {
if (!host)
return false;
- scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host(
- base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host));
+ scoped_refptr<WebRtcInternalLogHandlerHost> webrtc_internal_log_handler_host(
+ base::UserDataAdapter<WebRtcInternalLogHandlerHost>::Get(host, host));
- webrtc_logging_handler_host->StopAudioDebugRecordings(
+ webrtc_internal_log_handler_host->StopAudioDebugRecordings(
host,
base::Bind(
&WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::FireCallback,
@@ -437,4 +441,66 @@ bool WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::RunAsync() {
return true;
}
+bool WebrtcLoggingPrivateStartRtcEventLoggingFunction::RunAsync() {
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableRtcEventLoggingFromExtension)) {
tommi (sloooow) - chröme 2016/02/05 11:09:00 Is there information about when this switch will b
terelius1 2016/02/16 20:09:12 Extra privacy protection. See previous comments an
+ return false;
+ }
+
+ scoped_ptr<StartRtcEventLogging::Params> params(
+ StartRtcEventLogging::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<WebRtcInternalLogHandlerHost> webrtc_internal_log_handler_host(
+ base::UserDataAdapter<WebRtcInternalLogHandlerHost>::Get(host, host));
+
+ webrtc_internal_log_handler_host->StartRtcEventLogging(
+ host, base::TimeDelta::FromSeconds(params->seconds),
+ base::Bind(
+ &WebrtcLoggingPrivateStartRtcEventLoggingFunction::FireCallback,
+ this),
+ base::Bind(
+ &WebrtcLoggingPrivateStartRtcEventLoggingFunction::FireErrorCallback,
+ this));
+ return true;
+}
+
+bool WebrtcLoggingPrivateStopRtcEventLoggingFunction::RunAsync() {
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableRtcEventLoggingFromExtension)) {
+ return false;
+ }
+
+ scoped_ptr<StopRtcEventLogging::Params> params(
+ StopRtcEventLogging::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ content::RenderProcessHost* host =
+ RphFromRequest(params->request, params->security_origin);
+ if (!host)
+ return false;
+
+ scoped_refptr<WebRtcInternalLogHandlerHost> webrtc_internal_log_handler_host(
+ base::UserDataAdapter<WebRtcInternalLogHandlerHost>::Get(host, host));
+
+ webrtc_internal_log_handler_host->StopRtcEventLogging(
+ host,
+ base::Bind(&WebrtcLoggingPrivateStopRtcEventLoggingFunction::FireCallback,
tommi (sloooow) - chröme 2016/02/05 11:09:00 nit: use the same way of wrapping as you do two li
terelius1 2016/02/16 20:09:12 Done.
+ this),
+ base::Bind(
+ &WebrtcLoggingPrivateStopRtcEventLoggingFunction::FireErrorCallback,
+ this));
+ return true;
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698