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

Unified Diff: gin/modules/module_registry.cc

Issue 83143002: [Mojo] Improve JavaScript API for MojoReadMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup Created 7 years, 1 month 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/converter.cc ('k') | mojo/public/bindings/js/DEPS » ('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 8baa4823cac250fc983ef1f499a0c103c8bcf43d..afb07d389e009daefc859e025b25040d7d74f5c5 100644
--- a/gin/modules/module_registry.cc
+++ b/gin/modules/module_registry.cc
@@ -12,6 +12,7 @@
#include "gin/converter.h"
#include "gin/per_isolate_data.h"
#include "gin/public/wrapper_info.h"
+#include "gin/try_catch.h"
using v8::Context;
using v8::External;
@@ -91,19 +92,6 @@ Handle<String> GetHiddenValueKey(Isolate* isolate) {
return StringToSymbol(isolate, "::gin::ModuleRegistry");
}
-std::string GetImplicitModuleName(const std::string& explicit_name) {
- if (!explicit_name.empty())
- return explicit_name;
- std::string implicit_name;
- Handle<StackTrace> trace = StackTrace::CurrentStackTrace(1);
- if (!trace->GetFrameCount())
- return implicit_name;
- Handle<String> script_name = trace->GetFrame(0)->GetScriptName();
- if (!script_name.IsEmpty())
- ConvertFromV8(script_name, &implicit_name);
- return implicit_name;
-}
-
} // namespace
ModuleRegistry::ModuleRegistry(Isolate* isolate)
@@ -196,11 +184,17 @@ void ModuleRegistry::Load(Isolate* isolate, scoped_ptr<PendingModule> pending) {
Handle<Function> factory;
if (ConvertFromV8(module, &factory)) {
Handle<Object> global = isolate->GetCurrentContext()->Global();
- module = factory->Call(global, argc, argv.data());
- // TODO(abarth): What should we do with exceptions?
+ {
+ gin::TryCatch try_catch;
+ module = factory->Call(global, argc, argv.data());
+ if (try_catch.HasCaught())
+ return; // TODO(abarth): What should we do with the exception?
+ }
+ if (pending->id.empty())
+ ConvertFromV8(factory->GetScriptOrigin().ResourceName(), &pending->id);
}
- RegisterModule(isolate, GetImplicitModuleName(pending->id), module);
+ RegisterModule(isolate, pending->id, module);
}
bool ModuleRegistry::AttemptToLoad(Isolate* isolate,
« no previous file with comments | « gin/converter.cc ('k') | mojo/public/bindings/js/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698