summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 12:12:33 +0000
committergrunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 12:12:33 +0000
commita5a98ab5d0337c98674ade76323004de102e6063 (patch)
tree2af06a07c6528e8acd492d3fbae05ef9907b4c99
parent7c3ee1abf0801439cbef6f6673fe379a6caedb80 (diff)
downloadchromium_src-a5a98ab5d0337c98674ade76323004de102e6063.zip
chromium_src-a5a98ab5d0337c98674ade76323004de102e6063.tar.gz
chromium_src-a5a98ab5d0337c98674ade76323004de102e6063.tar.bz2
Revert 274615 "Convert WebRtcLoggingHandlerHost to use the block..."
Hits dcheck. BUG=381107 > 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 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/313963008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275070 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover.cc3
-rw-r--r--chrome/browser/media/webrtc_log_uploader.cc13
-rw-r--r--chrome/browser/media/webrtc_log_uploader.h11
-rw-r--r--chrome/browser/media/webrtc_log_util.cc7
-rw-r--r--chrome/browser/media/webrtc_log_util.h11
-rw-r--r--chrome/browser/media/webrtc_logging_handler_host.cc95
-rw-r--r--chrome/browser/media/webrtc_logging_handler_host.h11
7 files changed, 72 insertions, 79 deletions
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
index bd4e2fd..da2bb2f 100644
--- a/chrome/browser/browsing_data/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc
@@ -388,7 +388,8 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
#if defined(ENABLE_WEBRTC)
waiting_for_clear_webrtc_logs_ = true;
- BrowserThread::PostBlockingPoolTaskAndReply(
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::FILE,
FROM_HERE,
base::Bind(
&WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles,
diff --git a/chrome/browser/media/webrtc_log_uploader.cc b/chrome/browser/media/webrtc_log_uploader.cc
index a51404c..98b22c3 100644
--- a/chrome/browser/media/webrtc_log_uploader.cc
+++ b/chrome/browser/media/webrtc_log_uploader.cc
@@ -76,7 +76,7 @@ WebRtcLogUploader::WebRtcLogUploader()
: log_count_(0),
post_data_(NULL),
shutting_down_(false) {
- blocking_sequence_checker_.DetachFromSequence();
+ file_thread_checker_.DetachFromThread();
}
WebRtcLogUploader::~WebRtcLogUploader() {
@@ -102,7 +102,8 @@ void WebRtcLogUploader::OnURLFetchComplete(
// TODO(jiayl): Add the RTP dump records to chrome://webrtc-logs.
base::FilePath log_list_path =
WebRtcLogList::GetWebRtcLogListFileForDirectory(it->second.log_path);
- content::BrowserThread::PostBlockingPoolTask(
+ content::BrowserThread::PostTask(
+ content::BrowserThread::FILE,
FROM_HERE,
base::Bind(&WebRtcLogUploader::AddUploadedLogInfoToUploadListFile,
base::Unretained(this),
@@ -140,7 +141,7 @@ void WebRtcLogUploader::LoggingStoppedDoUpload(
uint32 length,
const std::map<std::string, std::string>& meta_data,
const WebRtcLogUploadDoneData& upload_done_data) {
- DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
+ DCHECK(file_thread_checker_.CalledOnValidThread());
DCHECK(log_buffer.get());
DCHECK(!upload_done_data.log_path.empty());
@@ -351,7 +352,7 @@ void WebRtcLogUploader::DecreaseLogCount() {
void WebRtcLogUploader::WriteCompressedLogToFile(
const std::vector<uint8>& compressed_log,
const base::FilePath& log_file_path) {
- DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
+ DCHECK(file_thread_checker_.CalledOnValidThread());
DCHECK(!compressed_log.empty());
base::WriteFile(log_file_path,
reinterpret_cast<const char*>(&compressed_log[0]),
@@ -361,7 +362,7 @@ void WebRtcLogUploader::WriteCompressedLogToFile(
void WebRtcLogUploader::AddLocallyStoredLogInfoToUploadListFile(
const base::FilePath& upload_list_path,
const std::string& local_log_id) {
- DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
+ DCHECK(file_thread_checker_.CalledOnValidThread());
DCHECK(!upload_list_path.empty());
DCHECK(!local_log_id.empty());
@@ -405,7 +406,7 @@ void WebRtcLogUploader::AddUploadedLogInfoToUploadListFile(
const base::FilePath& upload_list_path,
const std::string& local_log_id,
const std::string& report_id) {
- DCHECK(blocking_sequence_checker_.CalledOnValidSequencedThread());
+ DCHECK(file_thread_checker_.CalledOnValidThread());
DCHECK(!upload_list_path.empty());
DCHECK(!local_log_id.empty());
DCHECK(!report_id.empty());
diff --git a/chrome/browser/media/webrtc_log_uploader.h b/chrome/browser/media/webrtc_log_uploader.h
index aa30bb2..86c2d3a 100644
--- a/chrome/browser/media/webrtc_log_uploader.h
+++ b/chrome/browser/media/webrtc_log_uploader.h
@@ -11,7 +11,6 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
-#include "base/sequence_checker.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/media/webrtc_logging_handler_host.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -119,7 +118,7 @@ class WebRtcLogUploader : public net::URLFetcherDelegate {
void DecreaseLogCount();
- // Must be called on the blocking task pool.
+ // Must be called on the FILE thread.
void WriteCompressedLogToFile(const std::vector<uint8>& compressed_log,
const base::FilePath& log_file_path);
@@ -138,7 +137,7 @@ class WebRtcLogUploader : public net::URLFetcherDelegate {
// "upload_time" and "report_id" is the left empty in the entry written to the
// list file. If uploading is successful, AddUploadedLogInfoToUploadListFile()
// is called and those empty items are filled out.
- // Must be called on the blocking task pool.
+ // Must be called on the FILE thread.
void AddLocallyStoredLogInfoToUploadListFile(
const base::FilePath& upload_list_path,
const std::string& local_log_id);
@@ -154,15 +153,15 @@ class WebRtcLogUploader : public net::URLFetcherDelegate {
// This is the UI thread for Chromium. Some other thread for tests.
base::ThreadChecker create_thread_checker_;
- // This is the blocking task pool.
- base::SequenceChecker blocking_sequence_checker_;
+ // This is the FILE thread for Chromium. Some other thread for tests.
+ base::ThreadChecker file_thread_checker_;
// Keeps track of number of currently open logs. Must be accessed on the UI
// thread.
int log_count_;
// For testing purposes, see OverrideUploadWithBufferForTesting. Only accessed
- // on the blocking thread pool.
+ // on the FILE thread.
std::string* post_data_;
typedef std::map<const net::URLFetcher*, WebRtcLogUploadDoneData>
diff --git a/chrome/browser/media/webrtc_log_util.cc b/chrome/browser/media/webrtc_log_util.cc
index d38625b..d443f27 100644
--- a/chrome/browser/media/webrtc_log_util.cc
+++ b/chrome/browser/media/webrtc_log_util.cc
@@ -6,9 +6,7 @@
#include "base/file_util.h"
#include "base/files/file_enumerator.h"
-#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/webrtc_log_list.h"
@@ -46,7 +44,7 @@ void WebRtcLogUtil::DeleteOldWebRtcLogFiles(const base::FilePath& log_dir) {
void WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles(
const base::FilePath& log_dir,
const base::Time& delete_begin_time) {
- base::ThreadRestrictions::AssertIOAllowed();
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
if (!base::PathExists(log_dir)) {
// This will happen if no logs have been stored or uploaded.
@@ -110,7 +108,8 @@ void WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles() {
g_browser_process->profile_manager()->GetProfileInfoCache();
size_t profiles_count = profile_cache.GetNumberOfProfiles();
for (size_t i = 0; i < profiles_count; ++i) {
- content::BrowserThread::PostBlockingPoolTask(
+ content::BrowserThread::PostTask(
+ content::BrowserThread::FILE,
FROM_HERE,
base::Bind(&DeleteOldWebRtcLogFiles,
WebRtcLogList::GetWebRtcLogDirectoryForProfile(
diff --git a/chrome/browser/media/webrtc_log_util.h b/chrome/browser/media/webrtc_log_util.h
index af4d06a..1bc1f95 100644
--- a/chrome/browser/media/webrtc_log_util.h
+++ b/chrome/browser/media/webrtc_log_util.h
@@ -5,22 +5,19 @@
#ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOG_UTIL_H_
#define CHROME_BROWSER_MEDIA_WEBRTC_LOG_UTIL_H_
-namespace base {
-class FilePath;
-class Time;
-}
+#include "base/files/file_path.h"
+#include "base/time/time.h"
class WebRtcLogUtil {
public:
// Deletes logs files older that 5 days. Updates the log file list. Must be
- // called on a thread that allows IO.
+ // called on the FILE thread.
static void DeleteOldWebRtcLogFiles(const base::FilePath& log_dir);
// Deletes logs files older that 5 days and logs younger than
// |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
- // equal to DeleteOldWebRtcLogFiles(). Must be called on a thread that allows
- // IO.
+ // equal to DeleteOldWebRtcLogFiles(). Must be called on the FILE thread.
static void DeleteOldAndRecentWebRtcLogFiles(
const base::FilePath& log_dir,
const base::Time& delete_begin_time);
diff --git a/chrome/browser/media/webrtc_logging_handler_host.cc b/chrome/browser/media/webrtc_logging_handler_host.cc
index 46a07df..4d7b168 100644
--- a/chrome/browser/media/webrtc_logging_handler_host.cc
+++ b/chrome/browser/media/webrtc_logging_handler_host.cc
@@ -7,19 +7,25 @@
#include <string>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/cpu.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/sys_info.h"
#include "base/time/time.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_uploader.h"
#include "chrome/browser/media/webrtc_rtp_dump_handler.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/media/webrtc_logging_messages.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/content_browser_client.h"
#include "content/public/browser/gpu_data_manager.h"
@@ -37,8 +43,6 @@
#endif
#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"
#endif
@@ -134,9 +138,9 @@ void WebRtcLoggingHandlerHost::SetMetaData(
error_message = "Meta data must be set before stop or upload.";
}
bool success = error_message.empty();
- BrowserThread::PostTask(BrowserThread::UI,
- FROM_HERE,
- base::Bind(callback, success, error_message));
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(callback, success,
+ error_message));
}
void WebRtcLoggingHandlerHost::StartLogging(
@@ -174,7 +178,7 @@ void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) {
if (logging_state_ != STOPPED) {
if (!callback.is_null()) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, false, "", kLogNotStoppedOrNoLogOpen));
}
return;
@@ -182,8 +186,8 @@ void WebRtcLoggingHandlerHost::UploadLog(const UploadDoneCallback& callback) {
upload_callback_ = callback;
logging_state_ = UPLOADING;
- base::PostTaskAndReplyWithResult(
- BrowserThread::GetBlockingPool(),
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::FILE,
FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
this),
@@ -236,8 +240,8 @@ void WebRtcLoggingHandlerHost::StartRtpDump(
stop_rtp_dump_callback_ = stop_callback;
if (!rtp_dump_handler_) {
- base::PostTaskAndReplyWithResult(
- BrowserThread::GetBlockingPool(),
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::FILE,
FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
this),
@@ -301,8 +305,8 @@ void WebRtcLoggingHandlerHost::DumpRtpPacketOnIOThread(
bool incoming) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- // |rtp_dump_handler_| could be NULL if we are waiting for the blocking
- // thread pool to create/ensure the log directory.
+ // |rtp_dump_handler_| could be NULL if we are waiting for the FILE thread to
+ // create/ensure the log directory.
if (rtp_dump_handler_) {
rtp_dump_handler_->OnRtpPacket(
packet_header.get(), header_length, packet_length, incoming);
@@ -315,8 +319,9 @@ void WebRtcLoggingHandlerHost::OnChannelClosing() {
if (upload_log_on_render_close_) {
logging_state_ = UPLOADING;
logging_started_time_ = base::Time();
- base::PostTaskAndReplyWithResult(
- BrowserThread::GetBlockingPool(),
+
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::FILE,
FROM_HERE,
base::Bind(&WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists,
this),
@@ -325,7 +330,7 @@ void WebRtcLoggingHandlerHost::OnChannelClosing() {
g_browser_process->webrtc_log_uploader()->LoggingStoppedDontUpload();
}
}
- BrowserMessageFilter::OnChannelClosing();
+ content::BrowserMessageFilter::OnChannelClosing();
}
void WebRtcLoggingHandlerHost::OnDestruct() const {
@@ -400,36 +405,23 @@ void WebRtcLoggingHandlerHost::DoStartLogging() {
kWebRtcLogSize / 2,
false));
- BrowserThread::PostBlockingPoolTask(
- FROM_HERE,
- base::Bind(&WebRtcLoggingHandlerHost::LogInitialInfoOnBlockingPool,
- this));
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(
+ &WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread, this));
}
-void WebRtcLoggingHandlerHost::LogInitialInfoOnBlockingPool() {
- DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+void WebRtcLoggingHandlerHost::LogInitialInfoOnFileThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
net::NetworkInterfaceList network_list;
net::GetNetworkList(&network_list,
net::EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES);
- std::string linux_distro;
-#if defined(OS_LINUX)
- linux_distro = base::GetLinuxDistro();
-#endif
-
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(&WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread,
- this,
- network_list,
- linux_distro));
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(
+ &WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread, this, network_list));
}
void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread(
- const net::NetworkInterfaceList& network_list,
- const std::string& linux_distro) {
+ const net::NetworkInterfaceList& network_list) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Log start time (current time). We don't use base/i18n/time_formatting.h
@@ -452,7 +444,7 @@ void WebRtcLoggingHandlerHost::LogInitialInfoOnIOThread(
base::SysInfo::OperatingSystemVersion() + " " +
base::SysInfo::OperatingSystemArchitecture());
#if defined(OS_LINUX)
- LogToCircularBuffer("Linux distribution: " + linux_distro);
+ LogToCircularBuffer("Linux distribution: " + base::GetLinuxDistro());
#endif
// CPU
@@ -523,7 +515,7 @@ void WebRtcLoggingHandlerHost::LogToCircularBuffer(const std::string& message) {
}
base::FilePath WebRtcLoggingHandlerHost::GetLogDirectoryAndEnsureExists() {
- DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::FilePath log_dir_path =
WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath());
base::File::Error error;
@@ -574,14 +566,13 @@ void WebRtcLoggingHandlerHost::DoUploadLogAndRtpDumps(
upload_done_data.host = this;
upload_callback_.Reset();
- BrowserThread::PostBlockingPoolTask(
- FROM_HERE,
- base::Bind(&WebRtcLogUploader::LoggingStoppedDoUpload,
- base::Unretained(g_browser_process->webrtc_log_uploader()),
- Passed(&log_buffer_),
- kWebRtcLogSize,
- meta_data_,
- upload_done_data));
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(
+ &WebRtcLogUploader::LoggingStoppedDoUpload,
+ base::Unretained(g_browser_process->webrtc_log_uploader()),
+ Passed(&log_buffer_),
+ kWebRtcLogSize,
+ meta_data_,
+ upload_done_data));
meta_data_.clear();
circular_buffer_.reset();
@@ -592,10 +583,12 @@ void WebRtcLoggingHandlerHost::FireGenericDoneCallback(
bool success,
const std::string& error_message) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(!callback->is_null());
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(*callback, success, error_message));
- callback->Reset();
+ DCHECK(!(*callback).is_null());
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(*callback, success, error_message));
+ (*callback).Reset();
}
void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart(
@@ -605,8 +598,8 @@ void WebRtcLoggingHandlerHost::CreateRtpDumpHandlerAndStart(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// |rtp_dump_handler_| may be non-NULL if StartRtpDump is called again before
- // GetLogDirectoryAndEnsureExists returns on the blocking thread pool for a
- // previous StartRtpDump.
+ // GetLogDirectoryAndEnsureExists returns on the FILE thread for a previous
+ // StartRtpDump.
if (!rtp_dump_handler_)
rtp_dump_handler_.reset(new WebRtcRtpDumpHandler(dump_dir));
diff --git a/chrome/browser/media/webrtc_logging_handler_host.h b/chrome/browser/media/webrtc_logging_handler_host.h
index 493dd01..dfff8c3 100644
--- a/chrome/browser/media/webrtc_logging_handler_host.h
+++ b/chrome/browser/media/webrtc_logging_handler_host.h
@@ -14,6 +14,10 @@
#include "content/public/browser/render_process_host.h"
#include "net/base/net_util.h"
+namespace net {
+class URLRequestContextGetter;
+} // namespace net
+
class PartialCircularBuffer;
class Profile;
@@ -132,9 +136,8 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
void StartLoggingIfAllowed();
void DoStartLogging();
- void LogInitialInfoOnBlockingPool();
- void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list,
- const std::string& linux_distro);
+ void LogInitialInfoOnFileThread();
+ void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list);
void NotifyLoggingStarted();
// Writes a formatted log |message| to the |circular_buffer_|.
@@ -173,7 +176,7 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
scoped_ptr<PartialCircularBuffer> circular_buffer_;
// The profile associated with our renderer process.
- const Profile* const profile_;
+ Profile* profile_;
// 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