| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 *message += it->first + ": " + it->second + '\n'; | 98 *message += it->first + ": " + it->second + '\n'; |
| 99 } | 99 } |
| 100 // Remove last '\n'. | 100 // Remove last '\n'. |
| 101 message->resize(message->size() - 1); | 101 message->resize(message->size() - 1); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void FireGenericDoneCallback( | 104 void FireGenericDoneCallback( |
| 105 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, | 105 const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, |
| 106 bool success, | 106 bool success, |
| 107 const std::string& error_message) { | 107 const std::string& error_message) { |
| 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 108 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 109 DCHECK(!callback.is_null()); | 109 DCHECK(!callback.is_null()); |
| 110 content::BrowserThread::PostTask( | 110 content::BrowserThread::PostTask( |
| 111 content::BrowserThread::UI, | 111 content::BrowserThread::UI, |
| 112 FROM_HERE, | 112 FROM_HERE, |
| 113 base::Bind(callback, success, error_message)); | 113 base::Bind(callback, success, error_message)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void FireAndResetGenericDoneCallback( | 116 void FireAndResetGenericDoneCallback( |
| 117 WebRtcLoggingHandlerHost::GenericDoneCallback* callback, | 117 WebRtcLoggingHandlerHost::GenericDoneCallback* callback, |
| 118 bool success, | 118 bool success, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 logging_state_(CLOSED), | 162 logging_state_(CLOSED), |
| 163 upload_log_on_render_close_(false) { | 163 upload_log_on_render_close_(false) { |
| 164 DCHECK(profile_); | 164 DCHECK(profile_); |
| 165 } | 165 } |
| 166 | 166 |
| 167 WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() {} | 167 WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() {} |
| 168 | 168 |
| 169 void WebRtcLoggingHandlerHost::SetMetaData( | 169 void WebRtcLoggingHandlerHost::SetMetaData( |
| 170 scoped_ptr<MetaDataMap> meta_data, | 170 scoped_ptr<MetaDataMap> meta_data, |
| 171 const GenericDoneCallback& callback) { | 171 const GenericDoneCallback& callback) { |
| 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 172 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 173 DCHECK(!callback.is_null()); | 173 DCHECK(!callback.is_null()); |
| 174 | 174 |
| 175 std::string error_message; | 175 std::string error_message; |
| 176 if (logging_state_ == CLOSED) { | 176 if (logging_state_ == CLOSED) { |
| 177 if (!meta_data_.get()) | 177 if (!meta_data_.get()) |
| 178 meta_data_ = meta_data.Pass(); | 178 meta_data_ = meta_data.Pass(); |
| 179 } else if (logging_state_ == STARTED) { | 179 } else if (logging_state_ == STARTED) { |
| 180 std::string meta_data_message; | 180 std::string meta_data_message; |
| 181 FormatMetaDataAsLogMessage(*meta_data.get(), &meta_data_message); | 181 FormatMetaDataAsLogMessage(*meta_data.get(), &meta_data_message); |
| 182 LogToCircularBuffer(meta_data_message); | 182 LogToCircularBuffer(meta_data_message); |
| 183 } else { | 183 } else { |
| 184 error_message = "Meta data must be set before stop or upload."; | 184 error_message = "Meta data must be set before stop or upload."; |
| 185 } | 185 } |
| 186 | 186 |
| 187 if (error_message.empty() && meta_data.get()) { | 187 if (error_message.empty() && meta_data.get()) { |
| 188 // Keep the meta data around for uploading separately from the log. | 188 // Keep the meta data around for uploading separately from the log. |
| 189 for (const auto& it : *meta_data.get()) | 189 for (const auto& it : *meta_data.get()) |
| 190 (*meta_data_.get())[it.first] = it.second; | 190 (*meta_data_.get())[it.first] = it.second; |
| 191 } | 191 } |
| 192 | 192 |
| 193 FireGenericDoneCallback(callback, error_message.empty(), error_message); | 193 FireGenericDoneCallback(callback, error_message.empty(), error_message); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void WebRtcLoggingHandlerHost::StartLogging( | 196 void WebRtcLoggingHandlerHost::StartLogging( |
| 197 const GenericDoneCallback& callback) { | 197 const GenericDoneCallback& callback) { |
| 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 198 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 199 DCHECK(!callback.is_null()); | 199 DCHECK(!callback.is_null()); |
| 200 | 200 |
| 201 if (logging_state_ != CLOSED) { | 201 if (logging_state_ != CLOSED) { |
| 202 FireGenericDoneCallback(callback, false, "A log is already open"); | 202 FireGenericDoneCallback(callback, false, "A log is already open"); |
| 203 return; | 203 return; |
| 204 } | 204 } |
| 205 | 205 |
| 206 logging_state_ = STARTING; | 206 logging_state_ = STARTING; |
| 207 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 207 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 208 &WebRtcLoggingHandlerHost::StartLoggingIfAllowed, this, callback)); | 208 &WebRtcLoggingHandlerHost::StartLoggingIfAllowed, this, callback)); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void WebRtcLoggingHandlerHost::StopLogging( | 211 void WebRtcLoggingHandlerHost::StopLogging( |
| 212 const GenericDoneCallback& callback) { | 212 const GenericDoneCallback& callback) { |
| 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 213 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 214 DCHECK(!callback.is_null()); | 214 DCHECK(!callback.is_null()); |
| 215 | 215 |
| 216 if (logging_state_ != STARTED) { | 216 if (logging_state_ != STARTED) { |
| 217 FireGenericDoneCallback(callback, false, "Logging not started"); | 217 FireGenericDoneCallback(callback, false, "Logging not started"); |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 | 220 |
| 221 stop_callback_ = callback; | 221 stop_callback_ = callback; |
| 222 logging_state_ = STOPPING; | 222 logging_state_ = STOPPING; |
| 223 Send(new WebRtcLoggingMsg_StopLogging()); | 223 Send(new WebRtcLoggingMsg_StopLogging()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) { | 226 void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) { |
| 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 227 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 228 DCHECK(!callback.is_null()); | 228 DCHECK(!callback.is_null()); |
| 229 | 229 |
| 230 if (logging_state_ != STOPPED) { | 230 if (logging_state_ != STOPPED) { |
| 231 if (!callback.is_null()) { | 231 if (!callback.is_null()) { |
| 232 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 232 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 233 base::Bind(callback, false, "", kLogNotStoppedOrNoLogOpen)); | 233 base::Bind(callback, false, "", kLogNotStoppedOrNoLogOpen)); |
| 234 } | 234 } |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 content::BrowserThread::PostTaskAndReplyWithResult( | 238 content::BrowserThread::PostTaskAndReplyWithResult( |
| 239 content::BrowserThread::FILE, | 239 content::BrowserThread::FILE, |
| 240 FROM_HERE, | 240 FROM_HERE, |
| 241 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, | 241 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, |
| 242 this), | 242 this), |
| 243 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this, callback)); | 243 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this, callback)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void WebRtcLoggingHandlerHost::UploadStoredLog( | 246 void WebRtcLoggingHandlerHost::UploadStoredLog( |
| 247 const std::string& log_id, | 247 const std::string& log_id, |
| 248 const UploadDoneCallback& callback) { | 248 const UploadDoneCallback& callback) { |
| 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 249 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 250 DCHECK(!callback.is_null()); | 250 DCHECK(!callback.is_null()); |
| 251 | 251 |
| 252 content::BrowserThread::PostTask(content::BrowserThread::FILE, | 252 content::BrowserThread::PostTask(content::BrowserThread::FILE, |
| 253 FROM_HERE, | 253 FROM_HERE, |
| 254 base::Bind(&WebRtcLoggingHandlerHost::UploadStoredLogOnFileThread, | 254 base::Bind(&WebRtcLoggingHandlerHost::UploadStoredLogOnFileThread, |
| 255 this, log_id, callback)); | 255 this, log_id, callback)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void WebRtcLoggingHandlerHost::UploadStoredLogOnFileThread( | 258 void WebRtcLoggingHandlerHost::UploadStoredLogOnFileThread( |
| 259 const std::string& log_id, | 259 const std::string& log_id, |
| 260 const UploadDoneCallback& callback) { | 260 const UploadDoneCallback& callback) { |
| 261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 261 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 262 | 262 |
| 263 WebRtcLogUploadDoneData upload_data; | 263 WebRtcLogUploadDoneData upload_data; |
| 264 upload_data.log_path = GetLogDirectoryAndEnsureExists(); | 264 upload_data.log_path = GetLogDirectoryAndEnsureExists(); |
| 265 upload_data.callback = callback; | 265 upload_data.callback = callback; |
| 266 upload_data.host = this; | 266 upload_data.host = this; |
| 267 upload_data.local_log_id = log_id; | 267 upload_data.local_log_id = log_id; |
| 268 | 268 |
| 269 g_browser_process->webrtc_log_uploader()->UploadStoredLog(upload_data); | 269 g_browser_process->webrtc_log_uploader()->UploadStoredLog(upload_data); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void WebRtcLoggingHandlerHost::UploadLogDone() { | 272 void WebRtcLoggingHandlerHost::UploadLogDone() { |
| 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 273 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 274 logging_state_ = CLOSED; | 274 logging_state_ = CLOSED; |
| 275 } | 275 } |
| 276 | 276 |
| 277 void WebRtcLoggingHandlerHost::DiscardLog(const GenericDoneCallback& callback) { | 277 void WebRtcLoggingHandlerHost::DiscardLog(const GenericDoneCallback& callback) { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 278 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 279 DCHECK(!callback.is_null()); | 279 DCHECK(!callback.is_null()); |
| 280 | 280 |
| 281 if (logging_state_ != STOPPED) { | 281 if (logging_state_ != STOPPED) { |
| 282 FireGenericDoneCallback(callback, false, kLogNotStoppedOrNoLogOpen); | 282 FireGenericDoneCallback(callback, false, kLogNotStoppedOrNoLogOpen); |
| 283 return; | 283 return; |
| 284 } | 284 } |
| 285 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); | 285 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); |
| 286 log_buffer_.reset(); | 286 log_buffer_.reset(); |
| 287 meta_data_.reset(); | 287 meta_data_.reset(); |
| 288 logging_state_ = CLOSED; | 288 logging_state_ = CLOSED; |
| 289 rtp_dump_handler_.reset(); | 289 rtp_dump_handler_.reset(); |
| 290 stop_rtp_dump_callback_.Reset(); | 290 stop_rtp_dump_callback_.Reset(); |
| 291 FireGenericDoneCallback(callback, true, ""); | 291 FireGenericDoneCallback(callback, true, ""); |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Stores the log locally using a hash of log_id + security origin. | 294 // Stores the log locally using a hash of log_id + security origin. |
| 295 void WebRtcLoggingHandlerHost::StoreLog( | 295 void WebRtcLoggingHandlerHost::StoreLog( |
| 296 const std::string& log_id, | 296 const std::string& log_id, |
| 297 const GenericDoneCallback& callback) { | 297 const GenericDoneCallback& callback) { |
| 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 298 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 299 DCHECK(!callback.is_null()); | 299 DCHECK(!callback.is_null()); |
| 300 | 300 |
| 301 if (logging_state_ != STOPPED) { | 301 if (logging_state_ != STOPPED) { |
| 302 FireGenericDoneCallback(callback, false, kLogNotStoppedOrNoLogOpen); | 302 FireGenericDoneCallback(callback, false, kLogNotStoppedOrNoLogOpen); |
| 303 return; | 303 return; |
| 304 } | 304 } |
| 305 | 305 |
| 306 if (rtp_dump_handler_) { | 306 if (rtp_dump_handler_) { |
| 307 BrowserThread::PostTask( | 307 BrowserThread::PostTask( |
| 308 BrowserThread::UI, | 308 BrowserThread::UI, |
| 309 FROM_HERE, | 309 FROM_HERE, |
| 310 base::Bind(stop_rtp_dump_callback_, true, true)); | 310 base::Bind(stop_rtp_dump_callback_, true, true)); |
| 311 | 311 |
| 312 rtp_dump_handler_->StopOngoingDumps( | 312 rtp_dump_handler_->StopOngoingDumps( |
| 313 base::Bind(&WebRtcLoggingHandlerHost::StoreLogContinue, | 313 base::Bind(&WebRtcLoggingHandlerHost::StoreLogContinue, |
| 314 this, log_id, callback)); | 314 this, log_id, callback)); |
| 315 return; | 315 return; |
| 316 } | 316 } |
| 317 | 317 |
| 318 StoreLogContinue(log_id, callback); | 318 StoreLogContinue(log_id, callback); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void WebRtcLoggingHandlerHost::StoreLogContinue( | 321 void WebRtcLoggingHandlerHost::StoreLogContinue( |
| 322 const std::string& log_id, | 322 const std::string& log_id, |
| 323 const GenericDoneCallback& callback) { | 323 const GenericDoneCallback& callback) { |
| 324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 324 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 325 DCHECK(!callback.is_null()); | 325 DCHECK(!callback.is_null()); |
| 326 | 326 |
| 327 scoped_ptr<WebRtcLogPaths> log_paths(new WebRtcLogPaths()); | 327 scoped_ptr<WebRtcLogPaths> log_paths(new WebRtcLogPaths()); |
| 328 ReleaseRtpDumps(log_paths.get()); | 328 ReleaseRtpDumps(log_paths.get()); |
| 329 | 329 |
| 330 content::BrowserThread::PostTaskAndReplyWithResult( | 330 content::BrowserThread::PostTaskAndReplyWithResult( |
| 331 content::BrowserThread::FILE, | 331 content::BrowserThread::FILE, |
| 332 FROM_HERE, | 332 FROM_HERE, |
| 333 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, | 333 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, |
| 334 this), | 334 this), |
| 335 base::Bind(&WebRtcLoggingHandlerHost::StoreLogInDirectory, this, log_id, | 335 base::Bind(&WebRtcLoggingHandlerHost::StoreLogInDirectory, this, log_id, |
| 336 Passed(&log_paths), callback)); | 336 Passed(&log_paths), callback)); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void WebRtcLoggingHandlerHost::LogMessage(const std::string& message) { | 339 void WebRtcLoggingHandlerHost::LogMessage(const std::string& message) { |
| 340 BrowserThread::PostTask( | 340 BrowserThread::PostTask( |
| 341 BrowserThread::IO, | 341 BrowserThread::IO, |
| 342 FROM_HERE, | 342 FROM_HERE, |
| 343 base::Bind( | 343 base::Bind( |
| 344 &WebRtcLoggingHandlerHost::AddLogMessageFromBrowser, | 344 &WebRtcLoggingHandlerHost::AddLogMessageFromBrowser, |
| 345 this, | 345 this, |
| 346 WebRtcLoggingMessageData(base::Time::Now(), message))); | 346 WebRtcLoggingMessageData(base::Time::Now(), message))); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void WebRtcLoggingHandlerHost::StartRtpDump( | 349 void WebRtcLoggingHandlerHost::StartRtpDump( |
| 350 RtpDumpType type, | 350 RtpDumpType type, |
| 351 const GenericDoneCallback& callback, | 351 const GenericDoneCallback& callback, |
| 352 const content::RenderProcessHost::WebRtcStopRtpDumpCallback& | 352 const content::RenderProcessHost::WebRtcStopRtpDumpCallback& |
| 353 stop_callback) { | 353 stop_callback) { |
| 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 354 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 355 DCHECK(stop_rtp_dump_callback_.is_null() || | 355 DCHECK(stop_rtp_dump_callback_.is_null() || |
| 356 stop_rtp_dump_callback_.Equals(stop_callback)); | 356 stop_rtp_dump_callback_.Equals(stop_callback)); |
| 357 | 357 |
| 358 stop_rtp_dump_callback_ = stop_callback; | 358 stop_rtp_dump_callback_ = stop_callback; |
| 359 | 359 |
| 360 if (!rtp_dump_handler_) { | 360 if (!rtp_dump_handler_) { |
| 361 content::BrowserThread::PostTaskAndReplyWithResult( | 361 content::BrowserThread::PostTaskAndReplyWithResult( |
| 362 content::BrowserThread::FILE, | 362 content::BrowserThread::FILE, |
| 363 FROM_HERE, | 363 FROM_HERE, |
| 364 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, | 364 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, |
| 365 this), | 365 this), |
| 366 base::Bind(&WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart, | 366 base::Bind(&WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart, |
| 367 this, | 367 this, |
| 368 type, | 368 type, |
| 369 callback)); | 369 callback)); |
| 370 return; | 370 return; |
| 371 } | 371 } |
| 372 | 372 |
| 373 DoStartRtpDump(type, callback); | 373 DoStartRtpDump(type, callback); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void WebRtcLoggingHandlerHost::StopRtpDump( | 376 void WebRtcLoggingHandlerHost::StopRtpDump( |
| 377 RtpDumpType type, | 377 RtpDumpType type, |
| 378 const GenericDoneCallback& callback) { | 378 const GenericDoneCallback& callback) { |
| 379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 379 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 380 DCHECK(!callback.is_null()); | 380 DCHECK(!callback.is_null()); |
| 381 | 381 |
| 382 if (!rtp_dump_handler_) { | 382 if (!rtp_dump_handler_) { |
| 383 FireGenericDoneCallback(callback, false, "RTP dump has not been started."); | 383 FireGenericDoneCallback(callback, false, "RTP dump has not been started."); |
| 384 return; | 384 return; |
| 385 } | 385 } |
| 386 | 386 |
| 387 if (!stop_rtp_dump_callback_.is_null()) { | 387 if (!stop_rtp_dump_callback_.is_null()) { |
| 388 BrowserThread::PostTask( | 388 BrowserThread::PostTask( |
| 389 BrowserThread::UI, | 389 BrowserThread::UI, |
| 390 FROM_HERE, | 390 FROM_HERE, |
| 391 base::Bind(stop_rtp_dump_callback_, | 391 base::Bind(stop_rtp_dump_callback_, |
| 392 type == RTP_DUMP_INCOMING || type == RTP_DUMP_BOTH, | 392 type == RTP_DUMP_INCOMING || type == RTP_DUMP_BOTH, |
| 393 type == RTP_DUMP_OUTGOING || type == RTP_DUMP_BOTH)); | 393 type == RTP_DUMP_OUTGOING || type == RTP_DUMP_BOTH)); |
| 394 } | 394 } |
| 395 | 395 |
| 396 rtp_dump_handler_->StopDump(type, callback); | 396 rtp_dump_handler_->StopDump(type, callback); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void WebRtcLoggingHandlerHost::OnRtpPacket(scoped_ptr<uint8[]> packet_header, | 399 void WebRtcLoggingHandlerHost::OnRtpPacket(scoped_ptr<uint8[]> packet_header, |
| 400 size_t header_length, | 400 size_t header_length, |
| 401 size_t packet_length, | 401 size_t packet_length, |
| 402 bool incoming) { | 402 bool incoming) { |
| 403 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 403 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 404 | 404 |
| 405 BrowserThread::PostTask( | 405 BrowserThread::PostTask( |
| 406 BrowserThread::IO, | 406 BrowserThread::IO, |
| 407 FROM_HERE, | 407 FROM_HERE, |
| 408 base::Bind(&WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread, | 408 base::Bind(&WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread, |
| 409 this, | 409 this, |
| 410 base::Passed(&packet_header), | 410 base::Passed(&packet_header), |
| 411 header_length, | 411 header_length, |
| 412 packet_length, | 412 packet_length, |
| 413 incoming)); | 413 incoming)); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread( | 416 void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread( |
| 417 scoped_ptr<uint8[]> packet_header, | 417 scoped_ptr<uint8[]> packet_header, |
| 418 size_t header_length, | 418 size_t header_length, |
| 419 size_t packet_length, | 419 size_t packet_length, |
| 420 bool incoming) { | 420 bool incoming) { |
| 421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 421 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 422 | 422 |
| 423 // |rtp_dump_handler_| could be NULL if we are waiting for the FILE thread to | 423 // |rtp_dump_handler_| could be NULL if we are waiting for the FILE thread to |
| 424 // create/ensure the log directory. | 424 // create/ensure the log directory. |
| 425 if (rtp_dump_handler_) { | 425 if (rtp_dump_handler_) { |
| 426 rtp_dump_handler_->OnRtpPacket( | 426 rtp_dump_handler_->OnRtpPacket( |
| 427 packet_header.get(), header_length, packet_length, incoming); | 427 packet_header.get(), header_length, packet_length, incoming); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 void WebRtcLoggingHandlerHost::OnChannelClosing() { | 431 void WebRtcLoggingHandlerHost::OnChannelClosing() { |
| 432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 432 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 433 if (logging_state_ == STARTED || logging_state_ == STOPPED) { | 433 if (logging_state_ == STARTED || logging_state_ == STOPPED) { |
| 434 if (upload_log_on_render_close_) { | 434 if (upload_log_on_render_close_) { |
| 435 logging_started_time_ = base::Time(); | 435 logging_started_time_ = base::Time(); |
| 436 | 436 |
| 437 content::BrowserThread::PostTaskAndReplyWithResult( | 437 content::BrowserThread::PostTaskAndReplyWithResult( |
| 438 content::BrowserThread::FILE, | 438 content::BrowserThread::FILE, |
| 439 FROM_HERE, | 439 FROM_HERE, |
| 440 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, | 440 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, |
| 441 this), | 441 this), |
| 442 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this, | 442 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this, |
| 443 UploadDoneCallback())); | 443 UploadDoneCallback())); |
| 444 } else { | 444 } else { |
| 445 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); | 445 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); |
| 446 } | 446 } |
| 447 } | 447 } |
| 448 content::BrowserMessageFilter::OnChannelClosing(); | 448 content::BrowserMessageFilter::OnChannelClosing(); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void WebRtcLoggingHandlerHost::OnDestruct() const { | 451 void WebRtcLoggingHandlerHost::OnDestruct() const { |
| 452 BrowserThread::DeleteOnIOThread::Destruct(this); | 452 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 453 } | 453 } |
| 454 | 454 |
| 455 bool WebRtcLoggingHandlerHost::OnMessageReceived(const IPC::Message& message) { | 455 bool WebRtcLoggingHandlerHost::OnMessageReceived(const IPC::Message& message) { |
| 456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 456 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 457 bool handled = true; | 457 bool handled = true; |
| 458 IPC_BEGIN_MESSAGE_MAP(WebRtcLoggingHandlerHost, message) | 458 IPC_BEGIN_MESSAGE_MAP(WebRtcLoggingHandlerHost, message) |
| 459 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_AddLogMessages, OnAddLogMessages) | 459 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_AddLogMessages, OnAddLogMessages) |
| 460 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_LoggingStopped, | 460 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_LoggingStopped, |
| 461 OnLoggingStoppedInRenderer) | 461 OnLoggingStoppedInRenderer) |
| 462 IPC_MESSAGE_UNHANDLED(handled = false) | 462 IPC_MESSAGE_UNHANDLED(handled = false) |
| 463 IPC_END_MESSAGE_MAP() | 463 IPC_END_MESSAGE_MAP() |
| 464 | 464 |
| 465 return handled; | 465 return handled; |
| 466 } | 466 } |
| 467 | 467 |
| 468 void WebRtcLoggingHandlerHost::AddLogMessageFromBrowser( | 468 void WebRtcLoggingHandlerHost::AddLogMessageFromBrowser( |
| 469 const WebRtcLoggingMessageData& message) { | 469 const WebRtcLoggingMessageData& message) { |
| 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 470 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 471 if (logging_state_ == STARTED) | 471 if (logging_state_ == STARTED) |
| 472 LogToCircularBuffer(message.Format(logging_started_time_)); | 472 LogToCircularBuffer(message.Format(logging_started_time_)); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void WebRtcLoggingHandlerHost::OnAddLogMessages( | 475 void WebRtcLoggingHandlerHost::OnAddLogMessages( |
| 476 const std::vector<WebRtcLoggingMessageData>& messages) { | 476 const std::vector<WebRtcLoggingMessageData>& messages) { |
| 477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 477 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 478 if (logging_state_ == STARTED || logging_state_ == STOPPING) { | 478 if (logging_state_ == STARTED || logging_state_ == STOPPING) { |
| 479 for (size_t i = 0; i < messages.size(); ++i) { | 479 for (size_t i = 0; i < messages.size(); ++i) { |
| 480 LogToCircularBuffer(messages[i].Format(logging_started_time_)); | 480 LogToCircularBuffer(messages[i].Format(logging_started_time_)); |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 | 484 |
| 485 void WebRtcLoggingHandlerHost::OnLoggingStoppedInRenderer() { | 485 void WebRtcLoggingHandlerHost::OnLoggingStoppedInRenderer() { |
| 486 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 486 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 487 if (logging_state_ != STOPPING) { | 487 if (logging_state_ != STOPPING) { |
| 488 // If an out-of-order response is received, stop_callback_ may be invalid, | 488 // If an out-of-order response is received, stop_callback_ may be invalid, |
| 489 // and must not be invoked. | 489 // and must not be invoked. |
| 490 DLOG(ERROR) << "OnLoggingStoppedInRenderer invoked in state " | 490 DLOG(ERROR) << "OnLoggingStoppedInRenderer invoked in state " |
| 491 << logging_state_; | 491 << logging_state_; |
| 492 BadMessageReceived(); | 492 BadMessageReceived(); |
| 493 return; | 493 return; |
| 494 } | 494 } |
| 495 logging_started_time_ = base::Time(); | 495 logging_started_time_ = base::Time(); |
| 496 logging_state_ = STOPPED; | 496 logging_state_ = STOPPED; |
| 497 FireAndResetGenericDoneCallback(&stop_callback_, true, ""); | 497 FireAndResetGenericDoneCallback(&stop_callback_, true, ""); |
| 498 } | 498 } |
| 499 | 499 |
| 500 void WebRtcLoggingHandlerHost::StartLoggingIfAllowed( | 500 void WebRtcLoggingHandlerHost::StartLoggingIfAllowed( |
| 501 const GenericDoneCallback& callback) { | 501 const GenericDoneCallback& callback) { |
| 502 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 502 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 503 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 503 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
| 504 &WebRtcLoggingHandlerHost::DoStartLogging, this, | 504 &WebRtcLoggingHandlerHost::DoStartLogging, this, |
| 505 g_browser_process->webrtc_log_uploader()->ApplyForStartLogging(), | 505 g_browser_process->webrtc_log_uploader()->ApplyForStartLogging(), |
| 506 callback)); | 506 callback)); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void WebRtcLoggingHandlerHost::DoStartLogging( | 509 void WebRtcLoggingHandlerHost::DoStartLogging( |
| 510 bool permissions_granted, | 510 bool permissions_granted, |
| 511 const GenericDoneCallback& callback) { | 511 const GenericDoneCallback& callback) { |
| 512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 512 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 513 if (logging_state_ != STARTING) { | 513 if (logging_state_ != STARTING) { |
| 514 FireGenericDoneCallback(callback, false, "Logging cancelled."); | 514 FireGenericDoneCallback(callback, false, "Logging cancelled."); |
| 515 return; | 515 return; |
| 516 } | 516 } |
| 517 | 517 |
| 518 if (!permissions_granted) { | 518 if (!permissions_granted) { |
| 519 logging_state_ = CLOSED; | 519 logging_state_ = CLOSED; |
| 520 FireGenericDoneCallback(callback, false, | 520 FireGenericDoneCallback(callback, false, |
| 521 "Cannot start, maybe the maximum number of " | 521 "Cannot start, maybe the maximum number of " |
| 522 "simultaneuos logs has been reached."); | 522 "simultaneuos logs has been reached."); |
| 523 return; | 523 return; |
| 524 } | 524 } |
| 525 | 525 |
| 526 DCHECK(!log_buffer_.get()); | 526 DCHECK(!log_buffer_.get()); |
| 527 log_buffer_.reset(new WebRtcLogBuffer()); | 527 log_buffer_.reset(new WebRtcLogBuffer()); |
| 528 if (!meta_data_.get()) | 528 if (!meta_data_.get()) |
| 529 meta_data_.reset(new MetaDataMap()); | 529 meta_data_.reset(new MetaDataMap()); |
| 530 | 530 |
| 531 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( | 531 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( |
| 532 &WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread, this, callback)); | 532 &WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread, this, callback)); |
| 533 } | 533 } |
| 534 | 534 |
| 535 void WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread( | 535 void WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread( |
| 536 const GenericDoneCallback& callback) { | 536 const GenericDoneCallback& callback) { |
| 537 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 537 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 538 | 538 |
| 539 net::NetworkInterfaceList network_list; | 539 net::NetworkInterfaceList network_list; |
| 540 net::GetNetworkList(&network_list, | 540 net::GetNetworkList(&network_list, |
| 541 net::EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES); | 541 net::EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES); |
| 542 | 542 |
| 543 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 543 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
| 544 &WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread, this, network_list, | 544 &WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread, this, network_list, |
| 545 callback)); | 545 callback)); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread( | 548 void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread( |
| 549 const net::NetworkInterfaceList& network_list, | 549 const net::NetworkInterfaceList& network_list, |
| 550 const GenericDoneCallback& callback) { | 550 const GenericDoneCallback& callback) { |
| 551 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 551 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 552 if (logging_state_ != STARTING) { | 552 if (logging_state_ != STARTING) { |
| 553 FireGenericDoneCallback(callback, false, "Logging cancelled."); | 553 FireGenericDoneCallback(callback, false, "Logging cancelled."); |
| 554 return; | 554 return; |
| 555 } | 555 } |
| 556 | 556 |
| 557 // Log start time (current time). We don't use base/i18n/time_formatting.h | 557 // Log start time (current time). We don't use base/i18n/time_formatting.h |
| 558 // here because we don't want the format of the current locale. | 558 // here because we don't want the format of the current locale. |
| 559 base::Time::Exploded now = {0}; | 559 base::Time::Exploded now = {0}; |
| 560 base::Time::Now().LocalExplode(&now); | 560 base::Time::Now().LocalExplode(&now); |
| 561 LogToCircularBuffer(base::StringPrintf( | 561 LogToCircularBuffer(base::StringPrintf( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 "Name: " + it->friendly_name + ", Address: " + | 630 "Name: " + it->friendly_name + ", Address: " + |
| 631 IPAddressToSensitiveString(it->address) + ", Type: " + | 631 IPAddressToSensitiveString(it->address) + ", Type: " + |
| 632 net::NetworkChangeNotifier::ConnectionTypeToString(it->type)); | 632 net::NetworkChangeNotifier::ConnectionTypeToString(it->type)); |
| 633 } | 633 } |
| 634 | 634 |
| 635 NotifyLoggingStarted(callback); | 635 NotifyLoggingStarted(callback); |
| 636 } | 636 } |
| 637 | 637 |
| 638 void WebRtcLoggingHandlerHost::NotifyLoggingStarted( | 638 void WebRtcLoggingHandlerHost::NotifyLoggingStarted( |
| 639 const GenericDoneCallback& callback) { | 639 const GenericDoneCallback& callback) { |
| 640 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 640 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 641 DCHECK_EQ(logging_state_, STARTING); | 641 DCHECK_EQ(logging_state_, STARTING); |
| 642 Send(new WebRtcLoggingMsg_StartLogging()); | 642 Send(new WebRtcLoggingMsg_StartLogging()); |
| 643 logging_started_time_ = base::Time::Now(); | 643 logging_started_time_ = base::Time::Now(); |
| 644 logging_state_ = STARTED; | 644 logging_state_ = STARTED; |
| 645 FireGenericDoneCallback(callback, true, ""); | 645 FireGenericDoneCallback(callback, true, ""); |
| 646 } | 646 } |
| 647 | 647 |
| 648 void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) { | 648 void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) { |
| 649 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 649 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 650 DCHECK_NE(logging_state_, CLOSED); | 650 DCHECK_NE(logging_state_, CLOSED); |
| 651 log_buffer_->Log(message); | 651 log_buffer_->Log(message); |
| 652 } | 652 } |
| 653 | 653 |
| 654 base::FilePath WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists() { | 654 base::FilePath WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists() { |
| 655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 655 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 656 base::FilePath log_dir_path = | 656 base::FilePath log_dir_path = |
| 657 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()); | 657 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()); |
| 658 base::File::Error error; | 658 base::File::Error error; |
| 659 if (!base::CreateDirectoryAndGetError(log_dir_path, &error)) { | 659 if (!base::CreateDirectoryAndGetError(log_dir_path, &error)) { |
| 660 DLOG(ERROR) << "Could not create WebRTC log directory, error: " << error; | 660 DLOG(ERROR) << "Could not create WebRTC log directory, error: " << error; |
| 661 return base::FilePath(); | 661 return base::FilePath(); |
| 662 } | 662 } |
| 663 return log_dir_path; | 663 return log_dir_path; |
| 664 } | 664 } |
| 665 | 665 |
| 666 void WebRtcLoggingHandlerHost::TriggerUpload( | 666 void WebRtcLoggingHandlerHost::TriggerUpload( |
| 667 const UploadDoneCallback& callback, | 667 const UploadDoneCallback& callback, |
| 668 const base::FilePath& log_directory) { | 668 const base::FilePath& log_directory) { |
| 669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 669 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 670 | 670 |
| 671 if (rtp_dump_handler_) { | 671 if (rtp_dump_handler_) { |
| 672 BrowserThread::PostTask( | 672 BrowserThread::PostTask( |
| 673 BrowserThread::UI, | 673 BrowserThread::UI, |
| 674 FROM_HERE, | 674 FROM_HERE, |
| 675 base::Bind(stop_rtp_dump_callback_, true, true)); | 675 base::Bind(stop_rtp_dump_callback_, true, true)); |
| 676 | 676 |
| 677 rtp_dump_handler_->StopOngoingDumps( | 677 rtp_dump_handler_->StopOngoingDumps( |
| 678 base::Bind(&WebRtcLoggingHandlerHost::DoUploadLogAndRtpDumps, | 678 base::Bind(&WebRtcLoggingHandlerHost::DoUploadLogAndRtpDumps, |
| 679 this, | 679 this, |
| 680 log_directory, | 680 log_directory, |
| 681 callback)); | 681 callback)); |
| 682 return; | 682 return; |
| 683 } | 683 } |
| 684 | 684 |
| 685 DoUploadLogAndRtpDumps(log_directory, callback); | 685 DoUploadLogAndRtpDumps(log_directory, callback); |
| 686 } | 686 } |
| 687 | 687 |
| 688 void WebRtcLoggingHandlerHost::StoreLogInDirectory( | 688 void WebRtcLoggingHandlerHost::StoreLogInDirectory( |
| 689 const std::string& log_id, | 689 const std::string& log_id, |
| 690 scoped_ptr<WebRtcLogPaths> log_paths, | 690 scoped_ptr<WebRtcLogPaths> log_paths, |
| 691 const GenericDoneCallback& done_callback, | 691 const GenericDoneCallback& done_callback, |
| 692 const base::FilePath& directory) { | 692 const base::FilePath& directory) { |
| 693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 693 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 694 log_paths->log_path = directory; | 694 log_paths->log_path = directory; |
| 695 | 695 |
| 696 log_buffer_->SetComplete(); | 696 log_buffer_->SetComplete(); |
| 697 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 697 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 698 base::Bind(&WebRtcLogUploader::LoggingStoppedDoStore, | 698 base::Bind(&WebRtcLogUploader::LoggingStoppedDoStore, |
| 699 base::Unretained(g_browser_process->webrtc_log_uploader()), | 699 base::Unretained(g_browser_process->webrtc_log_uploader()), |
| 700 *log_paths.get(), log_id, Passed(&log_buffer_), Passed(&meta_data_), | 700 *log_paths.get(), log_id, Passed(&log_buffer_), Passed(&meta_data_), |
| 701 done_callback)); | 701 done_callback)); |
| 702 | 702 |
| 703 logging_state_ = CLOSED; | 703 logging_state_ = CLOSED; |
| 704 } | 704 } |
| 705 | 705 |
| 706 void WebRtcLoggingHandlerHost::DoUploadLogAndRtpDumps( | 706 void WebRtcLoggingHandlerHost::DoUploadLogAndRtpDumps( |
| 707 const base::FilePath& log_directory, | 707 const base::FilePath& log_directory, |
| 708 const UploadDoneCallback& callback) { | 708 const UploadDoneCallback& callback) { |
| 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 709 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 710 | 710 |
| 711 WebRtcLogUploadDoneData upload_done_data; | 711 WebRtcLogUploadDoneData upload_done_data; |
| 712 upload_done_data.log_path = log_directory; | 712 upload_done_data.log_path = log_directory; |
| 713 upload_done_data.callback = callback; | 713 upload_done_data.callback = callback; |
| 714 upload_done_data.host = this; | 714 upload_done_data.host = this; |
| 715 ReleaseRtpDumps(&upload_done_data); | 715 ReleaseRtpDumps(&upload_done_data); |
| 716 | 716 |
| 717 log_buffer_->SetComplete(); | 717 log_buffer_->SetComplete(); |
| 718 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( | 718 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( |
| 719 &WebRtcLogUploader::LoggingStoppedDoUpload, | 719 &WebRtcLogUploader::LoggingStoppedDoUpload, |
| 720 base::Unretained(g_browser_process->webrtc_log_uploader()), | 720 base::Unretained(g_browser_process->webrtc_log_uploader()), |
| 721 Passed(&log_buffer_), | 721 Passed(&log_buffer_), |
| 722 Passed(&meta_data_), | 722 Passed(&meta_data_), |
| 723 upload_done_data)); | 723 upload_done_data)); |
| 724 | 724 |
| 725 logging_state_ = CLOSED; | 725 logging_state_ = CLOSED; |
| 726 } | 726 } |
| 727 | 727 |
| 728 void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart( | 728 void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart( |
| 729 RtpDumpType type, | 729 RtpDumpType type, |
| 730 const GenericDoneCallback& callback, | 730 const GenericDoneCallback& callback, |
| 731 const base::FilePath& dump_dir) { | 731 const base::FilePath& dump_dir) { |
| 732 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 732 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 733 | 733 |
| 734 // |rtp_dump_handler_| may be non-NULL if StartRtpDump is called again before | 734 // |rtp_dump_handler_| may be non-NULL if StartRtpDump is called again before |
| 735 // GetLogDirectoryAndEnsureExists returns on the FILE thread for a previous | 735 // GetLogDirectoryAndEnsureExists returns on the FILE thread for a previous |
| 736 // StartRtpDump. | 736 // StartRtpDump. |
| 737 if (!rtp_dump_handler_) | 737 if (!rtp_dump_handler_) |
| 738 rtp_dump_handler_.reset(new WebRtcRtpDumpHandler(dump_dir)); | 738 rtp_dump_handler_.reset(new WebRtcRtpDumpHandler(dump_dir)); |
| 739 | 739 |
| 740 DoStartRtpDump(type, callback); | 740 DoStartRtpDump(type, callback); |
| 741 } | 741 } |
| 742 | 742 |
| 743 void WebRtcLoggingHandlerHost::DoStartRtpDump( | 743 void WebRtcLoggingHandlerHost::DoStartRtpDump( |
| 744 RtpDumpType type, const GenericDoneCallback& callback) { | 744 RtpDumpType type, const GenericDoneCallback& callback) { |
| 745 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 745 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 746 DCHECK(rtp_dump_handler_); | 746 DCHECK(rtp_dump_handler_); |
| 747 | 747 |
| 748 std::string error; | 748 std::string error; |
| 749 bool result = rtp_dump_handler_->StartDump(type, &error); | 749 bool result = rtp_dump_handler_->StartDump(type, &error); |
| 750 FireGenericDoneCallback(callback, result, error); | 750 FireGenericDoneCallback(callback, result, error); |
| 751 } | 751 } |
| 752 | 752 |
| 753 bool WebRtcLoggingHandlerHost::ReleaseRtpDumps(WebRtcLogPaths* log_paths) { | 753 bool WebRtcLoggingHandlerHost::ReleaseRtpDumps(WebRtcLogPaths* log_paths) { |
| 754 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 754 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 755 DCHECK(log_paths); | 755 DCHECK(log_paths); |
| 756 | 756 |
| 757 if (!rtp_dump_handler_) | 757 if (!rtp_dump_handler_) |
| 758 return false; | 758 return false; |
| 759 | 759 |
| 760 WebRtcRtpDumpHandler::ReleasedDumps rtp_dumps( | 760 WebRtcRtpDumpHandler::ReleasedDumps rtp_dumps( |
| 761 rtp_dump_handler_->ReleaseDumps()); | 761 rtp_dump_handler_->ReleaseDumps()); |
| 762 log_paths->incoming_rtp_dump = rtp_dumps.incoming_dump_path; | 762 log_paths->incoming_rtp_dump = rtp_dumps.incoming_dump_path; |
| 763 log_paths->outgoing_rtp_dump = rtp_dumps.outgoing_dump_path; | 763 log_paths->outgoing_rtp_dump = rtp_dumps.outgoing_dump_path; |
| 764 | 764 |
| 765 rtp_dump_handler_.reset(); | 765 rtp_dump_handler_.reset(); |
| 766 stop_rtp_dump_callback_.Reset(); | 766 stop_rtp_dump_callback_.Reset(); |
| 767 | 767 |
| 768 return true; | 768 return true; |
| 769 } | 769 } |
| OLD | NEW |