| 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" | |
| 11 #include "base/cpu.h" | 10 #include "base/cpu.h" |
| 12 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 14 #include "base/prefs/pref_service.h" | |
| 15 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 17 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 18 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 20 #include "chrome/browser/media/webrtc_log_list.h" | 17 #include "chrome/browser/media/webrtc_log_list.h" |
| 21 #include "chrome/browser/media/webrtc_log_uploader.h" | 18 #include "chrome/browser/media/webrtc_log_uploader.h" |
| 22 #include "chrome/browser/media/webrtc_rtp_dump_handler.h" | 19 #include "chrome/browser/media/webrtc_rtp_dump_handler.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/common/chrome_switches.h" | |
| 25 #include "chrome/common/media/webrtc_logging_messages.h" | 21 #include "chrome/common/media/webrtc_logging_messages.h" |
| 26 #include "chrome/common/partial_circular_buffer.h" | 22 #include "chrome/common/partial_circular_buffer.h" |
| 27 #include "chrome/common/pref_names.h" | |
| 28 #include "chromeos/settings/cros_settings_names.h" | |
| 29 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/content_browser_client.h" | 24 #include "content/public/browser/content_browser_client.h" |
| 31 #include "content/public/browser/gpu_data_manager.h" | 25 #include "content/public/browser/gpu_data_manager.h" |
| 32 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
| 33 #include "gpu/config/gpu_info.h" | 27 #include "gpu/config/gpu_info.h" |
| 34 #include "net/base/address_family.h" | 28 #include "net/base/address_family.h" |
| 35 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
| 36 | 30 |
| 37 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
| 38 #include "base/linux_util.h" | 32 #include "base/linux_util.h" |
| 39 #endif | 33 #endif |
| 40 | 34 |
| 41 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
| 42 #include "base/mac/mac_util.h" | 36 #include "base/mac/mac_util.h" |
| 43 #endif | 37 #endif |
| 44 | 38 |
| 45 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
| 40 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 41 #include "chromeos/settings/cros_settings_names.h" |
| 46 #include "chromeos/system/statistics_provider.h" | 42 #include "chromeos/system/statistics_provider.h" |
| 47 #endif | 43 #endif |
| 48 | 44 |
| 49 using base::IntToString; | 45 using base::IntToString; |
| 50 using content::BrowserThread; | 46 using content::BrowserThread; |
| 51 | 47 |
| 52 namespace { | 48 namespace { |
| 53 | 49 |
| 54 #if defined(OS_ANDROID) | 50 #if defined(OS_ANDROID) |
| 55 const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB | 51 const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 meta_data_ = meta_data; | 127 meta_data_ = meta_data; |
| 132 } else if (logging_state_ == STARTED) { | 128 } else if (logging_state_ == STARTED) { |
| 133 meta_data_ = meta_data; | 129 meta_data_ = meta_data; |
| 134 std::string meta_data_message; | 130 std::string meta_data_message; |
| 135 FormatMetaDataAsLogMessage(meta_data_, &meta_data_message); | 131 FormatMetaDataAsLogMessage(meta_data_, &meta_data_message); |
| 136 LogToCircularBuffer(meta_data_message); | 132 LogToCircularBuffer(meta_data_message); |
| 137 } else { | 133 } else { |
| 138 error_message = "Meta data must be set before stop or upload."; | 134 error_message = "Meta data must be set before stop or upload."; |
| 139 } | 135 } |
| 140 bool success = error_message.empty(); | 136 bool success = error_message.empty(); |
| 141 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 137 BrowserThread::PostTask(BrowserThread::UI, |
| 142 base::Bind(callback, success, | 138 FROM_HERE, |
| 143 error_message)); | 139 base::Bind(callback, success, error_message)); |
| 144 } | 140 } |
| 145 | 141 |
| 146 void WebRtcLoggingHandlerHost::StartLogging( | 142 void WebRtcLoggingHandlerHost::StartLogging( |
| 147 const GenericDoneCallback& callback) { | 143 const GenericDoneCallback& callback) { |
| 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 149 DCHECK(!callback.is_null()); | 145 DCHECK(!callback.is_null()); |
| 150 | 146 |
| 151 start_callback_ = callback; | 147 start_callback_ = callback; |
| 152 if (logging_state_ != CLOSED) { | 148 if (logging_state_ != CLOSED) { |
| 153 FireGenericDoneCallback(&start_callback_, false, "A log is already open"); | 149 FireGenericDoneCallback(&start_callback_, false, "A log is already open"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 171 logging_state_ = STOPPING; | 167 logging_state_ = STOPPING; |
| 172 Send(new WebRtcLoggingMsg_StopLogging()); | 168 Send(new WebRtcLoggingMsg_StopLogging()); |
| 173 } | 169 } |
| 174 | 170 |
| 175 void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) { | 171 void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) { |
| 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 177 DCHECK(!callback.is_null()); | 173 DCHECK(!callback.is_null()); |
| 178 | 174 |
| 179 if (logging_state_ != STOPPED) { | 175 if (logging_state_ != STOPPED) { |
| 180 if (!callback.is_null()) { | 176 if (!callback.is_null()) { |
| 181 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 177 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 182 base::Bind(callback, false, "", kLogNotStoppedOrNoLogOpen)); | 178 base::Bind(callback, false, "", kLogNotStoppedOrNoLogOpen)); |
| 183 } | 179 } |
| 184 return; | 180 return; |
| 185 } | 181 } |
| 186 | 182 |
| 187 upload_callback_ = callback; | 183 upload_callback_ = callback; |
| 188 logging_state_ = UPLOADING; | 184 logging_state_ = UPLOADING; |
| 189 content::BrowserThread::PostTaskAndReplyWithResult( | 185 base::PostTaskAndReplyWithResult( |
| 190 content::BrowserThread::FILE, | 186 BrowserThread::GetBlockingPool(), |
| 191 FROM_HERE, | 187 FROM_HERE, |
| 192 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, | 188 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, |
| 193 this), | 189 this), |
| 194 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this)); | 190 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this)); |
| 195 } | 191 } |
| 196 | 192 |
| 197 void WebRtcLoggingHandlerHost::UploadLogDone() { | 193 void WebRtcLoggingHandlerHost::UploadLogDone() { |
| 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 199 logging_state_ = CLOSED; | 195 logging_state_ = CLOSED; |
| 200 } | 196 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 const GenericDoneCallback& callback, | 229 const GenericDoneCallback& callback, |
| 234 const content::RenderProcessHost::WebRtcStopRtpDumpCallback& | 230 const content::RenderProcessHost::WebRtcStopRtpDumpCallback& |
| 235 stop_callback) { | 231 stop_callback) { |
| 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 237 DCHECK(stop_rtp_dump_callback_.is_null() || | 233 DCHECK(stop_rtp_dump_callback_.is_null() || |
| 238 stop_rtp_dump_callback_.Equals(stop_callback)); | 234 stop_rtp_dump_callback_.Equals(stop_callback)); |
| 239 | 235 |
| 240 stop_rtp_dump_callback_ = stop_callback; | 236 stop_rtp_dump_callback_ = stop_callback; |
| 241 | 237 |
| 242 if (!rtp_dump_handler_) { | 238 if (!rtp_dump_handler_) { |
| 243 content::BrowserThread::PostTaskAndReplyWithResult( | 239 base::PostTaskAndReplyWithResult( |
| 244 content::BrowserThread::FILE, | 240 BrowserThread::GetBlockingPool(), |
| 245 FROM_HERE, | 241 FROM_HERE, |
| 246 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, | 242 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, |
| 247 this), | 243 this), |
| 248 base::Bind(&WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart, | 244 base::Bind(&WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart, |
| 249 this, | 245 this, |
| 250 type, | 246 type, |
| 251 callback)); | 247 callback)); |
| 252 return; | 248 return; |
| 253 } | 249 } |
| 254 | 250 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 incoming)); | 297 incoming)); |
| 302 } | 298 } |
| 303 | 299 |
| 304 void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread( | 300 void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread( |
| 305 scoped_ptr<uint8[]> packet_header, | 301 scoped_ptr<uint8[]> packet_header, |
| 306 size_t header_length, | 302 size_t header_length, |
| 307 size_t packet_length, | 303 size_t packet_length, |
| 308 bool incoming) { | 304 bool incoming) { |
| 309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 305 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 310 | 306 |
| 311 // |rtp_dump_handler_| could be NULL if we are waiting for the FILE thread to | 307 // |rtp_dump_handler_| could be NULL if we are waiting for the blocking |
| 312 // create/ensure the log directory. | 308 // thread pool to create/ensure the log directory. |
| 313 if (rtp_dump_handler_) { | 309 if (rtp_dump_handler_) { |
| 314 rtp_dump_handler_->OnRtpPacket( | 310 rtp_dump_handler_->OnRtpPacket( |
| 315 packet_header.get(), header_length, packet_length, incoming); | 311 packet_header.get(), header_length, packet_length, incoming); |
| 316 } | 312 } |
| 317 } | 313 } |
| 318 | 314 |
| 319 void WebRtcLoggingHandlerHost::OnChannelClosing() { | 315 void WebRtcLoggingHandlerHost::OnChannelClosing() { |
| 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 321 if (logging_state_ == STARTED || logging_state_ == STOPPED) { | 317 if (logging_state_ == STARTED || logging_state_ == STOPPED) { |
| 322 if (upload_log_on_render_close_) { | 318 if (upload_log_on_render_close_) { |
| 323 logging_state_ = UPLOADING; | 319 logging_state_ = UPLOADING; |
| 324 logging_started_time_ = base::Time(); | 320 logging_started_time_ = base::Time(); |
| 325 | 321 base::PostTaskAndReplyWithResult( |
| 326 content::BrowserThread::PostTaskAndReplyWithResult( | 322 BrowserThread::GetBlockingPool(), |
| 327 content::BrowserThread::FILE, | |
| 328 FROM_HERE, | 323 FROM_HERE, |
| 329 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, | 324 base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, |
| 330 this), | 325 this), |
| 331 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this)); | 326 base::Bind(&WebRtcLoggingHandlerHost::TriggerUpload, this)); |
| 332 } else { | 327 } else { |
| 333 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); | 328 g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); |
| 334 } | 329 } |
| 335 } | 330 } |
| 336 content::BrowserMessageFilter::OnChannelClosing(); | 331 BrowserMessageFilter::OnChannelClosing(); |
| 337 } | 332 } |
| 338 | 333 |
| 339 void WebRtcLoggingHandlerHost::OnDestruct() const { | 334 void WebRtcLoggingHandlerHost::OnDestruct() const { |
| 340 BrowserThread::DeleteOnIOThread::Destruct(this); | 335 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 341 } | 336 } |
| 342 | 337 |
| 343 bool WebRtcLoggingHandlerHost::OnMessageReceived(const IPC::Message& message) { | 338 bool WebRtcLoggingHandlerHost::OnMessageReceived(const IPC::Message& message) { |
| 344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 345 bool handled = true; | 340 bool handled = true; |
| 346 IPC_BEGIN_MESSAGE_MAP(WebRtcLoggingHandlerHost, message) | 341 IPC_BEGIN_MESSAGE_MAP(WebRtcLoggingHandlerHost, message) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 void WebRtcLoggingHandlerHost::DoStartLogging() { | 396 void WebRtcLoggingHandlerHost::DoStartLogging() { |
| 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 403 | 398 |
| 404 log_buffer_.reset(new unsigned char[kWebRtcLogSize]); | 399 log_buffer_.reset(new unsigned char[kWebRtcLogSize]); |
| 405 circular_buffer_.reset( | 400 circular_buffer_.reset( |
| 406 new PartialCircularBuffer(log_buffer_.get(), | 401 new PartialCircularBuffer(log_buffer_.get(), |
| 407 kWebRtcLogSize, | 402 kWebRtcLogSize, |
| 408 kWebRtcLogSize / 2, | 403 kWebRtcLogSize / 2, |
| 409 false)); | 404 false)); |
| 410 | 405 |
| 411 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( | 406 BrowserThread::PostBlockingPoolTask( |
| 412 &WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread, this)); | 407 FROM_HERE, |
| 408 base::Bind(&WebRtcLoggingHandlerHost::LogInitialInfoOnBlockingPool, |
| 409 this)); |
| 413 } | 410 } |
| 414 | 411 |
| 415 void WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread() { | 412 void WebRtcLoggingHandlerHost::LogInitialInfoOnBlockingPool() { |
| 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 413 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 417 | 414 |
| 418 net::NetworkInterfaceList network_list; | 415 net::NetworkInterfaceList network_list; |
| 419 net::GetNetworkList(&network_list, | 416 net::GetNetworkList(&network_list, |
| 420 net::EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES); | 417 net::EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES); |
| 421 | 418 |
| 422 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 419 std::string linux_distro; |
| 423 &WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread, this, network_list)); | 420 #if defined(OS_LINUX) |
| 421 linux_distro = base::GetLinuxDistro(); |
| 422 #endif |
| 423 |
| 424 BrowserThread::PostTask( |
| 425 BrowserThread::IO, |
| 426 FROM_HERE, |
| 427 base::Bind(&WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread, |
| 428 this, |
| 429 network_list, |
| 430 linux_distro)); |
| 424 } | 431 } |
| 425 | 432 |
| 426 void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread( | 433 void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread( |
| 427 const net::NetworkInterfaceList& network_list) { | 434 const net::NetworkInterfaceList& network_list, |
| 435 const std::string& linux_distro) { |
| 428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 436 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 429 | 437 |
| 430 // Log start time (current time). We don't use base/i18n/time_formatting.h | 438 // Log start time (current time). We don't use base/i18n/time_formatting.h |
| 431 // here because we don't want the format of the current locale. | 439 // here because we don't want the format of the current locale. |
| 432 base::Time::Exploded now = {0}; | 440 base::Time::Exploded now = {0}; |
| 433 base::Time::Now().LocalExplode(&now); | 441 base::Time::Now().LocalExplode(&now); |
| 434 LogToCircularBuffer(base::StringPrintf( | 442 LogToCircularBuffer(base::StringPrintf( |
| 435 "Start %d-%02d-%02d %02d:%02d:%02d", now.year, now.month, | 443 "Start %d-%02d-%02d %02d:%02d:%02d", now.year, now.month, |
| 436 now.day_of_month, now.hour, now.minute, now.second)); | 444 now.day_of_month, now.hour, now.minute, now.second)); |
| 437 | 445 |
| 438 // Write metadata if received before logging started. | 446 // Write metadata if received before logging started. |
| 439 if (!meta_data_.empty()) { | 447 if (!meta_data_.empty()) { |
| 440 std::string info; | 448 std::string info; |
| 441 FormatMetaDataAsLogMessage(meta_data_, &info); | 449 FormatMetaDataAsLogMessage(meta_data_, &info); |
| 442 LogToCircularBuffer(info); | 450 LogToCircularBuffer(info); |
| 443 } | 451 } |
| 444 | 452 |
| 445 // OS | 453 // OS |
| 446 LogToCircularBuffer(base::SysInfo::OperatingSystemName() + " " + | 454 LogToCircularBuffer(base::SysInfo::OperatingSystemName() + " " + |
| 447 base::SysInfo::OperatingSystemVersion() + " " + | 455 base::SysInfo::OperatingSystemVersion() + " " + |
| 448 base::SysInfo::OperatingSystemArchitecture()); | 456 base::SysInfo::OperatingSystemArchitecture()); |
| 449 #if defined(OS_LINUX) | 457 #if defined(OS_LINUX) |
| 450 LogToCircularBuffer("Linux distribution: " + base::GetLinuxDistro()); | 458 LogToCircularBuffer("Linux distribution: " + linux_distro); |
| 451 #endif | 459 #endif |
| 452 | 460 |
| 453 // CPU | 461 // CPU |
| 454 base::CPU cpu; | 462 base::CPU cpu; |
| 455 LogToCircularBuffer( | 463 LogToCircularBuffer( |
| 456 "Cpu: " + IntToString(cpu.family()) + "." + IntToString(cpu.model()) + | 464 "Cpu: " + IntToString(cpu.family()) + "." + IntToString(cpu.model()) + |
| 457 "." + IntToString(cpu.stepping()) + ", x" + | 465 "." + IntToString(cpu.stepping()) + ", x" + |
| 458 IntToString(base::SysInfo::NumberOfProcessors()) + ", " + | 466 IntToString(base::SysInfo::NumberOfProcessors()) + ", " + |
| 459 IntToString(base::SysInfo::AmountOfPhysicalMemoryMB()) + "MB"); | 467 IntToString(base::SysInfo::AmountOfPhysicalMemoryMB()) + "MB"); |
| 460 std::string cpu_brand = cpu.cpu_brand(); | 468 std::string cpu_brand = cpu.cpu_brand(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 519 |
| 512 void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) { | 520 void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) { |
| 513 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 514 DCHECK(circular_buffer_.get()); | 522 DCHECK(circular_buffer_.get()); |
| 515 circular_buffer_->Write(message.c_str(), message.length()); | 523 circular_buffer_->Write(message.c_str(), message.length()); |
| 516 const char eol = '\n'; | 524 const char eol = '\n'; |
| 517 circular_buffer_->Write(&eol, 1); | 525 circular_buffer_->Write(&eol, 1); |
| 518 } | 526 } |
| 519 | 527 |
| 520 base::FilePath WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists() { | 528 base::FilePath WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists() { |
| 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 529 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 522 base::FilePath log_dir_path = | 530 base::FilePath log_dir_path = |
| 523 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()); | 531 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()); |
| 524 base::File::Error error; | 532 base::File::Error error; |
| 525 if (!base::CreateDirectoryAndGetError(log_dir_path, &error)) { | 533 if (!base::CreateDirectoryAndGetError(log_dir_path, &error)) { |
| 526 DLOG(ERROR) << "Could not create WebRTC log directory, error: " << error; | 534 DLOG(ERROR) << "Could not create WebRTC log directory, error: " << error; |
| 527 return base::FilePath(); | 535 return base::FilePath(); |
| 528 } | 536 } |
| 529 return log_dir_path; | 537 return log_dir_path; |
| 530 } | 538 } |
| 531 | 539 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 562 upload_done_data.outgoing_rtp_dump = rtp_dumps.outgoing_dump_path; | 570 upload_done_data.outgoing_rtp_dump = rtp_dumps.outgoing_dump_path; |
| 563 | 571 |
| 564 rtp_dump_handler_.reset(); | 572 rtp_dump_handler_.reset(); |
| 565 stop_rtp_dump_callback_.Reset(); | 573 stop_rtp_dump_callback_.Reset(); |
| 566 } | 574 } |
| 567 | 575 |
| 568 upload_done_data.callback = upload_callback_; | 576 upload_done_data.callback = upload_callback_; |
| 569 upload_done_data.host = this; | 577 upload_done_data.host = this; |
| 570 upload_callback_.Reset(); | 578 upload_callback_.Reset(); |
| 571 | 579 |
| 572 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( | 580 BrowserThread::PostBlockingPoolTask( |
| 573 &WebRtcLogUploader::LoggingStoppedDoUpload, | 581 FROM_HERE, |
| 574 base::Unretained(g_browser_process->webrtc_log_uploader()), | 582 base::Bind(&WebRtcLogUploader::LoggingStoppedDoUpload, |
| 575 Passed(&log_buffer_), | 583 base::Unretained(g_browser_process->webrtc_log_uploader()), |
| 576 kWebRtcLogSize, | 584 Passed(&log_buffer_), |
| 577 meta_data_, | 585 kWebRtcLogSize, |
| 578 upload_done_data)); | 586 meta_data_, |
| 587 upload_done_data)); |
| 579 | 588 |
| 580 meta_data_.clear(); | 589 meta_data_.clear(); |
| 581 circular_buffer_.reset(); | 590 circular_buffer_.reset(); |
| 582 } | 591 } |
| 583 | 592 |
| 584 void WebRtcLoggingHandlerHost::FireGenericDoneCallback( | 593 void WebRtcLoggingHandlerHost::FireGenericDoneCallback( |
| 585 GenericDoneCallback* callback, | 594 GenericDoneCallback* callback, |
| 586 bool success, | 595 bool success, |
| 587 const std::string& error_message) { | 596 const std::string& error_message) { |
| 588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 597 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 589 DCHECK(!(*callback).is_null()); | 598 DCHECK(!callback->is_null()); |
| 590 content::BrowserThread::PostTask( | 599 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 591 content::BrowserThread::UI, | 600 base::Bind(*callback, success, error_message)); |
| 592 FROM_HERE, | 601 callback->Reset(); |
| 593 base::Bind(*callback, success, error_message)); | |
| 594 (*callback).Reset(); | |
| 595 } | 602 } |
| 596 | 603 |
| 597 void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart( | 604 void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart( |
| 598 RtpDumpType type, | 605 RtpDumpType type, |
| 599 GenericDoneCallback callback, | 606 GenericDoneCallback callback, |
| 600 const base::FilePath& dump_dir) { | 607 const base::FilePath& dump_dir) { |
| 601 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 602 | 609 |
| 603 // |rtp_dump_handler_| may be non-NULL if StartRtpDump is called again before | 610 // |rtp_dump_handler_| may be non-NULL if StartRtpDump is called again before |
| 604 // GetLogDirectoryAndEnsureExists returns on the FILE thread for a previous | 611 // GetLogDirectoryAndEnsureExists returns on the blocking thread pool for a |
| 605 // StartRtpDump. | 612 // previous StartRtpDump. |
| 606 if (!rtp_dump_handler_) | 613 if (!rtp_dump_handler_) |
| 607 rtp_dump_handler_.reset(new WebRtcRtpDumpHandler(dump_dir)); | 614 rtp_dump_handler_.reset(new WebRtcRtpDumpHandler(dump_dir)); |
| 608 | 615 |
| 609 DoStartRtpDump(type, &callback); | 616 DoStartRtpDump(type, &callback); |
| 610 } | 617 } |
| 611 | 618 |
| 612 void WebRtcLoggingHandlerHost::DoStartRtpDump(RtpDumpType type, | 619 void WebRtcLoggingHandlerHost::DoStartRtpDump(RtpDumpType type, |
| 613 GenericDoneCallback* callback) { | 620 GenericDoneCallback* callback) { |
| 614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 621 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 615 DCHECK(rtp_dump_handler_); | 622 DCHECK(rtp_dump_handler_); |
| 616 | 623 |
| 617 std::string error; | 624 std::string error; |
| 618 | 625 |
| 619 bool result = rtp_dump_handler_->StartDump(type, &error); | 626 bool result = rtp_dump_handler_->StartDump(type, &error); |
| 620 FireGenericDoneCallback(callback, result, error); | 627 FireGenericDoneCallback(callback, result, error); |
| 621 } | 628 } |
| OLD | NEW |