| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/module_system.h" | 5 #include "extensions/renderer/module_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 module_name, | 302 module_name, |
| 303 "method_name", | 303 "method_name", |
| 304 method_name); | 304 method_name); |
| 305 | 305 |
| 306 v8::EscapableHandleScope handle_scope(GetIsolate()); | 306 v8::EscapableHandleScope handle_scope(GetIsolate()); |
| 307 v8::Local<v8::Context> v8_context = context()->v8_context(); | 307 v8::Local<v8::Context> v8_context = context()->v8_context(); |
| 308 v8::Context::Scope context_scope(v8_context); | 308 v8::Context::Scope context_scope(v8_context); |
| 309 | 309 |
| 310 v8::Local<v8::Function> function = | 310 v8::Local<v8::Function> function = |
| 311 GetModuleFunction(module_name, method_name); | 311 GetModuleFunction(module_name, method_name); |
| 312 if (function.IsEmpty()) { |
| 313 NOTREACHED() << "GetModuleFunction() returns empty function handle"; |
| 314 return handle_scope.Escape(v8::Undefined(GetIsolate())); |
| 315 } |
| 312 | 316 |
| 313 v8::Local<v8::Value> result; | 317 v8::Local<v8::Value> result; |
| 314 { | 318 { |
| 315 v8::TryCatch try_catch(GetIsolate()); | 319 v8::TryCatch try_catch(GetIsolate()); |
| 316 try_catch.SetCaptureMessage(true); | 320 try_catch.SetCaptureMessage(true); |
| 317 result = context_->CallFunction(function, argc, argv); | 321 result = context_->CallFunction(function, argc, argv); |
| 318 if (try_catch.HasCaught()) { | 322 if (try_catch.HasCaught()) { |
| 319 HandleException(try_catch); | 323 HandleException(try_catch); |
| 320 result = v8::Undefined(GetIsolate()); | 324 result = v8::Undefined(GetIsolate()); |
| 321 } | 325 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 343 v8::Local<v8::Value> argv[]) { | 347 v8::Local<v8::Value> argv[]) { |
| 344 TRACE_EVENT2("v8", "v8.callModuleMethodSafe", "module_name", module_name, | 348 TRACE_EVENT2("v8", "v8.callModuleMethodSafe", "module_name", module_name, |
| 345 "method_name", method_name); | 349 "method_name", method_name); |
| 346 | 350 |
| 347 v8::HandleScope handle_scope(GetIsolate()); | 351 v8::HandleScope handle_scope(GetIsolate()); |
| 348 v8::Local<v8::Context> v8_context = context()->v8_context(); | 352 v8::Local<v8::Context> v8_context = context()->v8_context(); |
| 349 v8::Context::Scope context_scope(v8_context); | 353 v8::Context::Scope context_scope(v8_context); |
| 350 | 354 |
| 351 v8::Local<v8::Function> function = | 355 v8::Local<v8::Function> function = |
| 352 GetModuleFunction(module_name, method_name); | 356 GetModuleFunction(module_name, method_name); |
| 357 if (function.IsEmpty()) { |
| 358 NOTREACHED() << "GetModuleFunction() returns empty function handle"; |
| 359 return; |
| 360 } |
| 353 | 361 |
| 354 { | 362 { |
| 355 v8::TryCatch try_catch(GetIsolate()); | 363 v8::TryCatch try_catch(GetIsolate()); |
| 356 try_catch.SetCaptureMessage(true); | 364 try_catch.SetCaptureMessage(true); |
| 357 context_->SafeCallFunction(function, argc, argv); | 365 context_->SafeCallFunction(function, argc, argv); |
| 358 if (try_catch.HasCaught()) | 366 if (try_catch.HasCaught()) |
| 359 HandleException(try_catch); | 367 HandleException(try_catch); |
| 360 } | 368 } |
| 361 } | 369 } |
| 362 | 370 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 !value->IsFunction()) { | 823 !value->IsFunction()) { |
| 816 Fatal(context_, module_name + "." + method_name + " is not a function"); | 824 Fatal(context_, module_name + "." + method_name + " is not a function"); |
| 817 return function; | 825 return function; |
| 818 } | 826 } |
| 819 | 827 |
| 820 function = v8::Local<v8::Function>::Cast(value); | 828 function = v8::Local<v8::Function>::Cast(value); |
| 821 return function; | 829 return function; |
| 822 } | 830 } |
| 823 | 831 |
| 824 } // namespace extensions | 832 } // namespace extensions |
| OLD | NEW |