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

Unified Diff: gin/modules/module_registry.cc

Issue 1161053002: Revert of gin: Use V8 Maybe APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maybe-gin-converter
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/modules/module_registry.h ('k') | gin/object_template_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/modules/module_registry.cc
diff --git a/gin/modules/module_registry.cc b/gin/modules/module_registry.cc
index 036e98df6bcefb18858b4d9f1379b2ea1887a024..6c3e898cc29e07fa82ecab51d3ecf359755d32aa 100644
--- a/gin/modules/module_registry.cc
+++ b/gin/modules/module_registry.cc
@@ -113,14 +113,10 @@
}
// static
-bool ModuleRegistry::InstallGlobals(v8::Isolate* isolate,
+void ModuleRegistry::InstallGlobals(v8::Isolate* isolate,
v8::Local<v8::Object> obj) {
- v8::Local<v8::Function> function;
- auto maybe_function =
- GetDefineTemplate(isolate)->GetFunction(isolate->GetCurrentContext());
- if (!maybe_function.ToLocal(&function))
- return false;
- return SetProperty(isolate, obj, StringToSymbol(isolate, "define"), function);
+ obj->Set(StringToSymbol(isolate, "define"),
+ GetDefineTemplate(isolate)->GetFunction());
}
// static
@@ -181,17 +177,16 @@
unsatisfied_dependencies_.insert(id);
}
-bool ModuleRegistry::RegisterModule(Isolate* isolate,
+void ModuleRegistry::RegisterModule(Isolate* isolate,
const std::string& id,
v8::Local<Value> module) {
if (id.empty() || module.IsEmpty())
- return false;
-
- v8::Local<Object> modules = Local<Object>::New(isolate, modules_);
- if (!SetProperty(isolate, modules, StringToSymbol(isolate, id), module))
- return false;
+ return;
+
unsatisfied_dependencies_.erase(id);
available_modules_.insert(id);
+ v8::Local<Object> modules = Local<Object>::New(isolate, modules_);
+ modules->Set(StringToSymbol(isolate, id), module);
std::pair<LoadModuleCallbackMap::iterator, LoadModuleCallbackMap::iterator>
range = waiting_callbacks_.equal_range(id);
@@ -208,7 +203,6 @@
// Should we call the callback asynchronously?
it->Run(module);
}
- return true;
}
bool ModuleRegistry::CheckDependencies(PendingModule* pending) {
@@ -224,9 +218,9 @@
return num_missing_dependencies == 0;
}
-bool ModuleRegistry::Load(Isolate* isolate, scoped_ptr<PendingModule> pending) {
+void ModuleRegistry::Load(Isolate* isolate, scoped_ptr<PendingModule> pending) {
if (!pending->id.empty() && available_modules_.count(pending->id))
- return true; // We've already loaded this module.
+ return; // We've already loaded this module.
uint32_t argc = static_cast<uint32_t>(pending->dependencies.size());
std::vector<v8::Local<Value> > argv(argc);
@@ -246,7 +240,7 @@
&pending->id);
}
- return RegisterModule(isolate, pending->id, module);
+ RegisterModule(isolate, pending->id, module);
}
bool ModuleRegistry::AttemptToLoad(Isolate* isolate,
@@ -255,15 +249,16 @@
pending_modules_.push_back(pending.release());
return false;
}
- return Load(isolate, pending.Pass());
+ Load(isolate, pending.Pass());
+ return true;
}
v8::Local<v8::Value> ModuleRegistry::GetModule(v8::Isolate* isolate,
const std::string& id) {
v8::Local<Object> modules = Local<Object>::New(isolate, modules_);
v8::Local<String> key = StringToSymbol(isolate, id);
- DCHECK(modules->HasOwnProperty(isolate->GetCurrentContext(), key).FromJust());
- return modules->Get(isolate->GetCurrentContext(), key).ToLocalChecked();
+ DCHECK(modules->HasOwnProperty(key));
+ return modules->Get(key);
}
void ModuleRegistry::AttemptToLoadMoreModules(Isolate* isolate) {
« no previous file with comments | « gin/modules/module_registry.h ('k') | gin/object_template_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698