| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } // namespace | 94 } // namespace |
| 95 | 95 |
| 96 ModuleRegistry::ModuleRegistry(Isolate* isolate) | 96 ModuleRegistry::ModuleRegistry(Isolate* isolate) |
| 97 : modules_(isolate, Object::New(isolate)) { | 97 : modules_(isolate, Object::New(isolate)) { |
| 98 } | 98 } |
| 99 | 99 |
| 100 ModuleRegistry::~ModuleRegistry() { | 100 ModuleRegistry::~ModuleRegistry() { |
| 101 modules_.Reset(); | 101 modules_.Reset(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // static |
| 104 void ModuleRegistry::RegisterGlobals(Isolate* isolate, | 105 void ModuleRegistry::RegisterGlobals(Isolate* isolate, |
| 105 v8::Handle<ObjectTemplate> templ) { | 106 v8::Handle<ObjectTemplate> templ) { |
| 106 templ->Set(StringToSymbol(isolate, "define"), GetDefineTemplate(isolate)); | 107 templ->Set(StringToSymbol(isolate, "define"), GetDefineTemplate(isolate)); |
| 107 } | 108 } |
| 108 | 109 |
| 110 // static |
| 109 ModuleRegistry* ModuleRegistry::From(v8::Handle<Context> context) { | 111 ModuleRegistry* ModuleRegistry::From(v8::Handle<Context> context) { |
| 110 Isolate* isolate = context->GetIsolate(); | 112 Isolate* isolate = context->GetIsolate(); |
| 111 v8::Handle<String> key = GetHiddenValueKey(isolate); | 113 v8::Handle<String> key = GetHiddenValueKey(isolate); |
| 112 v8::Handle<Value> value = context->Global()->GetHiddenValue(key); | 114 v8::Handle<Value> value = context->Global()->GetHiddenValue(key); |
| 113 v8::Handle<External> external; | 115 v8::Handle<External> external; |
| 114 if (value.IsEmpty() || !ConvertFromV8(isolate, value, &external)) { | 116 if (value.IsEmpty() || !ConvertFromV8(isolate, value, &external)) { |
| 115 PerContextData* data = PerContextData::From(context); | 117 PerContextData* data = PerContextData::From(context); |
| 116 if (!data) | 118 if (!data) |
| 117 return NULL; | 119 return NULL; |
| 118 ModuleRegistry* registry = new ModuleRegistry(isolate); | 120 ModuleRegistry* registry = new ModuleRegistry(isolate); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 for (size_t i = 0; i < pending_modules.size(); ++i) { | 240 for (size_t i = 0; i < pending_modules.size(); ++i) { |
| 239 scoped_ptr<PendingModule> pending(pending_modules[i]); | 241 scoped_ptr<PendingModule> pending(pending_modules[i]); |
| 240 pending_modules[i] = NULL; | 242 pending_modules[i] = NULL; |
| 241 if (AttemptToLoad(isolate, pending.Pass())) | 243 if (AttemptToLoad(isolate, pending.Pass())) |
| 242 keep_trying = true; | 244 keep_trying = true; |
| 243 } | 245 } |
| 244 } | 246 } |
| 245 } | 247 } |
| 246 | 248 |
| 247 } // namespace gin | 249 } // namespace gin |
| OLD | NEW |