| 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 <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Retrieves the lazily defined field specified by |property| on a native | 176 // Retrieves the lazily defined field specified by |property| on a native |
| 177 // object. | 177 // object. |
| 178 static void NativeLazyFieldGetter( | 178 static void NativeLazyFieldGetter( |
| 179 v8::Local<v8::Name> property, | 179 v8::Local<v8::Name> property, |
| 180 const v8::PropertyCallbackInfo<v8::Value>& info); | 180 const v8::PropertyCallbackInfo<v8::Value>& info); |
| 181 | 181 |
| 182 // Called when an exception is thrown but not caught. | 182 // Called when an exception is thrown but not caught. |
| 183 void HandleException(const v8::TryCatch& try_catch); | 183 void HandleException(const v8::TryCatch& try_catch); |
| 184 | 184 |
| 185 void RequireForJs(const v8::FunctionCallbackInfo<v8::Value>& args); | 185 void RequireForJs(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 186 v8::Local<v8::Value> RequireForJsInner(v8::Local<v8::String> module_name); | 186 |
| 187 // Returns the module with the given |module_name|. If |create| is true, the |
| 188 // module will be loaded if it hasn't been already. Otherwise, the module |
| 189 // will only be returned if it has already been loaded. |
| 190 v8::Local<v8::Value> RequireForJsInner(v8::Local<v8::String> module_name, |
| 191 bool create); |
| 187 | 192 |
| 188 typedef v8::MaybeLocal<v8::Object>(ModuleSystem::*RequireFunction)( | 193 typedef v8::MaybeLocal<v8::Object>(ModuleSystem::*RequireFunction)( |
| 189 const std::string&); | 194 const std::string&); |
| 190 // Base implementation of a LazyFieldGetter which uses |require_fn| to require | 195 // Base implementation of a LazyFieldGetter which uses |require_fn| to require |
| 191 // modules. | 196 // modules. |
| 192 static void LazyFieldGetterInner( | 197 static void LazyFieldGetterInner( |
| 193 v8::Local<v8::String> property, | 198 v8::Local<v8::String> property, |
| 194 const v8::PropertyCallbackInfo<v8::Value>& info, | 199 const v8::PropertyCallbackInfo<v8::Value>& info, |
| 195 RequireFunction require_function); | 200 RequireFunction require_function); |
| 196 | 201 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // gin::ModuleRegistryObserver overrides. | 235 // gin::ModuleRegistryObserver overrides. |
| 231 void OnDidAddPendingModule( | 236 void OnDidAddPendingModule( |
| 232 const std::string& id, | 237 const std::string& id, |
| 233 const std::vector<std::string>& dependencies) override; | 238 const std::vector<std::string>& dependencies) override; |
| 234 | 239 |
| 235 // Marks any existing NativeHandler named |name| as clobbered. | 240 // Marks any existing NativeHandler named |name| as clobbered. |
| 236 // See |clobbered_native_handlers_|. | 241 // See |clobbered_native_handlers_|. |
| 237 void ClobberExistingNativeHandler(const std::string& name); | 242 void ClobberExistingNativeHandler(const std::string& name); |
| 238 | 243 |
| 239 // Returns the v8::Function associated with the given module and method name. | 244 // Returns the v8::Function associated with the given module and method name. |
| 245 // This will *not* load a module if it hasn't been loaded already. |
| 240 v8::Local<v8::Function> GetModuleFunction(const std::string& module_name, | 246 v8::Local<v8::Function> GetModuleFunction(const std::string& module_name, |
| 241 const std::string& method_name); | 247 const std::string& method_name); |
| 242 | 248 |
| 243 ScriptContext* context_; | 249 ScriptContext* context_; |
| 244 | 250 |
| 245 // A map from module names to the JS source for that module. GetSource() | 251 // A map from module names to the JS source for that module. GetSource() |
| 246 // performs a lookup on this map. | 252 // performs a lookup on this map. |
| 247 const SourceMap* const source_map_; | 253 const SourceMap* const source_map_; |
| 248 | 254 |
| 249 // A map from native handler names to native handlers. | 255 // A map from native handler names to native handlers. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 276 std::set<std::string> loaded_modules_; | 282 std::set<std::string> loaded_modules_; |
| 277 | 283 |
| 278 base::WeakPtrFactory<ModuleSystem> weak_factory_; | 284 base::WeakPtrFactory<ModuleSystem> weak_factory_; |
| 279 | 285 |
| 280 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); | 286 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); |
| 281 }; | 287 }; |
| 282 | 288 |
| 283 } // namespace extensions | 289 } // namespace extensions |
| 284 | 290 |
| 285 #endif // EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ | 291 #endif // EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ |
| OLD | NEW |