| 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(InputFile** file, | 170 void InputFileManager::AddDynamicInput(const SourceFile& name, |
| 171 InputFile** file, |
| 171 std::vector<Token>** tokens, | 172 std::vector<Token>** tokens, |
| 172 scoped_ptr<ParseNode>** parse_root) { | 173 scoped_ptr<ParseNode>** parse_root) { |
| 173 InputFileData* data = new InputFileData(SourceFile()); | 174 InputFileData* data = new InputFileData(name); |
| 174 { | 175 { |
| 175 base::AutoLock lock(lock_); | 176 base::AutoLock lock(lock_); |
| 176 dynamic_inputs_.push_back(data); | 177 dynamic_inputs_.push_back(data); |
| 177 } | 178 } |
| 178 *file = &data->file; | 179 *file = &data->file; |
| 179 *tokens = &data->tokens; | 180 *tokens = &data->tokens; |
| 180 *parse_root = &data->parsed_root; | 181 *parse_root = &data->parsed_root; |
| 181 } | 182 } |
| 182 | 183 |
| 183 int InputFileManager::GetInputFileCount() const { | 184 int InputFileManager::GetInputFileCount() const { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 callbacks.swap(data->scheduled_callbacks); | 285 callbacks.swap(data->scheduled_callbacks); |
| 285 } | 286 } |
| 286 | 287 |
| 287 // Run pending invocations. Theoretically we could schedule each of these | 288 // Run pending invocations. Theoretically we could schedule each of these |
| 288 // separately to get some parallelism. But normally there will only be one | 289 // separately to get some parallelism. But normally there will only be one |
| 289 // item in the list, so that's extra overhead and complexity for no gain. | 290 // item in the list, so that's extra overhead and complexity for no gain. |
| 290 for (size_t i = 0; i < callbacks.size(); i++) | 291 for (size_t i = 0; i < callbacks.size(); i++) |
| 291 callbacks[i].Run(unowned_root); | 292 callbacks[i].Run(unowned_root); |
| 292 return true; | 293 return true; |
| 293 } | 294 } |
| OLD | NEW |