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

Unified Diff: chrome/browser/media/webrtc_logging_handler_host.cc

Issue 1871533002: Change WebRTC log callback registration in browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/media/webrtc_logging_handler_host.cc
diff --git a/chrome/browser/media/webrtc_logging_handler_host.cc b/chrome/browser/media/webrtc_logging_handler_host.cc
index 0106cb34718e02866df51f1d5ad2a1d94a7ac90b..832558d8eff9bfa15f3ce72f608d500743ce6077 100644
--- a/chrome/browser/media/webrtc_logging_handler_host.cc
+++ b/chrome/browser/media/webrtc_logging_handler_host.cc
@@ -148,6 +148,7 @@ void WebRtcLogBuffer::SetComplete() {
}
WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost(
+ int render_process_id,
Profile* profile,
WebRtcLogUploader* log_uploader)
: BrowserMessageFilter(WebRtcLoggingMsgStart),
@@ -156,7 +157,8 @@ WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost(
upload_log_on_render_close_(false),
log_uploader_(log_uploader),
is_audio_debug_recordings_in_progress_(false),
- current_audio_debug_recordings_id_(0) {
+ current_audio_debug_recordings_id_(0),
+ render_process_id_(render_process_id) {
DCHECK(profile_);
DCHECK(log_uploader_);
}
@@ -234,7 +236,14 @@ void WebRtcLoggingHandlerHost::StopLogging(
stop_callback_ = callback;
logging_state_ = STOPPING;
+
Send(new WebRtcLoggingMsg_StopLogging());
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(
+ &WebRtcLoggingHandlerHost::DisableBrowserProcessLoggingOnUIThread,
+ this));
}
void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) {
@@ -632,12 +641,36 @@ void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread(
net::NetworkChangeNotifier::ConnectionTypeToString(it->type));
}
+ BrowserThread::PostTask(
o1ka 2016/04/07 13:00:11 Probably move it to the top to have less chances t
tommi (sloooow) - chröme 2016/04/07 13:52:19 Won't that introduce a potential race with writing
Henrik Grunell 2016/04/07 14:32:59 It won't race, since this function and LogMessage(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(
+ &WebRtcLoggingHandlerHost::EnableBrowserProcessLoggingOnUIThread,
+ this));
+
Send(new WebRtcLoggingMsg_StartLogging());
logging_started_time_ = base::Time::Now();
logging_state_ = STARTED;
FireGenericDoneCallback(callback, true, "");
}
+void WebRtcLoggingHandlerHost::EnableBrowserProcessLoggingOnUIThread() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(render_process_id_);
+ if (host) {
+ host->SetWebRtcLogMessageCallback(
o1ka 2016/04/07 13:00:11 What guarantees that |host| is still alive here (i
tommi (sloooow) - chröme 2016/04/07 13:52:19 FromID() must be called on the UI thread, it retur
Henrik Grunell 2016/04/07 14:32:59 Yes. Actually, I don't think we should spam with a
+ base::Bind(&WebRtcLoggingHandlerHost::LogMessage, this));
+ }
+}
+
+void WebRtcLoggingHandlerHost::DisableBrowserProcessLoggingOnUIThread() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(render_process_id_);
+ if (host)
+ host->UnsetWebRtcLogMessageCallback();
tommi (sloooow) - chröme 2016/04/07 12:51:44 could this possibly 'unset' a callback that was no
o1ka 2016/04/07 13:00:11 What guarantees that |host| is still alive here (i
Henrik Grunell 2016/04/07 13:34:53 This can't happen. These two functions are only ca
tommi (sloooow) - chröme 2016/04/07 13:52:19 From the code, it looks like it's at least theorat
tommi (sloooow) - chröme 2016/04/07 13:52:19 On 2016/04/07 13:34:53, Henrik Grunell wrote: http
Henrik Grunell 2016/04/07 14:32:59 No it's no applicable. In fact, the callback will
Henrik Grunell 2016/04/07 14:32:59 Hmm, in MSM it's OK to call several times, as a co
+}
+
void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_NE(logging_state_, CLOSED);

Powered by Google App Engine
This is Rietveld 408576698