OLD | NEW |
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 #include "gin/modules/module_registry.h" | 5 #include "gin/modules/module_registry.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if (!data) | 116 if (!data) |
117 return NULL; | 117 return NULL; |
118 ModuleRegistry* registry = new ModuleRegistry(isolate); | 118 ModuleRegistry* registry = new ModuleRegistry(isolate); |
119 context->Global()->SetHiddenValue(key, External::New(isolate, registry)); | 119 context->Global()->SetHiddenValue(key, External::New(isolate, registry)); |
120 data->AddSupplement(scoped_ptr<ContextSupplement>(registry)); | 120 data->AddSupplement(scoped_ptr<ContextSupplement>(registry)); |
121 return registry; | 121 return registry; |
122 } | 122 } |
123 return static_cast<ModuleRegistry*>(external->Value()); | 123 return static_cast<ModuleRegistry*>(external->Value()); |
124 } | 124 } |
125 | 125 |
126 void ModuleRegistry::AddBuiltinModule(Isolate* isolate, | 126 void ModuleRegistry::AddBuiltinModule(Isolate* isolate, const std::string& id, |
127 const std::string& id, | 127 v8::Handle<Value> module) { |
128 v8::Handle<ObjectTemplate> templ) { | |
129 DCHECK(!id.empty()); | 128 DCHECK(!id.empty()); |
130 RegisterModule(isolate, id, templ->NewInstance()); | 129 RegisterModule(isolate, id, module); |
131 } | 130 } |
132 | 131 |
133 void ModuleRegistry::AddPendingModule(Isolate* isolate, | 132 void ModuleRegistry::AddPendingModule(Isolate* isolate, |
134 scoped_ptr<PendingModule> pending) { | 133 scoped_ptr<PendingModule> pending) { |
135 AttemptToLoad(isolate, pending.Pass()); | 134 AttemptToLoad(isolate, pending.Pass()); |
136 } | 135 } |
137 | 136 |
138 void ModuleRegistry::LoadModule(Isolate* isolate, | 137 void ModuleRegistry::LoadModule(Isolate* isolate, |
139 const std::string& id, | 138 const std::string& id, |
140 LoadModuleCallback callback) { | 139 LoadModuleCallback callback) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 for (size_t i = 0; i < pending_modules.size(); ++i) { | 238 for (size_t i = 0; i < pending_modules.size(); ++i) { |
240 scoped_ptr<PendingModule> pending(pending_modules[i]); | 239 scoped_ptr<PendingModule> pending(pending_modules[i]); |
241 pending_modules[i] = NULL; | 240 pending_modules[i] = NULL; |
242 if (AttemptToLoad(isolate, pending.Pass())) | 241 if (AttemptToLoad(isolate, pending.Pass())) |
243 keep_trying = true; | 242 keep_trying = true; |
244 } | 243 } |
245 } | 244 } |
246 } | 245 } |
247 | 246 |
248 } // namespace gin | 247 } // namespace gin |
OLD | NEW |