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

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

Issue 757703002: Creates a JavaScript Applicaiton (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Do not try to call undefined Application methods. Created 6 years 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
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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 void ModuleRegistry::LoadModule(Isolate* isolate, 162 void ModuleRegistry::LoadModule(Isolate* isolate,
163 const std::string& id, 163 const std::string& id,
164 LoadModuleCallback callback) { 164 LoadModuleCallback callback) {
165 if (available_modules_.find(id) != available_modules_.end()) { 165 if (available_modules_.find(id) != available_modules_.end()) {
166 // Should we call the callback asynchronously? 166 // Should we call the callback asynchronously?
167 callback.Run(GetModule(isolate, id)); 167 callback.Run(GetModule(isolate, id));
168 return; 168 return;
169 } 169 }
170 waiting_callbacks_.insert(std::make_pair(id, callback)); 170 waiting_callbacks_.insert(std::make_pair(id, callback));
171
172 for (size_t i = 0; i < pending_modules_.size(); ++i) {
173 if (pending_modules_[i]->id == id)
174 return;
175 }
abarth-chromium 2014/11/24 23:47:24 I think we copy gin from Chromium. We probably ne
hansmuller 2014/11/25 00:31:54 I'll coordinate with the person who's rolling Mojo
176
171 unsatisfied_dependencies_.insert(id); 177 unsatisfied_dependencies_.insert(id);
172 } 178 }
173 179
174 void ModuleRegistry::RegisterModule(Isolate* isolate, 180 void ModuleRegistry::RegisterModule(Isolate* isolate,
175 const std::string& id, 181 const std::string& id,
176 v8::Handle<Value> module) { 182 v8::Handle<Value> module) {
177 if (id.empty() || module.IsEmpty()) 183 if (id.empty() || module.IsEmpty())
178 return; 184 return;
179 185
180 unsatisfied_dependencies_.erase(id); 186 unsatisfied_dependencies_.erase(id);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 for (size_t i = 0; i < pending_modules.size(); ++i) { 270 for (size_t i = 0; i < pending_modules.size(); ++i) {
265 scoped_ptr<PendingModule> pending(pending_modules[i]); 271 scoped_ptr<PendingModule> pending(pending_modules[i]);
266 pending_modules[i] = NULL; 272 pending_modules[i] = NULL;
267 if (AttemptToLoad(isolate, pending.Pass())) 273 if (AttemptToLoad(isolate, pending.Pass()))
268 keep_trying = true; 274 keep_trying = true;
269 } 275 }
270 } 276 }
271 } 277 }
272 278
273 } // namespace gin 279 } // namespace gin
OLDNEW
« no previous file with comments | « examples/js/world.js ('k') | services/js/BUILD.gn » ('j') | services/js/js_app.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698