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

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

Issue 2965273002: Remove ScopedVector from gin/. (Closed)
Patch Set: Created 3 years, 5 months 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
« no previous file with comments | « gin/modules/module_registry.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "gin/modules/module_registry.h" 5 #include "gin/modules/module_registry.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 ConvertFromV8(isolate, factory->GetScriptOrigin().ResourceName(), 251 ConvertFromV8(isolate, factory->GetScriptOrigin().ResourceName(),
252 &pending->id); 252 &pending->id);
253 } 253 }
254 254
255 return RegisterModule(isolate, pending->id, module); 255 return RegisterModule(isolate, pending->id, module);
256 } 256 }
257 257
258 bool ModuleRegistry::AttemptToLoad(Isolate* isolate, 258 bool ModuleRegistry::AttemptToLoad(Isolate* isolate,
259 std::unique_ptr<PendingModule> pending) { 259 std::unique_ptr<PendingModule> pending) {
260 if (!CheckDependencies(pending.get())) { 260 if (!CheckDependencies(pending.get())) {
261 pending_modules_.push_back(pending.release()); 261 pending_modules_.push_back(std::move(pending));
262 return false; 262 return false;
263 } 263 }
264 return Load(isolate, std::move(pending)); 264 return Load(isolate, std::move(pending));
265 } 265 }
266 266
267 v8::Local<v8::Value> ModuleRegistry::GetModule(v8::Isolate* isolate, 267 v8::Local<v8::Value> ModuleRegistry::GetModule(v8::Isolate* isolate,
268 const std::string& id) { 268 const std::string& id) {
269 v8::Local<Object> modules = Local<Object>::New(isolate, modules_); 269 v8::Local<Object> modules = Local<Object>::New(isolate, modules_);
270 v8::Local<String> key = StringToSymbol(isolate, id); 270 v8::Local<String> key = StringToSymbol(isolate, id);
271 DCHECK(modules->HasOwnProperty(isolate->GetCurrentContext(), key).FromJust()); 271 DCHECK(modules->HasOwnProperty(isolate->GetCurrentContext(), key).FromJust());
272 return modules->Get(isolate->GetCurrentContext(), key).ToLocalChecked(); 272 return modules->Get(isolate->GetCurrentContext(), key).ToLocalChecked();
273 } 273 }
274 274
275 void ModuleRegistry::AttemptToLoadMoreModules(Isolate* isolate) { 275 void ModuleRegistry::AttemptToLoadMoreModules(Isolate* isolate) {
276 bool keep_trying = true; 276 bool keep_trying = true;
277 while (keep_trying) { 277 while (keep_trying) {
278 keep_trying = false; 278 keep_trying = false;
279 PendingModuleVector pending_modules; 279 PendingModuleVector pending_modules;
280 pending_modules.swap(pending_modules_); 280 pending_modules.swap(pending_modules_);
281 for (size_t i = 0; i < pending_modules.size(); ++i) { 281 for (size_t i = 0; i < pending_modules.size(); ++i) {
282 std::unique_ptr<PendingModule> pending(pending_modules[i]); 282 std::unique_ptr<PendingModule> pending(std::move(pending_modules[i]));
283 pending_modules[i] = NULL; 283 pending_modules[i] = NULL;
284 if (AttemptToLoad(isolate, std::move(pending))) 284 if (AttemptToLoad(isolate, std::move(pending)))
285 keep_trying = true; 285 keep_trying = true;
286 } 286 }
287 } 287 }
288 } 288 }
289 289
290 } // namespace gin 290 } // namespace gin
OLDNEW
« no previous file with comments | « gin/modules/module_registry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698