Index: chrome/browser/chromeos/system_logs/debug_log_writer.cc |
diff --git a/chrome/browser/chromeos/system_logs/debug_log_writer.cc b/chrome/browser/chromeos/system_logs/debug_log_writer.cc |
index 671a826ff3d8da6c7bec79a01b0967d23e582ff0..16d949470c26cc66a5739c8597ff1027c4040093 100644 |
--- a/chrome/browser/chromeos/system_logs/debug_log_writer.cc |
+++ b/chrome/browser/chromeos/system_logs/debug_log_writer.cc |
@@ -13,10 +13,10 @@ |
#include "base/command_line.h" |
#include "base/files/file.h" |
#include "base/files/file_util.h" |
+#include "base/lazy_instance.h" |
#include "base/process/kill.h" |
#include "base/process/launch.h" |
#include "base/task_scheduler/post_task.h" |
-#include "base/threading/sequenced_worker_pool.h" |
#include "chrome/common/logging_chrome.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
#include "chromeos/dbus/debug_daemon_client.h" |
@@ -32,13 +32,15 @@ typedef base::Callback<void(bool succeeded)> CommandCompletionCallback; |
const char kGzipCommand[] = "/bin/gzip"; |
const char kTarCommand[] = "/bin/tar"; |
-scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( |
- const std::string sequence_name) { |
- base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
- return pool->GetSequencedTaskRunnerWithShutdownBehavior( |
- pool->GetNamedSequenceToken(sequence_name), |
- base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
-} |
+struct DebugLogWriterTaskRunner { |
+ const scoped_refptr<base::SequencedTaskRunner> task_runner = |
+ base::CreateSequencedTaskRunnerWithTraits( |
+ {base::MayBlock(), base::TaskPriority::BACKGROUND, |
+ base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); |
+}; |
+ |
+base::LazyInstance<DebugLogWriterTaskRunner>::Leaky g_sequenced_task_runner = |
+ LAZY_INSTANCE_INITIALIZER; |
// Called upon completion of |WriteDebugLogToFile|. Closes file |
// descriptor, deletes log file in the case of failure and calls |
@@ -50,7 +52,7 @@ void WriteDebugLogToFileCompleted( |
bool succeeded) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
if (!succeeded) { |
- bool posted = GetSequencedTaskRunner(sequence_token_name)->PostTaskAndReply( |
+ bool posted = g_sequenced_task_runner.Get().task_runner->PostTaskAndReply( |
FROM_HERE, |
base::Bind(base::IgnoreResult(&base::DeleteFile), file_path, false), |
base::Bind(callback, file_path, false)); |
@@ -81,9 +83,8 @@ void WriteDebugLogToFile(std::unique_ptr<base::File> file, |
callback)); |
// Close the file on an IO-allowed thread. |
- GetSequencedTaskRunner(sequence_token_name) |
- ->PostTask(FROM_HERE, |
- base::Bind(&base::DeletePointer<base::File>, file.release())); |
+ g_sequenced_task_runner.Get().task_runner->DeleteSoon(FROM_HERE, |
+ file.release()); |
} |
// Runs command with its parameters as defined in |argv|. |
@@ -227,13 +228,12 @@ void StartLogRetrieval(const base::FilePath& file_name_template, |
int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; |
std::unique_ptr<base::File> file(new base::File); |
base::File* file_ptr = file.get(); |
- GetSequencedTaskRunner(sequence_token_name) |
- ->PostTaskAndReply( |
- FROM_HERE, base::Bind(&InitializeLogFile, base::Unretained(file_ptr), |
- file_path, flags), |
- base::Bind(&WriteDebugLogToFile, base::Passed(&file), |
- sequence_token_name, file_path, should_compress, |
- callback)); |
+ g_sequenced_task_runner.Get().task_runner->PostTaskAndReply( |
+ FROM_HERE, |
+ base::Bind(&InitializeLogFile, base::Unretained(file_ptr), file_path, |
+ flags), |
+ base::Bind(&WriteDebugLogToFile, base::Passed(&file), sequence_token_name, |
+ file_path, should_compress, callback)); |
} |
const char kDefaultSequenceName[] = "DebugLogWriter"; |