Index: extensions/renderer/module_system.h |
diff --git a/extensions/renderer/module_system.h b/extensions/renderer/module_system.h |
index eec25cce5228a510eff77d9b3c6c2ec98497f535..24f637b1a2cfb67baa78962d96dbdff6ba95ae89 100644 |
--- a/extensions/renderer/module_system.h |
+++ b/extensions/renderer/module_system.h |
@@ -15,6 +15,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "extensions/renderer/native_handler.h" |
#include "extensions/renderer/object_backed_native_handler.h" |
+#include "gin/modules/module_registry_observer.h" |
#include "v8/include/v8.h" |
namespace extensions { |
@@ -37,7 +38,8 @@ class ScriptContext; |
// Note that a ModuleSystem must be used only in conjunction with a single |
// v8::Context. |
// TODO(koz): Rename this to JavaScriptModuleSystem. |
-class ModuleSystem : public ObjectBackedNativeHandler { |
+class ModuleSystem : public ObjectBackedNativeHandler, |
+ public gin::ModuleRegistryObserver { |
public: |
class SourceMap { |
public: |
@@ -158,9 +160,6 @@ class ModuleSystem : public ObjectBackedNativeHandler { |
// Called when an exception is thrown but not caught. |
void HandleException(const v8::TryCatch& try_catch); |
- // Ensure that require_ has been evaluated from require.js. |
- void EnsureRequireLoaded(); |
- |
void RequireForJs(const v8::FunctionCallbackInfo<v8::Value>& args); |
v8::Local<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); |
@@ -183,15 +182,32 @@ class ModuleSystem : public ObjectBackedNativeHandler { |
v8::Handle<v8::Value> RequireNativeFromString(const std::string& native_name); |
void RequireNative(const v8::FunctionCallbackInfo<v8::Value>& args); |
+ // Return a promise for a requested module. |
+ // |args[0]| - the name of a module. |
+ void RequireAsync(const v8::FunctionCallbackInfo<v8::Value>& args); |
+ |
// Wraps |source| in a (function(require, requireNative, exports) {...}). |
v8::Handle<v8::String> WrapSource(v8::Handle<v8::String> source); |
+ // Wraps |source| in a (function(define) {...}). |
+ v8::Handle<v8::String> WrapAmdSource(v8::Handle<v8::String> source); |
not at google - send to devlin
2014/07/01 18:13:05
nit: Amd looks like a typo for And. could you use
Sam McNally
2014/07/02 03:26:35
Merged it into WrapSource.
|
+ |
// NativeHandler implementation which returns the private area of an Object. |
void Private(const v8::FunctionCallbackInfo<v8::Value>& args); |
- // NativeHandler implementation which returns a function wrapper for a |
- // provided function. |
- void CreateFunctionWrapper(const v8::FunctionCallbackInfo<v8::Value>& args); |
+ // Loads and runs an AMD module. |
+ void LoadAmdModule(const std::string& module_name); |
+ |
+ // Invoked when a module is loaded in response to a requireAsync call. |
+ // Resolves |resolver| with |value|. |
+ void OnModuleLoaded( |
+ scoped_ptr<v8::UniquePersistent<v8::Promise::Resolver> > resolver, |
+ v8::Handle<v8::Value> value); |
+ |
+ // gin::ModuleRegistryObserver overrides. |
+ virtual void OnDidAddPendingModule( |
+ const std::string& id, |
+ const std::vector<std::string>& dependencies) OVERRIDE; |
ScriptContext* context_; |
@@ -212,6 +228,8 @@ class ModuleSystem : public ObjectBackedNativeHandler { |
std::set<std::string> overridden_native_handlers_; |
+ base::WeakPtrFactory<ModuleSystem> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ModuleSystem); |
}; |