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 <assert.h> | 7 #include <assert.h> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include "gin/arguments.h" | 10 #include "gin/arguments.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 ModuleRegistry* ModuleRegistry::From(Handle<v8::Context> context) { | 112 ModuleRegistry* ModuleRegistry::From(Handle<v8::Context> context) { |
113 v8::Isolate* isolate = context->GetIsolate(); | 113 v8::Isolate* isolate = context->GetIsolate(); |
114 Handle<v8::String> key = GetHiddenValueKey(isolate); | 114 Handle<v8::String> key = GetHiddenValueKey(isolate); |
115 Handle<v8::Value> value = context->Global()->GetHiddenValue(key); | 115 Handle<v8::Value> value = context->Global()->GetHiddenValue(key); |
116 Handle<v8::External> external; | 116 Handle<v8::External> external; |
117 if (value.IsEmpty() || !ConvertFromV8(value, &external)) { | 117 if (value.IsEmpty() || !ConvertFromV8(value, &external)) { |
118 PerContextData* data = PerContextData::From(context); | 118 PerContextData* data = PerContextData::From(context); |
119 if (!data) | 119 if (!data) |
120 return NULL; | 120 return NULL; |
121 ModuleRegistry* registry = new ModuleRegistry(isolate); | 121 ModuleRegistry* registry = new ModuleRegistry(isolate); |
122 context->Global()->SetHiddenValue(key, v8::External::New(registry)); | 122 context->Global()->SetHiddenValue(key, |
| 123 v8::External::New(isolate, registry)); |
123 data->AddSupplement(registry); | 124 data->AddSupplement(registry); |
124 return registry; | 125 return registry; |
125 } | 126 } |
126 return static_cast<ModuleRegistry*>(external->Value()); | 127 return static_cast<ModuleRegistry*>(external->Value()); |
127 } | 128 } |
128 | 129 |
129 void ModuleRegistry::AddPendingModule(v8::Isolate* isolate, | 130 void ModuleRegistry::AddPendingModule(v8::Isolate* isolate, |
130 PendingModule* pending) { | 131 PendingModule* pending) { |
131 if (AttemptToLoad(isolate, pending)) | 132 if (AttemptToLoad(isolate, pending)) |
132 AttemptToLoadPendingModules(isolate); | 133 AttemptToLoadPendingModules(isolate); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void ModuleRegistry::AttemptToLoadPendingModules(v8::Isolate* isolate) { | 180 void ModuleRegistry::AttemptToLoadPendingModules(v8::Isolate* isolate) { |
180 PendingModuleList pending_modules; | 181 PendingModuleList pending_modules; |
181 pending_modules.swap(pending_modules_); | 182 pending_modules.swap(pending_modules_); |
182 for (PendingModuleList::iterator it = pending_modules.begin(); | 183 for (PendingModuleList::iterator it = pending_modules.begin(); |
183 it != pending_modules.end(); ++it) { | 184 it != pending_modules.end(); ++it) { |
184 AttemptToLoad(isolate, *it); | 185 AttemptToLoad(isolate, *it); |
185 } | 186 } |
186 } | 187 } |
187 | 188 |
188 } // namespace gin | 189 } // namespace gin |
OLD | NEW |