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 #ifndef TOOLS_GN_LOADER_H_ | 5 #ifndef TOOLS_GN_LOADER_H_ |
6 #define TOOLS_GN_LOADER_H_ | 6 #define TOOLS_GN_LOADER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Callback to emulate InputFileManager::AsyncLoadFile. | 75 // Callback to emulate InputFileManager::AsyncLoadFile. |
76 typedef base::Callback<bool(const LocationRange&, | 76 typedef base::Callback<bool(const LocationRange&, |
77 const BuildSettings*, | 77 const BuildSettings*, |
78 const SourceFile&, | 78 const SourceFile&, |
79 const base::Callback<void(const ParseNode*)>&, | 79 const base::Callback<void(const ParseNode*)>&, |
80 Err*)> AsyncLoadFileCallback; | 80 Err*)> AsyncLoadFileCallback; |
81 | 81 |
82 LoaderImpl(const BuildSettings* build_settings); | 82 LoaderImpl(const BuildSettings* build_settings); |
83 | 83 |
84 // Loader implementation. | 84 // Loader implementation. |
85 virtual void Load(const SourceFile& file, | 85 void Load(const SourceFile& file, |
86 const LocationRange& origin, | 86 const LocationRange& origin, |
87 const Label& toolchain_name) override; | 87 const Label& toolchain_name) override; |
88 virtual void ToolchainLoaded(const Toolchain* toolchain) override; | 88 void ToolchainLoaded(const Toolchain* toolchain) override; |
89 virtual Label GetDefaultToolchain() const override; | 89 Label GetDefaultToolchain() const override; |
90 virtual const Settings* GetToolchainSettings( | 90 const Settings* GetToolchainSettings(const Label& label) const override; |
91 const Label& label) const override; | |
92 | 91 |
93 // Sets the message loop corresponding to the main thread. By default this | 92 // Sets the message loop corresponding to the main thread. By default this |
94 // class will use the thread active during construction, but there is not | 93 // class will use the thread active during construction, but there is not |
95 // a message loop active during construction all the time. | 94 // a message loop active during construction all the time. |
96 void set_main_loop(base::MessageLoop* loop) { main_loop_ = loop; } | 95 void set_main_loop(base::MessageLoop* loop) { main_loop_ = loop; } |
97 | 96 |
98 // The complete callback is called whenever there are no more pending loads. | 97 // The complete callback is called whenever there are no more pending loads. |
99 // Called on the main thread only. This may be called more than once if the | 98 // Called on the main thread only. This may be called more than once if the |
100 // queue is drained, but then more stuff gets added. | 99 // queue is drained, but then more stuff gets added. |
101 void set_complete_callback(const base::Closure& cb) { | 100 void set_complete_callback(const base::Closure& cb) { |
102 complete_callback_ = cb; | 101 complete_callback_ = cb; |
103 } | 102 } |
104 | 103 |
105 // This callback is used when the loader finds it wants to load a file. | 104 // This callback is used when the loader finds it wants to load a file. |
106 void set_async_load_file(const AsyncLoadFileCallback& cb) { | 105 void set_async_load_file(const AsyncLoadFileCallback& cb) { |
107 async_load_file_ = cb; | 106 async_load_file_ = cb; |
108 } | 107 } |
109 | 108 |
110 const Label& default_toolchain_label() const { | 109 const Label& default_toolchain_label() const { |
111 return default_toolchain_label_; | 110 return default_toolchain_label_; |
112 } | 111 } |
113 | 112 |
114 private: | 113 private: |
115 struct LoadID; | 114 struct LoadID; |
116 struct ToolchainRecord; | 115 struct ToolchainRecord; |
117 | 116 |
118 virtual ~LoaderImpl(); | 117 ~LoaderImpl() override; |
119 | 118 |
120 // Schedules the input file manager to load the given file. | 119 // Schedules the input file manager to load the given file. |
121 void ScheduleLoadFile(const Settings* settings, | 120 void ScheduleLoadFile(const Settings* settings, |
122 const LocationRange& origin, | 121 const LocationRange& origin, |
123 const SourceFile& file); | 122 const SourceFile& file); |
124 void ScheduleLoadBuildConfig( | 123 void ScheduleLoadBuildConfig( |
125 Settings* settings, | 124 Settings* settings, |
126 const Scope::KeyValueMap& toolchain_overrides); | 125 const Scope::KeyValueMap& toolchain_overrides); |
127 | 126 |
128 // Runs the given file on the background thread. These are called by the | 127 // Runs the given file on the background thread. These are called by the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 const BuildSettings* build_settings_; | 172 const BuildSettings* build_settings_; |
174 Label default_toolchain_label_; | 173 Label default_toolchain_label_; |
175 | 174 |
176 // Records for the build config file loads. | 175 // Records for the build config file loads. |
177 // Owning pointers. | 176 // Owning pointers. |
178 typedef std::map<Label, ToolchainRecord*> ToolchainRecordMap; | 177 typedef std::map<Label, ToolchainRecord*> ToolchainRecordMap; |
179 ToolchainRecordMap toolchain_records_; | 178 ToolchainRecordMap toolchain_records_; |
180 }; | 179 }; |
181 | 180 |
182 #endif // TOOLS_GN_LOADER_H_ | 181 #endif // TOOLS_GN_LOADER_H_ |
OLD | NEW |