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

Side by Side Diff: gin/modules/module_registry.h

Issue 74753002: Introduce gin_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style nits 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GIN_MODULES_MODULE_REGISTRY_H_ 5 #ifndef GIN_MODULES_MODULE_REGISTRY_H_
6 #define GIN_MODULES_MODULE_REGISTRY_H_ 6 #define GIN_MODULES_MODULE_REGISTRY_H_
7 7
8 #include <list> 8 #include <list>
9 #include <set>
9 #include <string> 10 #include <string>
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
jochen (gone - plz use gerrit) 2013/11/18 12:46:05 nit empty line before this line
abarth-chromium 2013/11/18 15:33:06 Done.
12 #include "base/memory/scoped_ptr.h"
11 #include "gin/per_context_data.h" 13 #include "gin/per_context_data.h"
12 14
13 namespace gin { 15 namespace gin {
14 16
15 struct PendingModule; 17 struct PendingModule;
16 18
17 // This class implements the Asynchronous Module Definition (AMD) API. 19 // This class implements the Asynchronous Module Definition (AMD) API.
18 // https://github.com/amdjs/amdjs-api/wiki/AMD 20 // https://github.com/amdjs/amdjs-api/wiki/AMD
19 // 21 //
20 // Our implementation isn't complete yet. Missing features: 22 // Our implementation isn't complete yet. Missing features:
(...skipping 11 matching lines...) Expand all
32 static ModuleRegistry* From(v8::Handle<v8::Context> context); 34 static ModuleRegistry* From(v8::Handle<v8::Context> context);
33 35
34 static void RegisterGlobals(v8::Isolate* isolate, 36 static void RegisterGlobals(v8::Isolate* isolate,
35 v8::Handle<v8::ObjectTemplate> templ); 37 v8::Handle<v8::ObjectTemplate> templ);
36 38
37 // The caller must have already entered our context. 39 // The caller must have already entered our context.
38 void AddBuiltinModule(v8::Isolate* isolate, 40 void AddBuiltinModule(v8::Isolate* isolate,
39 const std::string& id, 41 const std::string& id,
40 v8::Handle<v8::ObjectTemplate> templ); 42 v8::Handle<v8::ObjectTemplate> templ);
41 43
42 // Takes ownership of |pending|. The caller must have already entered 44 // The caller must have already entered our context.
43 // our context. 45 void AddPendingModule(v8::Isolate* isolate,
44 void AddPendingModule(v8::Isolate* isolate, PendingModule* pending); 46 scoped_ptr<PendingModule> pending);
47
48 // The caller must have already entered our context.
49 void AttemptToLoadMoreModules(v8::Isolate* isolate);
50
51 const std::set<std::string>& available_modules() const {
52 return available_modules_;
53 }
54
55 const std::set<std::string>& unsatisfied_dependencies() const {
56 return unsatisfied_dependencies_;
57 }
45 58
46 private: 59 private:
47 typedef std::list<PendingModule*> PendingModuleList; // Owning reference. 60 typedef ScopedVector<PendingModule> PendingModuleVector;
48 61
49 explicit ModuleRegistry(v8::Isolate* isolate); 62 explicit ModuleRegistry(v8::Isolate* isolate);
50 63
51 // From ContextSupplement: 64 // From ContextSupplement:
52 virtual void Detach(v8::Handle<v8::Context> context) OVERRIDE; 65 virtual void Detach(v8::Handle<v8::Context> context) OVERRIDE;
53 66
54 // Takes ownership of |pending|. 67 void Load(v8::Isolate* isolate, scoped_ptr<PendingModule> pending);
55 bool AttemptToLoad(v8::Isolate* isolate, PendingModule* pending); 68 void RegisterModule(v8::Isolate* isolate,
56 void AttemptToLoadPendingModules(v8::Isolate* isolate); 69 const std::string& id,
70 v8::Handle<v8::Value> module);
57 71
72 bool CheckDependencies(PendingModule* pending);
73 bool AttemptToLoad(v8::Isolate* isolate, scoped_ptr<PendingModule> pending);
74
75 std::set<std::string> available_modules_;
76 std::set<std::string> unsatisfied_dependencies_;
77
78 PendingModuleVector pending_modules_;
58 v8::Persistent<v8::Object> modules_; 79 v8::Persistent<v8::Object> modules_;
59 PendingModuleList pending_modules_;
60 80
61 DISALLOW_COPY_AND_ASSIGN(ModuleRegistry); 81 DISALLOW_COPY_AND_ASSIGN(ModuleRegistry);
62 }; 82 };
63 83
64 } // namespace gin 84 } // namespace gin
65 85
66 #endif // GIN_MODULES_MODULE_REGISTRY_H_ 86 #endif // GIN_MODULES_MODULE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698