OLD | NEW |
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/input_file_manager.h" | 5 #include "tools/gn/input_file_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
10 #include "tools/gn/parser.h" | 10 #include "tools/gn/parser.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 // The other load could have failed. In this case that error will be printed | 162 // The other load could have failed. In this case that error will be printed |
163 // to the console, but we need to return something here, so make up a | 163 // to the console, but we need to return something here, so make up a |
164 // dummy error. | 164 // dummy error. |
165 if (!data->parsed_root) | 165 if (!data->parsed_root) |
166 *err = Err(origin, "File parse failed"); | 166 *err = Err(origin, "File parse failed"); |
167 return data->parsed_root.get(); | 167 return data->parsed_root.get(); |
168 } | 168 } |
169 | 169 |
170 void InputFileManager::AddDynamicInput(const SourceFile& name, | 170 void InputFileManager::AddDynamicInput(InputFile** file, |
171 InputFile** file, | |
172 std::vector<Token>** tokens, | 171 std::vector<Token>** tokens, |
173 scoped_ptr<ParseNode>** parse_root) { | 172 scoped_ptr<ParseNode>** parse_root) { |
174 InputFileData* data = new InputFileData(name); | 173 InputFileData* data = new InputFileData(SourceFile()); |
175 { | 174 { |
176 base::AutoLock lock(lock_); | 175 base::AutoLock lock(lock_); |
177 dynamic_inputs_.push_back(data); | 176 dynamic_inputs_.push_back(data); |
178 } | 177 } |
179 *file = &data->file; | 178 *file = &data->file; |
180 *tokens = &data->tokens; | 179 *tokens = &data->tokens; |
181 *parse_root = &data->parsed_root; | 180 *parse_root = &data->parsed_root; |
182 } | 181 } |
183 | 182 |
184 int InputFileManager::GetInputFileCount() const { | 183 int InputFileManager::GetInputFileCount() const { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 callbacks.swap(data->scheduled_callbacks); | 284 callbacks.swap(data->scheduled_callbacks); |
286 } | 285 } |
287 | 286 |
288 // Run pending invocations. Theoretically we could schedule each of these | 287 // Run pending invocations. Theoretically we could schedule each of these |
289 // separately to get some parallelism. But normally there will only be one | 288 // separately to get some parallelism. But normally there will only be one |
290 // item in the list, so that's extra overhead and complexity for no gain. | 289 // item in the list, so that's extra overhead and complexity for no gain. |
291 for (size_t i = 0; i < callbacks.size(); i++) | 290 for (size_t i = 0; i < callbacks.size(); i++) |
292 callbacks[i].Run(unowned_root); | 291 callbacks[i].Run(unowned_root); |
293 return true; | 292 return true; |
294 } | 293 } |
OLD | NEW |