Chromium Code Reviews| Index: gin/modules/module_registry.h |
| diff --git a/gin/modules/module_registry.h b/gin/modules/module_registry.h |
| index a7732c8091854261dcda24501b0362514cfb3ac8..342c3e1ae6dbf22aadf869a44463a3087fc21e38 100644 |
| --- a/gin/modules/module_registry.h |
| +++ b/gin/modules/module_registry.h |
| @@ -6,9 +6,11 @@ |
| #define GIN_MODULES_MODULE_REGISTRY_H_ |
| #include <list> |
| +#include <map> |
| #include <set> |
| #include <string> |
| +#include "base/callback.h" |
| #include "base/compiler_specific.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "gin/per_context_data.h" |
| @@ -17,6 +19,8 @@ namespace gin { |
| struct PendingModule; |
| +typedef base::Callback<void (v8::Handle<v8::Value>)> ModuleLoadCallback; |
|
Aaron Boodman
2013/11/27 19:02:41
Does this need to be namespace scoped?
Aaron Boodman
2013/11/27 19:02:41
Nit: The general style in Chrome is for non-primit
Aaron Boodman
2013/11/27 19:02:41
Nit: LoadModuleCallback, for parallelism with Load
abarth-chromium
2013/11/27 19:18:09
Done.
abarth-chromium
2013/11/27 19:18:09
v8::Handles are just pointers to pointers. Having
abarth-chromium
2013/11/27 19:18:09
Done.
|
| + |
| // This class implements the Asynchronous Module Definition (AMD) API. |
| // https://github.com/amdjs/amdjs-api/wiki/AMD |
| // |
| @@ -46,6 +50,10 @@ class ModuleRegistry : public ContextSupplement { |
| void AddPendingModule(v8::Isolate* isolate, |
| scoped_ptr<PendingModule> pending); |
| + void LoadModule(v8::Isolate* isolate, |
| + const std::string& id, |
| + ModuleLoadCallback callback); |
| + |
| // The caller must have already entered our context. |
| void AttemptToLoadMoreModules(v8::Isolate* isolate); |
| @@ -59,6 +67,7 @@ class ModuleRegistry : public ContextSupplement { |
| private: |
| typedef ScopedVector<PendingModule> PendingModuleVector; |
| + typedef std::map<std::string, ModuleLoadCallback> ModuleLoadCallbackMap; |
| explicit ModuleRegistry(v8::Isolate* isolate); |
| @@ -73,9 +82,13 @@ class ModuleRegistry : public ContextSupplement { |
| bool CheckDependencies(PendingModule* pending); |
| bool AttemptToLoad(v8::Isolate* isolate, scoped_ptr<PendingModule> pending); |
| + v8::Handle<v8::Value> GetModule(v8::Isolate* isolate, const std::string& id); |
| + |
| std::set<std::string> available_modules_; |
| std::set<std::string> unsatisfied_dependencies_; |
| + ModuleLoadCallbackMap waiting_callbacks_; |
| + |
| PendingModuleVector pending_modules_; |
| v8::Persistent<v8::Object> modules_; |