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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GIN_MODULES_MODULE_REGISTRY_H_
6 #define GIN_MODULES_MODULE_REGISTRY_H_
7
8 #include <list>
9 #include <string>
10 #include "base/compiler_specific.h"
11 #include "gin/per_context_data.h"
12
13 namespace gin {
14
15 struct PendingModule;
16
17 // This class implements the Asynchronous Module Definition (AMD) API.
18 // https://github.com/amdjs/amdjs-api/wiki/AMD
19 //
20 // Our implementation isn't complete yet. Missing features:
21 // 1) Built-in support for require, exports, and module.
22 // 2) Path resoltuion in module names.
23 //
24 // For these reasons, we don't have an "amd" property on the "define"
25 // function. The spec says we should only add that property once our
26 // implementation complies with the specification.
27 //
28 class ModuleRegistry : public ContextSupplement {
29 public:
30 static ModuleRegistry* From(v8::Handle<v8::Context> context);
31
32 static void RegisterGlobals(v8::Isolate* isolate,
33 v8::Handle<v8::ObjectTemplate> templ);
34
35 // The caller must have already entered our context.
36 void AddBuiltinModule(v8::Isolate* isolate,
37 const std::string& id,
38 v8::Handle<v8::ObjectTemplate> templ);
39
40 // Takes ownership of |pending|. The caller must have already entered
41 // our context.
42 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
43
44 private:
45 typedef std::list<PendingModule*> PendingModuleList; // Owning reference.
46
47 explicit ModuleRegistry(v8::Isolate* isolate);
48 virtual ~ModuleRegistry();
49
50 static v8::Handle<v8::String> Key(v8::Isolate* isolate);
51
52 // From ContextSupplement:
53 virtual void Detach(v8::Handle<v8::Context> context) OVERRIDE;
54
55 // Takes ownership of |pending|.
56 bool AttemptToLoad(v8::Isolate* isolate, PendingModule* pending);
57 void AttemptToLoadPendingModules(v8::Isolate* isolate);
58
59 v8::Persistent<v8::Object> modules_;
60 PendingModuleList pending_modules_;
61
62 DISALLOW_COPY_AND_ASSIGN(ModuleRegistry);
63 };
64
65 } // namespace gin
66
67 #endif // GIN_MODULES_MODULE_REGISTRY_H_
OLDNEW
« 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