Index: gin/modules/module_registry.h |
diff --git a/gin/modules/module_registry.h b/gin/modules/module_registry.h |
index 7cff355963725107010cdf99994ed8e85ec32bd6..a7732c8091854261dcda24501b0362514cfb3ac8 100644 |
--- a/gin/modules/module_registry.h |
+++ b/gin/modules/module_registry.h |
@@ -6,8 +6,11 @@ |
#define GIN_MODULES_MODULE_REGISTRY_H_ |
#include <list> |
+#include <set> |
#include <string> |
+ |
#include "base/compiler_specific.h" |
+#include "base/memory/scoped_ptr.h" |
#include "gin/per_context_data.h" |
namespace gin { |
@@ -27,6 +30,8 @@ struct PendingModule; |
// |
class ModuleRegistry : public ContextSupplement { |
public: |
+ virtual ~ModuleRegistry(); |
+ |
static ModuleRegistry* From(v8::Handle<v8::Context> context); |
static void RegisterGlobals(v8::Isolate* isolate, |
@@ -37,25 +42,42 @@ class ModuleRegistry : public ContextSupplement { |
const std::string& id, |
v8::Handle<v8::ObjectTemplate> templ); |
- // Takes ownership of |pending|. The caller must have already entered |
- // our context. |
- void AddPendingModule(v8::Isolate* isolate, PendingModule* pending); |
+ // The caller must have already entered our context. |
+ void AddPendingModule(v8::Isolate* isolate, |
+ scoped_ptr<PendingModule> pending); |
+ |
+ // The caller must have already entered our context. |
+ void AttemptToLoadMoreModules(v8::Isolate* isolate); |
+ |
+ const std::set<std::string>& available_modules() const { |
+ return available_modules_; |
+ } |
+ |
+ const std::set<std::string>& unsatisfied_dependencies() const { |
+ return unsatisfied_dependencies_; |
+ } |
private: |
- typedef std::list<PendingModule*> PendingModuleList; // Owning reference. |
+ typedef ScopedVector<PendingModule> PendingModuleVector; |
explicit ModuleRegistry(v8::Isolate* isolate); |
- virtual ~ModuleRegistry(); |
// From ContextSupplement: |
virtual void Detach(v8::Handle<v8::Context> context) OVERRIDE; |
- // Takes ownership of |pending|. |
- bool AttemptToLoad(v8::Isolate* isolate, PendingModule* pending); |
- void AttemptToLoadPendingModules(v8::Isolate* isolate); |
+ void Load(v8::Isolate* isolate, scoped_ptr<PendingModule> pending); |
+ void RegisterModule(v8::Isolate* isolate, |
+ const std::string& id, |
+ v8::Handle<v8::Value> module); |
+ |
+ bool CheckDependencies(PendingModule* pending); |
+ bool AttemptToLoad(v8::Isolate* isolate, scoped_ptr<PendingModule> pending); |
+ |
+ std::set<std::string> available_modules_; |
+ std::set<std::string> unsatisfied_dependencies_; |
+ PendingModuleVector pending_modules_; |
v8::Persistent<v8::Object> modules_; |
- PendingModuleList pending_modules_; |
DISALLOW_COPY_AND_ASSIGN(ModuleRegistry); |
}; |