Commit 09eab25b authored by thestig@chromium.org's avatar thestig@chromium.org

Convert WebRtcLoggingHandlerHost to use the blocking thread pool.

Also call base::GetLinuxDistro() on the blocking pool and not on the IO thread
because it may block.

Review URL: https://codereview.chromium.org/299903002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274615 0039d316-1c4b-4281-b951-d872f2087c98
parent 8d8277a6
...@@ -388,8 +388,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask, ...@@ -388,8 +388,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
#if defined(ENABLE_WEBRTC) #if defined(ENABLE_WEBRTC)
waiting_for_clear_webrtc_logs_ = true; waiting_for_clear_webrtc_logs_ = true;
BrowserThread::PostTaskAndReply( BrowserThread::PostBlockingPoolTaskAndReply(
BrowserThread::FILE,
FROM_HERE, FROM_HERE,
base::Bind( base::Bind(
&WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles,
......
...@@ -76,7 +76,7 @@ WebRtcLogUploader::WebRtcLogUploader() ...@@ -76,7 +76,7 @@ WebRtcLogUploader::WebRtcLogUploader()
: log_count_(0), : log_count_(0),
post_data_(NULL), post_data_(NULL),
shutting_down_(false) { shutting_down_(false) {
file_thread_checker_.DetachFromThread(); blocking_sequence_checker_.DetachFromSequence();
} }
WebRtcLogUploader::~WebRtcLogUploader() { WebRtcLogUploader::~WebRtcLogUploader() {
...@@ -102,8 +102,7 @@ void WebRtcLogUploader::OnURLFetchComplete( ...@@ -102,8 +102,7 @@ void WebRtcLogUploader::OnURLFetchComplete(
// TODO(jiayl): Add the RTP dump records to chrome://webrtc-logs. // TODO(jiayl): Add the RTP dump records to chrome://webrtc-logs.
base::FilePath log_list_path = base::FilePath log_list_path =
WebRtcLogList::GetWebRtcLogListFileForDirectory(it->second.log_path); WebRtcLogList::GetWebRtcLogListFileForDirectory(it->second.log_path);
content::BrowserThread::PostTask( content::BrowserThread::PostBlockingPoolTask(
content::BrowserThread::FILE,
FROM_HERE, FROM_HERE,
base::Bind(&WebRtcLogUploader::AddUploadedLogInfoToUploadListFile, base::Bind(&WebRtcLogUploader::AddUploadedLogInfoToUploadListFile,
base::Unretained(this), base::Unretained(this),
...@@ -141,7 +140,7 @@ void WebRtcLogUploader::LoggingStoppedDoUpload( ...@@ -141,7 +140,7 @@ void WebRtcLogUploader::LoggingStoppedDoUpload(
uint32 length, uint32 length,
const std::map<std::string, std::string>& meta_data, const std::map<std::string, std::string>& meta_data,
const WebRtcLogUploadDoneData& upload_done_data) { const WebRtcLogUploadDoneData& upload_done_data) {
DCHECK(file_thread_checker_.CalledOnValidThread()); DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
DCHECK(log_buffer.get()); DCHECK(log_buffer.get());
DCHECK(!upload_done_data.log_path.empty()); DCHECK(!upload_done_data.log_path.empty());
...@@ -352,7 +351,7 @@ void WebRtcLogUploader::DecreaseLogCount() { ...@@ -352,7 +351,7 @@ void WebRtcLogUploader::DecreaseLogCount() {
void WebRtcLogUploader::WriteCompressedLogToFile( void WebRtcLogUploader::WriteCompressedLogToFile(
const std::vector<uint8>& compressed_log, const std::vector<uint8>& compressed_log,
const base::FilePath& log_file_path) { const base::FilePath& log_file_path) {
DCHECK(file_thread_checker_.CalledOnValidThread()); DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
DCHECK(!compressed_log.empty()); DCHECK(!compressed_log.empty());
base::WriteFile(log_file_path, base::WriteFile(log_file_path,
reinterpret_cast<const char*>(&compressed_log[0]), reinterpret_cast<const char*>(&compressed_log[0]),
...@@ -362,7 +361,7 @@ void WebRtcLogUploader::WriteCompressedLogToFile( ...@@ -362,7 +361,7 @@ void WebRtcLogUploader::WriteCompressedLogToFile(
void WebRtcLogUploader::AddLocallyStoredLogInfoToUploadListFile( void WebRtcLogUploader::AddLocallyStoredLogInfoToUploadListFile(
const base::FilePath& upload_list_path, const base::FilePath& upload_list_path,
const std::string& local_log_id) { const std::string& local_log_id) {
DCHECK(file_thread_checker_.CalledOnValidThread()); DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
DCHECK(!upload_list_path.empty()); DCHECK(!upload_list_path.empty());
DCHECK(!local_log_id.empty()); DCHECK(!local_log_id.empty());
...@@ -406,7 +405,7 @@ void WebRtcLogUploader::AddUploadedLogInfoToUploadListFile( ...@@ -406,7 +405,7 @@ void WebRtcLogUploader::AddUploadedLogInfoToUploadListFile(
const base::FilePath& upload_list_path, const base::FilePath& upload_list_path,
const std::string& local_log_id, const std::string& local_log_id,
const std::string& report_id) { const std::string& report_id) {
DCHECK(file_thread_checker_.CalledOnValidThread()); DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
DCHECK(!upload_list_path.empty()); DCHECK(!upload_list_path.empty());
DCHECK(!local_log_id.empty()); DCHECK(!local_log_id.empty());
DCHECK(!report_id.empty()); DCHECK(!report_id.empty());
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/sequence_checker.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "chrome/browser/media/webrtc_logging_handler_host.h" #include "chrome/browser/media/webrtc_logging_handler_host.h"
#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_fetcher_delegate.h"
...@@ -118,7 +119,7 @@ class WebRtcLogUploader : public net::URLFetcherDelegate { ...@@ -118,7 +119,7 @@ class WebRtcLogUploader : public net::URLFetcherDelegate {
void DecreaseLogCount(); void DecreaseLogCount();
// Must be called on the FILE thread. // Must be called on the blocking task pool.
void WriteCompressedLogToFile(const std::vector<uint8>& compressed_log, void WriteCompressedLogToFile(const std::vector<uint8>& compressed_log,
const base::FilePath& log_file_path); const base::FilePath& log_file_path);
...@@ -137,7 +138,7 @@ class WebRtcLogUploader : public net::URLFetcherDelegate { ...@@ -137,7 +138,7 @@ class WebRtcLogUploader : public net::URLFetcherDelegate {
// "upload_time" and "report_id" is the left empty in the entry written to the // "upload_time" and "report_id" is the left empty in the entry written to the
// list file. If uploading is successful, AddUploadedLogInfoToUploadListFile() // list file. If uploading is successful, AddUploadedLogInfoToUploadListFile()
// is called and those empty items are filled out. // is called and those empty items are filled out.
// Must be called on the FILE thread. // Must be called on the blocking task pool.
void AddLocallyStoredLogInfoToUploadListFile( void AddLocallyStoredLogInfoToUploadListFile(
const base::FilePath& upload_list_path, const base::FilePath& upload_list_path,
const std::string& local_log_id); const std::string& local_log_id);
...@@ -153,15 +154,15 @@ class WebRtcLogUploader : public net::URLFetcherDelegate { ...@@ -153,15 +154,15 @@ class WebRtcLogUploader : public net::URLFetcherDelegate {
// This is the UI thread for Chromium. Some other thread for tests. // This is the UI thread for Chromium. Some other thread for tests.
base::ThreadChecker create_thread_checker_; base::ThreadChecker create_thread_checker_;
// This is the FILE thread for Chromium. Some other thread for tests. // This is the blocking task pool.
base::ThreadChecker file_thread_checker_; base::SequenceChecker blocking_sequence_checker_;
// Keeps track of number of currently open logs. Must be accessed on the UI // Keeps track of number of currently open logs. Must be accessed on the UI
// thread. // thread.
int log_count_; int log_count_;
// For testing purposes, see OverrideUploadWithBufferForTesting. Only accessed // For testing purposes, see OverrideUploadWithBufferForTesting. Only accessed
// on the FILE thread. // on the blocking thread pool.
std::string* post_data_; std::string* post_data_;
typedef std::map<const net::URLFetcher*, WebRtcLogUploadDoneData> typedef std::map<const net::URLFetcher*, WebRtcLogUploadDoneData>
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/media/webrtc_log_list.h" #include "chrome/browser/media/webrtc_log_list.h"
...@@ -44,7 +46,7 @@ void WebRtcLogUtil::DeleteOldWebRtcLogFiles(const base::FilePath& log_dir) { ...@@ -44,7 +46,7 @@ void WebRtcLogUtil::DeleteOldWebRtcLogFiles(const base::FilePath& log_dir) {
void WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles( void WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles(
const base::FilePath& log_dir, const base::FilePath& log_dir,
const base::Time& delete_begin_time) { const base::Time& delete_begin_time) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); base::ThreadRestrictions::AssertIOAllowed();
if (!base::PathExists(log_dir)) { if (!base::PathExists(log_dir)) {
// This will happen if no logs have been stored or uploaded. // This will happen if no logs have been stored or uploaded.
...@@ -108,8 +110,7 @@ void WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles() { ...@@ -108,8 +110,7 @@ void WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles() {
g_browser_process->profile_manager()->GetProfileInfoCache(); g_browser_process->profile_manager()->GetProfileInfoCache();
size_t profiles_count = profile_cache.GetNumberOfProfiles(); size_t profiles_count = profile_cache.GetNumberOfProfiles();
for (size_t i = 0; i < profiles_count; ++i) { for (size_t i = 0; i < profiles_count; ++i) {
content::BrowserThread::PostTask( content::BrowserThread::PostBlockingPoolTask(
content::BrowserThread::FILE,
FROM_HERE, FROM_HERE,
base::Bind(&DeleteOldWebRtcLogFiles, base::Bind(&DeleteOldWebRtcLogFiles,
WebRtcLogList::GetWebRtcLogDirectoryForProfile( WebRtcLogList::GetWebRtcLogDirectoryForProfile(
......
...@@ -5,19 +5,22 @@ ...@@ -5,19 +5,22 @@
#ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOG_UTIL_H_ #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOG_UTIL_H_
#define CHROME_BROWSER_MEDIA_WEBRTC_LOG_UTIL_H_ #define CHROME_BROWSER_MEDIA_WEBRTC_LOG_UTIL_H_
#include "base/files/file_path.h" namespace base {
#include "base/time/time.h" class FilePath;
class Time;
}
class WebRtcLogUtil { class WebRtcLogUtil {
public: public:
// Deletes logs files older that 5 days. Updates the log file list. Must be // Deletes logs files older that 5 days. Updates the log file list. Must be
// called on the FILE thread. // called on a thread that allows IO.
static void DeleteOldWebRtcLogFiles(const base::FilePath& log_dir); static void DeleteOldWebRtcLogFiles(const base::FilePath& log_dir);
// Deletes logs files older that 5 days and logs younger than // Deletes logs files older that 5 days and logs younger than
// |delete_begin_time|. Updates the log file list. If |delete_begin_time| is // |delete_begin_time|. Updates the log file list. If |delete_begin_time| is
// base::time::Max(), no recent logs will be deleted, and the function is // base::time::Max(), no recent logs will be deleted, and the function is
// equal to DeleteOldWebRtcLogFiles(). Must be called on the FILE thread. // equal to DeleteOldWebRtcLogFiles(). Must be called on a thread that allows
// IO.
static void DeleteOldAndRecentWebRtcLogFiles( static void DeleteOldAndRecentWebRtcLogFiles(
const base::FilePath& log_dir, const base::FilePath& log_dir,
const base::Time& delete_begin_time); const base::Time& delete_begin_time);
......
...@@ -7,25 +7,19 @@ ...@@ -7,25 +7,19 @@
#include <string> #include <string>
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h"
#include "base/cpu.h" #include "base/cpu.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/media/webrtc_log_list.h" #include "chrome/browser/media/webrtc_log_list.h"
#include "chrome/browser/media/webrtc_log_uploader.h" #include "chrome/browser/media/webrtc_log_uploader.h"
#include "chrome/browser/media/webrtc_rtp_dump_handler.h" #include "chrome/browser/media/webrtc_rtp_dump_handler.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/media/webrtc_logging_messages.h" #include "chrome/common/media/webrtc_logging_messages.h"
#include "chrome/common/partial_circular_buffer.h" #include "chrome/common/partial_circular_buffer.h"
#include "chrome/common/pref_names.h"
#include "chromeos/settings/cros_settings_names.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h" #include "content/public/browser/content_browser_client.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
...@@ -43,6 +37,8 @@ ...@@ -43,6 +37,8 @@
#endif #endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chromeos/settings/cros_settings_names.h"
#include "chromeos/system/statistics_provider.h" #include "chromeos/system/statistics_provider.h"
#endif #endif
...@@ -138,9 +134,9 @@ void WebRtcLoggingHandlerHost::SetMetaData( ...@@ -138,9 +134,9 @@ void WebRtcLoggingHandlerHost::SetMetaData(
error_message = "Meta data must be set before stop or upload."; error_message = "Meta data must be set before stop or upload.";
} }
bool success = error_message.empty(); bool success = error_message.empty();
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, BrowserThread::PostTask(BrowserThread::UI,
base::Bind(callback, success, FROM_HERE,
error_message)); base::Bind(callback, success, error_message));
} }
void WebRtcLoggingHandlerHost::StartLogging( void WebRtcLoggingHandlerHost::StartLogging(
...@@ -178,7 +174,7 @@ void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) { ...@@ -178,7 +174,7 @@ void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) {
if (logging_state_ != STOPPED) { if (logging_state_ != STOPPED) {
if (!callback.is_null()) { if (!callback.is_null()) {
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(callback, false, "", kLogNotStoppedOrNoLogOpen)); base::Bind(callback, false, "", kLogNotStoppedOrNoLogOpen));
} }
return; return;
...@@ -186,8 +182,8 @@ void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) { ...@@ -186,8 +182,8 @@ void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) {
upload_callback_ = callback; upload_callback_ = callback;
logging_state_ = UPLOADING; logging_state_ = UPLOADING;
content::BrowserThread::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
content::BrowserThread::FILE, BrowserThread::GetBlockingPool(),
FROM_HERE, FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
this), this),
...@@ -240,8 +236,8 @@ void WebRtcLoggingHandlerHost::StartRtpDump( ...@@ -240,8 +236,8 @@ void WebRtcLoggingHandlerHost::StartRtpDump(
stop_rtp_dump_callback_ = stop_callback; stop_rtp_dump_callback_ = stop_callback;
if (!rtp_dump_handler_) { if (!rtp_dump_handler_) {
content::BrowserThread::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
content::BrowserThread::FILE, BrowserThread::GetBlockingPool(),
FROM_HERE, FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
this), this),
...@@ -305,8 +301,8 @@ void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread( ...@@ -305,8 +301,8 @@ void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread(
bool incoming) { bool incoming) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// |rtp_dump_handler_| could be NULL if we are waiting for the FILE thread to // |rtp_dump_handler_| could be NULL if we are waiting for the blocking
// create/ensure the log directory. // thread pool to create/ensure the log directory.
if (rtp_dump_handler_) { if (rtp_dump_handler_) {
rtp_dump_handler_->OnRtpPacket( rtp_dump_handler_->OnRtpPacket(
packet_header.get(), header_length, packet_length, incoming); packet_header.get(), header_length, packet_length, incoming);
...@@ -319,9 +315,8 @@ void WebRtcLoggingHandlerHost::OnChannelClosing() { ...@@ -319,9 +315,8 @@ void WebRtcLoggingHandlerHost::OnChannelClosing() {
if (upload_log_on_render_close_) { if (upload_log_on_render_close_) {
logging_state_ = UPLOADING; logging_state_ = UPLOADING;
logging_started_time_ = base::Time(); logging_started_time_ = base::Time();
base::PostTaskAndReplyWithResult(
content::BrowserThread::PostTaskAndReplyWithResult( BrowserThread::GetBlockingPool(),
content::BrowserThread::FILE,
FROM_HERE, FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists, base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
this), this),
...@@ -330,7 +325,7 @@ void WebRtcLoggingHandlerHost::OnChannelClosing() { ...@@ -330,7 +325,7 @@ void WebRtcLoggingHandlerHost::OnChannelClosing() {
g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload(); g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload();
} }
} }
content::BrowserMessageFilter::OnChannelClosing(); BrowserMessageFilter::OnChannelClosing();
} }
void WebRtcLoggingHandlerHost::OnDestruct() const { void WebRtcLoggingHandlerHost::OnDestruct() const {
...@@ -405,23 +400,36 @@ void WebRtcLoggingHandlerHost::DoStartLogging() { ...@@ -405,23 +400,36 @@ void WebRtcLoggingHandlerHost::DoStartLogging() {
kWebRtcLogSize / 2, kWebRtcLogSize / 2,
false)); false));
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( BrowserThread::PostBlockingPoolTask(
&WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread, this)); FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::LogInitialInfoOnBlockingPool,
this));
} }
void WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread() { void WebRtcLoggingHandlerHost::LogInitialInfoOnBlockingPool() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
net::NetworkInterfaceList network_list; net::NetworkInterfaceList network_list;
net::GetNetworkList(&network_list, net::GetNetworkList(&network_list,
net::EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES); net::EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( std::string linux_distro;
&WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread, this, network_list)); #if defined(OS_LINUX)
linux_distro = base::GetLinuxDistro();
#endif
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread,
this,
network_list,
linux_distro));
} }
void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread( void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread(
const net::NetworkInterfaceList& network_list) { const net::NetworkInterfaceList& network_list,
const std::string& linux_distro) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Log start time (current time). We don't use base/i18n/time_formatting.h // Log start time (current time). We don't use base/i18n/time_formatting.h
...@@ -444,7 +452,7 @@ void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread( ...@@ -444,7 +452,7 @@ void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread(
base::SysInfo::OperatingSystemVersion() + " " + base::SysInfo::OperatingSystemVersion() + " " +
base::SysInfo::OperatingSystemArchitecture()); base::SysInfo::OperatingSystemArchitecture());
#if defined(OS_LINUX) #if defined(OS_LINUX)
LogToCircularBuffer("Linux distribution: " + base::GetLinuxDistro()); LogToCircularBuffer("Linux distribution: " + linux_distro);
#endif #endif
// CPU // CPU
...@@ -515,7 +523,7 @@ void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) { ...@@ -515,7 +523,7 @@ void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) {
} }
base::FilePath WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists() { base::FilePath WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
base::FilePath log_dir_path = base::FilePath log_dir_path =
WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()); WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath());
base::File::Error error; base::File::Error error;
...@@ -566,8 +574,9 @@ void WebRtcLoggingHandlerHost::DoUploadLogAndRtpDumps( ...@@ -566,8 +574,9 @@ void WebRtcLoggingHandlerHost::DoUploadLogAndRtpDumps(
upload_done_data.host = this; upload_done_data.host = this;
upload_callback_.Reset(); upload_callback_.Reset();
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( BrowserThread::PostBlockingPoolTask(
&WebRtcLogUploader::LoggingStoppedDoUpload, FROM_HERE,
base::Bind(&WebRtcLogUploader::LoggingStoppedDoUpload,
base::Unretained(g_browser_process->webrtc_log_uploader()), base::Unretained(g_browser_process->webrtc_log_uploader()),
Passed(&log_buffer_), Passed(&log_buffer_),
kWebRtcLogSize, kWebRtcLogSize,
...@@ -583,12 +592,10 @@ void WebRtcLoggingHandlerHost::FireGenericDoneCallback( ...@@ -583,12 +592,10 @@ void WebRtcLoggingHandlerHost::FireGenericDoneCallback(
bool success, bool success,
const std::string& error_message) { const std::string& error_message) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!(*callback).is_null()); DCHECK(!callback->is_null());
content::BrowserThread::PostTask( BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
content::BrowserThread::UI,
FROM_HERE,
base::Bind(*callback, success, error_message)); base::Bind(*callback, success, error_message));
(*callback).Reset(); callback->Reset();
} }
void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart( void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart(
...@@ -598,8 +605,8 @@ void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart( ...@@ -598,8 +605,8 @@ void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// |rtp_dump_handler_| may be non-NULL if StartRtpDump is called again before // |rtp_dump_handler_| may be non-NULL if StartRtpDump is called again before
// GetLogDirectoryAndEnsureExists returns on the FILE thread for a previous // GetLogDirectoryAndEnsureExists returns on the blocking thread pool for a
// StartRtpDump. // previous StartRtpDump.
if (!rtp_dump_handler_) if (!rtp_dump_handler_)
rtp_dump_handler_.reset(new WebRtcRtpDumpHandler(dump_dir)); rtp_dump_handler_.reset(new WebRtcRtpDumpHandler(dump_dir));
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
namespace net {
class URLRequestContextGetter;
} // namespace net
class PartialCircularBuffer; class PartialCircularBuffer;
class Profile; class Profile;
...@@ -136,8 +132,9 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { ...@@ -136,8 +132,9 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
void StartLoggingIfAllowed(); void StartLoggingIfAllowed();
void DoStartLogging(); void DoStartLogging();
void LogInitialInfoOnFileThread(); void LogInitialInfoOnBlockingPool();
void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list); void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list,
const std::string& linux_distro);
void NotifyLoggingStarted(); void NotifyLoggingStarted();
// Writes a formatted log |message| to the |circular_buffer_|. // Writes a formatted log |message| to the |circular_buffer_|.
...@@ -176,7 +173,7 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { ...@@ -176,7 +173,7 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
scoped_ptr<PartialCircularBuffer> circular_buffer_; scoped_ptr<PartialCircularBuffer> circular_buffer_;
// The profile associated with our renderer process. // The profile associated with our renderer process.
Profile* profile_; const Profile* const profile_;
// These are only accessed on the IO thread, except when in STARTING state. In // These are only accessed on the IO thread, except when in STARTING state. In
// this state we are protected since entering any function that alters the // this state we are protected since entering any function that alters the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment