Commit f92c27db authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

Migrate custom lazy TaskRunner implementations to LazyTaskRunner.

TBR=afakhry@chromium.org,creis@chromium.org

Bug: 
Change-Id: Ife874db9ed1b7fa2e6251e12ce1bf7fcb348d675
Reviewed-on: https://chromium-review.googlesource.com/595868
Commit-Queue: Francois Doray <fdoray@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491406}
parent 3cd64d66
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file.h" #include "base/files/file.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/process/kill.h" #include "base/process/kill.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/task_scheduler/lazy_task_runner.h"
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "chrome/common/logging_chrome.h" #include "chrome/common/logging_chrome.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
...@@ -33,15 +33,11 @@ typedef base::Callback<void(bool succeeded)> CommandCompletionCallback; ...@@ -33,15 +33,11 @@ typedef base::Callback<void(bool succeeded)> CommandCompletionCallback;
const char kGzipCommand[] = "/bin/gzip"; const char kGzipCommand[] = "/bin/gzip";
const char kTarCommand[] = "/bin/tar"; const char kTarCommand[] = "/bin/tar";
struct DebugLogWriterTaskRunner { base::LazySequencedTaskRunner g_sequenced_task_runner =
const scoped_refptr<base::SequencedTaskRunner> task_runner = LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
base::CreateSequencedTaskRunnerWithTraits( base::TaskTraits(base::MayBlock(),
{base::MayBlock(), base::TaskPriority::BACKGROUND, base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); base::TaskShutdownBehavior::BLOCK_SHUTDOWN));
};
base::LazyInstance<DebugLogWriterTaskRunner>::Leaky g_sequenced_task_runner =
LAZY_INSTANCE_INITIALIZER;
// Called upon completion of |WriteDebugLogToFile|. Closes file // Called upon completion of |WriteDebugLogToFile|. Closes file
// descriptor, deletes log file in the case of failure and calls // descriptor, deletes log file in the case of failure and calls
...@@ -53,7 +49,7 @@ void WriteDebugLogToFileCompleted( ...@@ -53,7 +49,7 @@ void WriteDebugLogToFileCompleted(
bool succeeded) { bool succeeded) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!succeeded) { if (!succeeded) {
bool posted = g_sequenced_task_runner.Get().task_runner->PostTaskAndReply( bool posted = g_sequenced_task_runner.Get()->PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::Bind(base::IgnoreResult(&base::DeleteFile), file_path, false), base::Bind(base::IgnoreResult(&base::DeleteFile), file_path, false),
base::Bind(callback, file_path, false)); base::Bind(callback, file_path, false));
...@@ -84,8 +80,7 @@ void WriteDebugLogToFile(std::unique_ptr<base::File> file, ...@@ -84,8 +80,7 @@ void WriteDebugLogToFile(std::unique_ptr<base::File> file,
callback)); callback));
// Close the file on an IO-allowed thread. // Close the file on an IO-allowed thread.
g_sequenced_task_runner.Get().task_runner->DeleteSoon(FROM_HERE, g_sequenced_task_runner.Get()->DeleteSoon(FROM_HERE, file.release());
file.release());
} }
// Runs command with its parameters as defined in |argv|. // Runs command with its parameters as defined in |argv|.
...@@ -229,7 +224,7 @@ void StartLogRetrieval(const base::FilePath& file_name_template, ...@@ -229,7 +224,7 @@ void StartLogRetrieval(const base::FilePath& file_name_template,
int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE;
std::unique_ptr<base::File> file(new base::File); std::unique_ptr<base::File> file(new base::File);
base::File* file_ptr = file.get(); base::File* file_ptr = file.get();
g_sequenced_task_runner.Get().task_runner->PostTaskAndReply( g_sequenced_task_runner.Get()->PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::Bind(&InitializeLogFile, base::Unretained(file_ptr), file_path, base::Bind(&InitializeLogFile, base::Unretained(file_ptr), file_path,
flags), flags),
......
...@@ -4,26 +4,20 @@ ...@@ -4,26 +4,20 @@
#include "content/common/font_list.h" #include "content/common/font_list.h"
#include "base/lazy_instance.h" #include "base/task_scheduler/lazy_task_runner.h"
#include "base/task_scheduler/post_task.h"
namespace content { namespace content {
namespace { namespace {
struct FontListTaskRunner { base::LazySequencedTaskRunner g_font_list_task_runner =
const scoped_refptr<base::SequencedTaskRunner> task_runner = LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
base::CreateSequencedTaskRunnerWithTraits( base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_VISIBLE));
{base::MayBlock(), base::TaskPriority::USER_VISIBLE});
};
base::LazyInstance<FontListTaskRunner>::Leaky g_font_list_task_runner =
LAZY_INSTANCE_INITIALIZER;
} // namespace } // namespace
scoped_refptr<base::SequencedTaskRunner> GetFontListTaskRunner() { scoped_refptr<base::SequencedTaskRunner> GetFontListTaskRunner() {
return g_font_list_task_runner.Get().task_runner; return g_font_list_task_runner.Get();
} }
} // content } // content
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