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/import_manager.h" | 5 #include "tools/gn/import_manager.h" |
6 | 6 |
7 #include "tools/gn/err.h" | 7 #include "tools/gn/err.h" |
8 #include "tools/gn/parse_tree.h" | 8 #include "tools/gn/parse_tree.h" |
9 #include "tools/gn/scheduler.h" | 9 #include "tools/gn/scheduler.h" |
10 #include "tools/gn/scope_per_file_provider.h" | 10 #include "tools/gn/scope_per_file_provider.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return false; | 104 return false; |
105 } | 105 } |
106 } else { | 106 } else { |
107 // Add trace if this thread was blocked for a long period of time and did | 107 // Add trace if this thread was blocked for a long period of time and did |
108 // not load the import itself. | 108 // not load the import itself. |
109 base::TimeTicks import_block_end = base::TimeTicks::Now(); | 109 base::TimeTicks import_block_end = base::TimeTicks::Now(); |
110 constexpr auto kImportBlockTraceThreshold = | 110 constexpr auto kImportBlockTraceThreshold = |
111 base::TimeDelta::FromMilliseconds(20); | 111 base::TimeDelta::FromMilliseconds(20); |
112 if (TracingEnabled() && | 112 if (TracingEnabled() && |
113 import_block_end - import_block_begin > kImportBlockTraceThreshold) { | 113 import_block_end - import_block_begin > kImportBlockTraceThreshold) { |
114 auto import_block_trace = | 114 auto* import_block_trace = |
115 new TraceItem(TraceItem::TRACE_IMPORT_BLOCK, file.value(), | 115 new TraceItem(TraceItem::TRACE_IMPORT_BLOCK, file.value(), |
116 base::PlatformThread::CurrentId()); | 116 base::PlatformThread::CurrentId()); |
117 import_block_trace->set_begin(import_block_begin); | 117 import_block_trace->set_begin(import_block_begin); |
118 import_block_trace->set_end(import_block_end); | 118 import_block_trace->set_end(import_block_end); |
119 AddTrace(import_block_trace); | 119 AddTrace(import_block_trace); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 // Promote the now-read-only scope to outside the load lock. | 123 // Promote the now-read-only scope to outside the load lock. |
124 import_scope = import_info->scope.get(); | 124 import_scope = import_info->scope.get(); |
125 } | 125 } |
126 | 126 |
127 Scope::MergeOptions options; | 127 Scope::MergeOptions options; |
128 options.skip_private_vars = true; | 128 options.skip_private_vars = true; |
129 options.mark_dest_used = true; // Don't require all imported values be used. | 129 options.mark_dest_used = true; // Don't require all imported values be used. |
130 return import_scope->NonRecursiveMergeTo(scope, options, node_for_err, | 130 return import_scope->NonRecursiveMergeTo(scope, options, node_for_err, |
131 "import", err); | 131 "import", err); |
132 } | 132 } |
133 | 133 |
134 std::vector<SourceFile> ImportManager::GetImportedFiles() const { | 134 std::vector<SourceFile> ImportManager::GetImportedFiles() const { |
135 std::vector<SourceFile> imported_files; | 135 std::vector<SourceFile> imported_files; |
136 imported_files.resize(imports_.size()); | 136 imported_files.resize(imports_.size()); |
137 std::transform(imports_.begin(), imports_.end(), imported_files.begin(), | 137 std::transform(imports_.begin(), imports_.end(), imported_files.begin(), |
138 [](const ImportMap::value_type& val) { return val.first; }); | 138 [](const ImportMap::value_type& val) { return val.first; }); |
139 return imported_files; | 139 return imported_files; |
140 } | 140 } |
OLD | NEW |