Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: tools/gn/loader.cc

Issue 2130443002: Remove calls to MessageLoop::current() in tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR brettw (add comment) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/loader.h ('k') | tools/gn/loader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/loader.cc
diff --git a/tools/gn/loader.cc b/tools/gn/loader.cc
index 69fb7668e17dd200c23ec5b37a7f591c5f774d5a..5a3f7832e07acb589167fc4b526e8262e28afd3b 100644
--- a/tools/gn/loader.cc
+++ b/tools/gn/loader.cc
@@ -6,8 +6,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
-#include "base/message_loop/message_loop.h"
-#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "tools/gn/build_settings.h"
#include "tools/gn/err.h"
#include "tools/gn/filesystem_utils.h"
@@ -100,9 +99,11 @@ SourceFile Loader::BuildFileForLabel(const Label& label) {
// -----------------------------------------------------------------------------
LoaderImpl::LoaderImpl(const BuildSettings* build_settings)
- : main_loop_(base::MessageLoop::current()),
- pending_loads_(0),
- build_settings_(build_settings) {
+ : pending_loads_(0), build_settings_(build_settings) {
+ // There may not be an active TaskRunner at this point. When that's the case,
+ // the calling code is expected to call set_task_runner().
+ if (base::ThreadTaskRunnerHandle::IsSet())
+ task_runner_ = base::ThreadTaskRunnerHandle::Get();
}
LoaderImpl::~LoaderImpl() {
@@ -239,7 +240,7 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings,
const LocationRange& origin,
const ParseNode* root) {
if (!root) {
- main_loop_->task_runner()->PostTask(
+ task_runner_->PostTask(
FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this));
return;
}
@@ -280,8 +281,7 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings,
trace.Done();
- main_loop_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this));
+ task_runner_->PostTask(FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this));
}
void LoaderImpl::BackgroundLoadBuildConfig(
@@ -289,7 +289,7 @@ void LoaderImpl::BackgroundLoadBuildConfig(
const Scope::KeyValueMap& toolchain_overrides,
const ParseNode* root) {
if (!root) {
- main_loop_->task_runner()->PostTask(
+ task_runner_->PostTask(
FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this));
return;
}
@@ -339,9 +339,9 @@ void LoaderImpl::BackgroundLoadBuildConfig(
}
}
- main_loop_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&LoaderImpl::DidLoadBuildConfig, this,
- settings->toolchain_label()));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&LoaderImpl::DidLoadBuildConfig, this,
+ settings->toolchain_label()));
}
void LoaderImpl::DidLoadFile() {
« no previous file with comments | « tools/gn/loader.h ('k') | tools/gn/loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698