| OLD | NEW |
| 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 Loading... |
| 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 | |
| 214 void WebRtcLoggingHandlerHost::OnChannelClosing() { | 206 void WebRtcLoggingHandlerHost::OnChannelClosing() { |
| 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 216 if (logging_state_ == STARTED || logging_state_ == STOPPED) { | 208 if (logging_state_ == STARTED || logging_state_ == STOPPED) { |
| 217 if (upload_log_on_render_close_) { | 209 if (upload_log_on_render_close_) { |
| 218 logging_state_ = STOPPED; | 210 logging_state_ = STOPPED; |
| 219 TriggerUploadLog(); | 211 TriggerUploadLog(); |
| 220 } else { | 212 } else { |
| 221 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); | 213 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); |
| 222 } | 214 } |
| 223 } | 215 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 235 IPC_BEGIN_MESSAGE_MAP_EX(WebRtcLoggingHandlerHost, message, *message_was_ok) | 227 IPC_BEGIN_MESSAGE_MAP_EX(WebRtcLoggingHandlerHost, message, *message_was_ok) |
| 236 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_AddLogMessage, OnAddLogMessage) | 228 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_AddLogMessage, OnAddLogMessage) |
| 237 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_LoggingStopped, | 229 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_LoggingStopped, |
| 238 OnLoggingStoppedInRenderer) | 230 OnLoggingStoppedInRenderer) |
| 239 IPC_MESSAGE_UNHANDLED(handled = false) | 231 IPC_MESSAGE_UNHANDLED(handled = false) |
| 240 IPC_END_MESSAGE_MAP_EX() | 232 IPC_END_MESSAGE_MAP_EX() |
| 241 | 233 |
| 242 return handled; | 234 return handled; |
| 243 } | 235 } |
| 244 | 236 |
| 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 | |
| 252 void WebRtcLoggingHandlerHost::OnAddLogMessage(const std::string& message) { | 237 void WebRtcLoggingHandlerHost::OnAddLogMessage(const std::string& message) { |
| 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 254 if (logging_state_ == STARTED || logging_state_ == STOPPING) | 239 if (logging_state_ == STARTED || logging_state_ == STOPPING) |
| 255 LogToCircularBuffer(message); | 240 LogToCircularBuffer(message); |
| 256 } | 241 } |
| 257 | 242 |
| 258 void WebRtcLoggingHandlerHost::OnLoggingStoppedInRenderer() { | 243 void WebRtcLoggingHandlerHost::OnLoggingStoppedInRenderer() { |
| 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 260 if (logging_state_ != STOPPING) { | 245 if (logging_state_ != STOPPING) { |
| 261 // If an out-of-order response is received, stop_callback_ may be invalid, | 246 // 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 Loading... |
| 403 void WebRtcLoggingHandlerHost::FireGenericDoneCallback( | 388 void WebRtcLoggingHandlerHost::FireGenericDoneCallback( |
| 404 GenericDoneCallback* callback, bool success, | 389 GenericDoneCallback* callback, bool success, |
| 405 const std::string& error_message) { | 390 const std::string& error_message) { |
| 406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 407 DCHECK(!(*callback).is_null()); | 392 DCHECK(!(*callback).is_null()); |
| 408 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 393 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 409 base::Bind(*callback, success, | 394 base::Bind(*callback, success, |
| 410 error_message)); | 395 error_message)); |
| 411 (*callback).Reset(); | 396 (*callback).Reset(); |
| 412 } | 397 } |
| OLD | NEW |