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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 num_missing_dependencies++; | 174 num_missing_dependencies++; |
175 } | 175 } |
176 return num_missing_dependencies == 0; | 176 return num_missing_dependencies == 0; |
177 } | 177 } |
178 | 178 |
179 void ModuleRegistry::Load(Isolate* isolate, scoped_ptr<PendingModule> pending) { | 179 void ModuleRegistry::Load(Isolate* isolate, scoped_ptr<PendingModule> pending) { |
180 if (!pending->id.empty() && available_modules_.count(pending->id)) | 180 if (!pending->id.empty() && available_modules_.count(pending->id)) |
181 return; // We've already loaded this module. | 181 return; // We've already loaded this module. |
182 | 182 |
183 Handle<Object> modules = Local<Object>::New(isolate, modules_); | 183 Handle<Object> modules = Local<Object>::New(isolate, modules_); |
184 size_t argc = pending->dependencies.size(); | 184 uint32_t argc = static_cast<uint32_t>(pending->dependencies.size()); |
185 std::vector<Handle<Value> > argv(argc); | 185 std::vector<Handle<Value> > argv(argc); |
186 for (size_t i = 0; i < argc; ++i) { | 186 for (uint32_t i = 0; i < argc; ++i) { |
187 Handle<String> key = StringToSymbol(isolate, pending->dependencies[i]); | 187 Handle<String> key = StringToSymbol(isolate, pending->dependencies[i]); |
188 DCHECK(modules->HasOwnProperty(key)); | 188 DCHECK(modules->HasOwnProperty(key)); |
189 argv[i] = modules->Get(key); | 189 argv[i] = modules->Get(key); |
190 } | 190 } |
191 | 191 |
192 Handle<Value> module = Local<Value>::New(isolate, pending->factory); | 192 Handle<Value> module = Local<Value>::New(isolate, pending->factory); |
193 | 193 |
194 Handle<Function> factory; | 194 Handle<Function> factory; |
195 if (ConvertFromV8(module, &factory)) { | 195 if (ConvertFromV8(module, &factory)) { |
196 Handle<Object> global = isolate->GetCurrentContext()->Global(); | 196 Handle<Object> global = isolate->GetCurrentContext()->Global(); |
(...skipping 23 matching lines...) Expand all Loading... |
220 for (size_t i = 0; i < pending_modules.size(); ++i) { | 220 for (size_t i = 0; i < pending_modules.size(); ++i) { |
221 scoped_ptr<PendingModule> pending(pending_modules[i]); | 221 scoped_ptr<PendingModule> pending(pending_modules[i]); |
222 pending_modules[i] = NULL; | 222 pending_modules[i] = NULL; |
223 if (AttemptToLoad(isolate, pending.Pass())) | 223 if (AttemptToLoad(isolate, pending.Pass())) |
224 keep_trying = true; | 224 keep_trying = true; |
225 } | 225 } |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 } // namespace gin | 229 } // namespace gin |
OLD | NEW |