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

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

Issue 120043008: Add a simple one shot and repeating timer API for Mojo.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 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 | 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 #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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698