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

Side by Side Diff: chrome/browser/media/webrtc_logging_handler_host.cc

Issue 140633004: Reland CL to implement browser-side logging to WebRtc log. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: These are the changes that should fix crbug.com/338848 Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/webrtc_logging_handler_host.h" 5 #include "chrome/browser/media/webrtc_logging_handler_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 kLogNotStoppedOrNoLogOpen); 196 kLogNotStoppedOrNoLogOpen);
197 return; 197 return;
198 } 198 }
199 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); 199 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload();
200 circular_buffer_.reset(); 200 circular_buffer_.reset();
201 log_buffer_.reset(); 201 log_buffer_.reset();
202 logging_state_ = CLOSED; 202 logging_state_ = CLOSED;
203 FireGenericDoneCallback(&discard_callback, true, ""); 203 FireGenericDoneCallback(&discard_callback, true, "");
204 } 204 }
205 205
206 void WebRtcLoggingHandlerHost::LogMessage(const std::string& message) {
207 BrowserThread::PostTask(
208 BrowserThread::IO,
209 FROM_HERE,
210 base::Bind(
211 &WebRtcLoggingHandlerHost::AddLogMessageFromBrowser, this, message));
212 }
213
206 void WebRtcLoggingHandlerHost::OnChannelClosing() { 214 void WebRtcLoggingHandlerHost::OnChannelClosing() {
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
208 if (logging_state_ == STARTED || logging_state_ == STOPPED) { 216 if (logging_state_ == STARTED || logging_state_ == STOPPED) {
209 if (upload_log_on_render_close_) { 217 if (upload_log_on_render_close_) {
210 logging_state_ = STOPPED; 218 logging_state_ = STOPPED;
211 TriggerUploadLog(); 219 TriggerUploadLog();
212 } else { 220 } else {
213 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); 221 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload();
214 } 222 }
215 } 223 }
(...skipping 11 matching lines...) Expand all
227 IPC_BEGIN_MESSAGE_MAP_EX(WebRtcLoggingHandlerHost, message, *message_was_ok) 235 IPC_BEGIN_MESSAGE_MAP_EX(WebRtcLoggingHandlerHost, message, *message_was_ok)
228 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_AddLogMessage, OnAddLogMessage) 236 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_AddLogMessage, OnAddLogMessage)
229 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_LoggingStopped, 237 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_LoggingStopped,
230 OnLoggingStoppedInRenderer) 238 OnLoggingStoppedInRenderer)
231 IPC_MESSAGE_UNHANDLED(handled = false) 239 IPC_MESSAGE_UNHANDLED(handled = false)
232 IPC_END_MESSAGE_MAP_EX() 240 IPC_END_MESSAGE_MAP_EX()
233 241
234 return handled; 242 return handled;
235 } 243 }
236 244
245 void WebRtcLoggingHandlerHost::AddLogMessageFromBrowser(
246 const std::string& message) {
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
248 if (logging_state_ == STARTED)
249 LogToCircularBuffer(message);
250 }
251
237 void WebRtcLoggingHandlerHost::OnAddLogMessage(const std::string& message) { 252 void WebRtcLoggingHandlerHost::OnAddLogMessage(const std::string& message) {
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
239 if (logging_state_ == STARTED || logging_state_ == STOPPING) 254 if (logging_state_ == STARTED || logging_state_ == STOPPING)
240 LogToCircularBuffer(message); 255 LogToCircularBuffer(message);
241 } 256 }
242 257
243 void WebRtcLoggingHandlerHost::OnLoggingStoppedInRenderer() { 258 void WebRtcLoggingHandlerHost::OnLoggingStoppedInRenderer() {
244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
245 if (logging_state_ != STOPPING) { 260 if (logging_state_ != STOPPING) {
246 // If an out-of-order response is received, stop_callback_ may be invalid, 261 // If an out-of-order response is received, stop_callback_ may be invalid,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 void WebRtcLoggingHandlerHost::FireGenericDoneCallback( 403 void WebRtcLoggingHandlerHost::FireGenericDoneCallback(
389 GenericDoneCallback* callback, bool success, 404 GenericDoneCallback* callback, bool success,
390 const std::string& error_message) { 405 const std::string& error_message) {
391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
392 DCHECK(!(*callback).is_null()); 407 DCHECK(!(*callback).is_null());
393 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 408 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
394 base::Bind(*callback, success, 409 base::Bind(*callback, success,
395 error_message)); 410 error_message));
396 (*callback).Reset(); 411 (*callback).Reset();
397 } 412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698