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

Side by Side Diff: tools/gn/setup.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 unified diff | Download patch
« no previous file with comments | « tools/gn/scheduler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/setup.h" 5 #include "tools/gn/setup.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <sstream> 9 #include <sstream>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/memory/ref_counted.h"
16 #include "base/process/launch.h" 17 #include "base/process/launch.h"
17 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
18 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
20 #include "base/strings/sys_string_conversions.h" 21 #include "base/strings/sys_string_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "tools/gn/commands.h" 24 #include "tools/gn/commands.h"
24 #include "tools/gn/filesystem_utils.h" 25 #include "tools/gn/filesystem_utils.h"
25 #include "tools/gn/input_file.h" 26 #include "tools/gn/input_file.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 base::FilePath with_no_slash = current_dir.StripTrailingSeparators(); 134 base::FilePath with_no_slash = current_dir.StripTrailingSeparators();
134 base::FilePath up_one_dir = with_no_slash.DirName(); 135 base::FilePath up_one_dir = with_no_slash.DirName();
135 if (up_one_dir == current_dir) 136 if (up_one_dir == current_dir)
136 return base::FilePath(); // Got to the top. 137 return base::FilePath(); // Got to the top.
137 138
138 return FindDotFile(up_one_dir); 139 return FindDotFile(up_one_dir);
139 } 140 }
140 141
141 // Called on any thread. Post the item to the builder on the main thread. 142 // Called on any thread. Post the item to the builder on the main thread.
142 void ItemDefinedCallback(base::MessageLoop* main_loop, 143 void ItemDefinedCallback(
143 scoped_refptr<Builder> builder, 144 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
144 std::unique_ptr<Item> item) { 145 scoped_refptr<Builder> builder,
146 std::unique_ptr<Item> item) {
145 DCHECK(item); 147 DCHECK(item);
146 main_loop->task_runner()->PostTask( 148 task_runner->PostTask(FROM_HERE, base::Bind(&Builder::ItemDefined, builder,
147 FROM_HERE, 149 base::Passed(&item)));
148 base::Bind(&Builder::ItemDefined, builder, base::Passed(&item)));
149 } 150 }
150 151
151 void DecrementWorkCount() { 152 void DecrementWorkCount() {
152 g_scheduler->DecrementWorkCount(); 153 g_scheduler->DecrementWorkCount();
153 } 154 }
154 155
155 #if defined(OS_WIN) 156 #if defined(OS_WIN)
156 157
157 // Given the path to a batch file that runs Python, extracts the name of the 158 // Given the path to a batch file that runs Python, extracts the name of the
158 // executable actually implementing Python. Generally people write a batch file 159 // executable actually implementing Python. Generally people write a batch file
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 : build_settings_(), 252 : build_settings_(),
252 loader_(new LoaderImpl(&build_settings_)), 253 loader_(new LoaderImpl(&build_settings_)),
253 builder_(new Builder(loader_.get())), 254 builder_(new Builder(loader_.get())),
254 root_build_file_("//BUILD.gn"), 255 root_build_file_("//BUILD.gn"),
255 check_public_headers_(false), 256 check_public_headers_(false),
256 dotfile_settings_(&build_settings_, std::string()), 257 dotfile_settings_(&build_settings_, std::string()),
257 dotfile_scope_(&dotfile_settings_), 258 dotfile_scope_(&dotfile_settings_),
258 fill_arguments_(true) { 259 fill_arguments_(true) {
259 dotfile_settings_.set_toolchain_label(Label()); 260 dotfile_settings_.set_toolchain_label(Label());
260 build_settings_.set_item_defined_callback( 261 build_settings_.set_item_defined_callback(
261 base::Bind(&ItemDefinedCallback, scheduler_.main_loop(), builder_)); 262 base::Bind(&ItemDefinedCallback, scheduler_.task_runner(), builder_));
262 263
263 loader_->set_complete_callback(base::Bind(&DecrementWorkCount)); 264 loader_->set_complete_callback(base::Bind(&DecrementWorkCount));
264 // The scheduler's main loop wasn't created when the Loader was created, so 265 // The scheduler's task runner wasn't created when the Loader was created, so
265 // we need to set it now. 266 // we need to set it now.
266 loader_->set_main_loop(scheduler_.main_loop()); 267 loader_->set_task_runner(scheduler_.task_runner());
267 } 268 }
268 269
269 Setup::~Setup() { 270 Setup::~Setup() {
270 } 271 }
271 272
272 bool Setup::DoSetup(const std::string& build_dir, bool force_create) { 273 bool Setup::DoSetup(const std::string& build_dir, bool force_create) {
273 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 274 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
274 275
275 scheduler_.set_verbose_logging(cmdline->HasSwitch(switches::kVerbose)); 276 scheduler_.set_verbose_logging(cmdline->HasSwitch(switches::kVerbose));
276 if (cmdline->HasSwitch(switches::kTime) || 277 if (cmdline->HasSwitch(switches::kTime) ||
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 if (err.has_error()) { 734 if (err.has_error()) {
734 err.PrintToStdout(); 735 err.PrintToStdout();
735 return false; 736 return false;
736 } 737 }
737 } 738 }
738 build_settings_.set_exec_script_whitelist(std::move(whitelist)); 739 build_settings_.set_exec_script_whitelist(std::move(whitelist));
739 } 740 }
740 741
741 return true; 742 return true;
742 } 743 }
OLDNEW
« no previous file with comments | « tools/gn/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698