OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ | 5 #ifndef EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ |
6 #define EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ | 6 #define EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 const std::string& module_name, | 136 const std::string& module_name, |
137 const std::string& module_field); | 137 const std::string& module_field); |
138 | 138 |
139 // Passes exceptions to |handler| rather than console::Fatal. | 139 // Passes exceptions to |handler| rather than console::Fatal. |
140 void SetExceptionHandlerForTest(scoped_ptr<ExceptionHandler> handler) { | 140 void SetExceptionHandlerForTest(scoped_ptr<ExceptionHandler> handler) { |
141 exception_handler_ = handler.Pass(); | 141 exception_handler_ = handler.Pass(); |
142 } | 142 } |
143 | 143 |
144 protected: | 144 protected: |
145 friend class ScriptContext; | 145 friend class ScriptContext; |
146 virtual void Invalidate() OVERRIDE; | 146 virtual void Invalidate() override; |
147 | 147 |
148 private: | 148 private: |
149 typedef std::map<std::string, linked_ptr<NativeHandler> > NativeHandlerMap; | 149 typedef std::map<std::string, linked_ptr<NativeHandler> > NativeHandlerMap; |
150 | 150 |
151 // Retrieves the lazily defined field specified by |property|. | 151 // Retrieves the lazily defined field specified by |property|. |
152 static void LazyFieldGetter(v8::Local<v8::String> property, | 152 static void LazyFieldGetter(v8::Local<v8::String> property, |
153 const v8::PropertyCallbackInfo<v8::Value>& info); | 153 const v8::PropertyCallbackInfo<v8::Value>& info); |
154 // Retrieves the lazily defined field specified by |property| on a native | 154 // Retrieves the lazily defined field specified by |property| on a native |
155 // object. | 155 // object. |
156 static void NativeLazyFieldGetter( | 156 static void NativeLazyFieldGetter( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 // Invoked when a module is loaded in response to a requireAsync call. | 198 // Invoked when a module is loaded in response to a requireAsync call. |
199 // Resolves |resolver| with |value|. | 199 // Resolves |resolver| with |value|. |
200 void OnModuleLoaded( | 200 void OnModuleLoaded( |
201 scoped_ptr<v8::UniquePersistent<v8::Promise::Resolver> > resolver, | 201 scoped_ptr<v8::UniquePersistent<v8::Promise::Resolver> > resolver, |
202 v8::Handle<v8::Value> value); | 202 v8::Handle<v8::Value> value); |
203 | 203 |
204 // gin::ModuleRegistryObserver overrides. | 204 // gin::ModuleRegistryObserver overrides. |
205 virtual void OnDidAddPendingModule( | 205 virtual void OnDidAddPendingModule( |
206 const std::string& id, | 206 const std::string& id, |
207 const std::vector<std::string>& dependencies) OVERRIDE; | 207 const std::vector<std::string>& dependencies) override; |
208 | 208 |
209 ScriptContext* context_; | 209 ScriptContext* context_; |
210 | 210 |
211 // A map from module names to the JS source for that module. GetSource() | 211 // A map from module names to the JS source for that module. GetSource() |
212 // performs a lookup on this map. | 212 // performs a lookup on this map. |
213 SourceMap* source_map_; | 213 SourceMap* source_map_; |
214 | 214 |
215 // A map from native handler names to native handlers. | 215 // A map from native handler names to native handlers. |
216 NativeHandlerMap native_handler_map_; | 216 NativeHandlerMap native_handler_map_; |
217 | 217 |
218 // When 0, natives are disabled, otherwise indicates how many callers have | 218 // When 0, natives are disabled, otherwise indicates how many callers have |
219 // pinned natives as enabled. | 219 // pinned natives as enabled. |
220 int natives_enabled_; | 220 int natives_enabled_; |
221 | 221 |
222 // Called when an exception is thrown but not caught in JS. Overridable by | 222 // Called when an exception is thrown but not caught in JS. Overridable by |
223 // tests. | 223 // tests. |
224 scoped_ptr<ExceptionHandler> exception_handler_; | 224 scoped_ptr<ExceptionHandler> exception_handler_; |
225 | 225 |
226 std::set<std::string> overridden_native_handlers_; | 226 std::set<std::string> overridden_native_handlers_; |
227 | 227 |
228 base::WeakPtrFactory<ModuleSystem> weak_factory_; | 228 base::WeakPtrFactory<ModuleSystem> weak_factory_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); | 230 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); |
231 }; | 231 }; |
232 | 232 |
233 } // namespace extensions | 233 } // namespace extensions |
234 | 234 |
235 #endif // EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ | 235 #endif // EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ |
OLD | NEW |