Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: gin/modules/module_registry.cc

Issue 187653004: Adds ModuleRegistryObserver interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: integrate feedback Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/modules/module_registry.h ('k') | gin/modules/module_registry_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/modules/module_registry.cc
diff --git a/gin/modules/module_registry.cc b/gin/modules/module_registry.cc
index d4e306709bfa508b97064c32ebed04c873b299e4..3712f1a41ac79fe29a33fcfadd73ee4a2d52ed42 100644
--- a/gin/modules/module_registry.cc
+++ b/gin/modules/module_registry.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "gin/arguments.h"
#include "gin/converter.h"
+#include "gin/modules/module_registry_observer.h"
#include "gin/per_context_data.h"
#include "gin/per_isolate_data.h"
#include "gin/public/wrapper_info.h"
@@ -112,6 +113,13 @@ void ModuleRegistry::RegisterGlobals(Isolate* isolate,
}
// static
+void ModuleRegistry::InstallGlobals(v8::Isolate* isolate,
+ v8::Handle<v8::Object> obj) {
+ obj->Set(StringToSymbol(isolate, "define"),
+ GetDefineTemplate(isolate)->GetFunction());
+}
+
+// static
ModuleRegistry* ModuleRegistry::From(v8::Handle<Context> context) {
PerContextData* data = PerContextData::From(context);
if (!data)
@@ -128,6 +136,14 @@ ModuleRegistry* ModuleRegistry::From(v8::Handle<Context> context) {
return registry_data->registry.get();
}
+void ModuleRegistry::AddObserver(ModuleRegistryObserver* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void ModuleRegistry::RemoveObserver(ModuleRegistryObserver* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
void ModuleRegistry::AddBuiltinModule(Isolate* isolate, const std::string& id,
v8::Handle<Value> module) {
DCHECK(!id.empty());
@@ -136,7 +152,11 @@ void ModuleRegistry::AddBuiltinModule(Isolate* isolate, const std::string& id,
void ModuleRegistry::AddPendingModule(Isolate* isolate,
scoped_ptr<PendingModule> pending) {
+ const std::string pending_id = pending->id;
+ const std::vector<std::string> pending_dependencies = pending->dependencies;
AttemptToLoad(isolate, pending.Pass());
+ FOR_EACH_OBSERVER(ModuleRegistryObserver, observer_list_,
+ OnDidAddPendingModule(pending_id, pending_dependencies));
}
void ModuleRegistry::LoadModule(Isolate* isolate,
« no previous file with comments | « gin/modules/module_registry.h ('k') | gin/modules/module_registry_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698