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

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

Issue 179803007: Refactors parts of gin: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gin_shell Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « gin/gin.gyp ('k') | gin/modules/module_runner_delegate.h » ('j') | 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 <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
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
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
OLDNEW
« no previous file with comments | « gin/gin.gyp ('k') | gin/modules/module_runner_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698