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

Unified Diff: gin/modules/module_registry.h

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar testing Created 7 years, 1 month 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
Index: gin/modules/module_registry.h
diff --git a/gin/modules/module_registry.h b/gin/modules/module_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..7b3f34db5c419268d0d13ff9b4e7ee0025f5c816
--- /dev/null
+++ b/gin/modules/module_registry.h
@@ -0,0 +1,67 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GIN_MODULES_MODULE_REGISTRY_H_
+#define GIN_MODULES_MODULE_REGISTRY_H_
+
+#include <list>
+#include <string>
+#include "base/compiler_specific.h"
+#include "gin/per_context_data.h"
+
+namespace gin {
+
+struct PendingModule;
+
+// This class implements the Asynchronous Module Definition (AMD) API.
+// https://github.com/amdjs/amdjs-api/wiki/AMD
+//
+// Our implementation isn't complete yet. Missing features:
+// 1) Built-in support for require, exports, and module.
+// 2) Path resoltuion in module names.
+//
+// For these reasons, we don't have an "amd" property on the "define"
+// function. The spec says we should only add that property once our
+// implementation complies with the specification.
+//
+class ModuleRegistry : public ContextSupplement {
+ public:
+ static ModuleRegistry* From(v8::Handle<v8::Context> context);
+
+ static void RegisterGlobals(v8::Isolate* isolate,
+ v8::Handle<v8::ObjectTemplate> templ);
+
+ // The caller must have already entered our context.
+ void AddBuiltinModule(v8::Isolate* isolate,
+ 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);
Aaron Boodman 2013/11/15 18:56:06 What is the rationale for not relying upon base? I
abarth-chromium 2013/11/15 19:13:37 Yeah, I agree that it's awkward not to have base.
Aaron Boodman 2013/11/15 19:54:30 In the bravo case, at least, the developer provide
+
+ private:
+ typedef std::list<PendingModule*> PendingModuleList; // Owning reference.
+
+ explicit ModuleRegistry(v8::Isolate* isolate);
+ virtual ~ModuleRegistry();
+
+ static v8::Handle<v8::String> Key(v8::Isolate* isolate);
+
+ // 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);
+
+ v8::Persistent<v8::Object> modules_;
+ PendingModuleList pending_modules_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModuleRegistry);
+};
+
+} // namespace gin
+
+#endif // GIN_MODULES_MODULE_REGISTRY_H_
« no previous file with comments | « gin/gin.gyp ('k') | gin/modules/module_registry.cc » ('j') | gin/modules/module_registry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698