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

Side by Side Diff: chrome/renderer/module_system.cc

Issue 10890021: Revert 153778 - Merge 153283 - Make ModuleSystem::DumpException() handle empty handles. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/module_system.h" 5 #include "chrome/renderer/module_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup pression.h" 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup pression.h"
9 9
10 namespace { 10 namespace {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 // static 54 // static
55 bool ModuleSystem::IsPresentInCurrentContext() { 55 bool ModuleSystem::IsPresentInCurrentContext() {
56 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global()); 56 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global());
57 return !global->GetHiddenValue(v8::String::New(kModuleSystem))->IsUndefined(); 57 return !global->GetHiddenValue(v8::String::New(kModuleSystem))->IsUndefined();
58 } 58 }
59 59
60 // static 60 // static
61 void ModuleSystem::DumpException(v8::Handle<v8::Message> message) { 61 void ModuleSystem::DumpException(v8::Handle<v8::Message> message) {
62 std::string resource_name = "<unknown resource>"; 62 LOG(ERROR) << "["
63 if (!message->GetScriptResourceName().IsEmpty()) { 63 << *v8::String::Utf8Value(
64 resource_name = *v8::String::Utf8Value( 64 message->GetScriptResourceName()->ToString())
65 message->GetScriptResourceName()->ToString()); 65 << "(" << message->GetLineNumber() << ")] "
66 } 66 << *v8::String::Utf8Value(message->Get());
67
68 std::string error_message = "<no error message>";
69 if (!message->Get().IsEmpty())
70 error_message = *v8::String::Utf8Value(message->Get());
71
72 std::string stack_trace = "<stack trace unavailable>";
73 if (!try_catch.StackTrace().IsEmpty())
74 stack_trace = *v8::String::Utf8Value(try_catch.StackTrace());
75
76 LOG(ERROR) << "[" << resource_name << "(" << message->GetLineNumber() << ")] "
77 << error_message
78 << "{" << stack_trace << "}";
79 } 67 }
80 68
81 void ModuleSystem::Require(const std::string& module_name) { 69 void ModuleSystem::Require(const std::string& module_name) {
82 v8::HandleScope handle_scope; 70 v8::HandleScope handle_scope;
83 RequireForJsInner(v8::String::New(module_name.c_str())); 71 RequireForJsInner(v8::String::New(module_name.c_str()));
84 } 72 }
85 73
86 v8::Handle<v8::Value> ModuleSystem::RequireForJs(const v8::Arguments& args) { 74 v8::Handle<v8::Value> ModuleSystem::RequireForJs(const v8::Arguments& args) {
87 v8::HandleScope handle_scope; 75 v8::HandleScope handle_scope;
88 v8::Handle<v8::String> module_name = args[0]->ToString(); 76 v8::Handle<v8::String> module_name = args[0]->ToString();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 v8::Handle<v8::String> left = 223 v8::Handle<v8::String> left =
236 v8::String::New("(function(require, requireNative, exports) {"); 224 v8::String::New("(function(require, requireNative, exports) {");
237 v8::Handle<v8::String> right = v8::String::New("\n})"); 225 v8::Handle<v8::String> right = v8::String::New("\n})");
238 return handle_scope.Close( 226 return handle_scope.Close(
239 v8::String::Concat(left, v8::String::Concat(source, right))); 227 v8::String::Concat(left, v8::String::Concat(source, right)));
240 } 228 }
241 229
242 v8::Handle<v8::Value> ModuleSystem::ThrowException(const std::string& message) { 230 v8::Handle<v8::Value> ModuleSystem::ThrowException(const std::string& message) {
243 return v8::ThrowException(v8::String::New(message.c_str())); 231 return v8::ThrowException(v8::String::New(message.c_str()));
244 } 232 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698