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

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

Issue 2546853002: [extensions] added checks that function is not empty (Closed)
Patch Set: Created 4 years 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
« 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 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
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()) {
Devlin 2016/12/01 22:09:47 This *shouldn't* ever happen, but I wouldn't be en
kozy 2016/12/01 22:19:25 Done.
313 return handle_scope.Escape(v8::Undefined(GetIsolate()));
314 }
312 315
313 v8::Local<v8::Value> result; 316 v8::Local<v8::Value> result;
314 { 317 {
315 v8::TryCatch try_catch(GetIsolate()); 318 v8::TryCatch try_catch(GetIsolate());
316 try_catch.SetCaptureMessage(true); 319 try_catch.SetCaptureMessage(true);
317 result = context_->CallFunction(function, argc, argv); 320 result = context_->CallFunction(function, argc, argv);
318 if (try_catch.HasCaught()) { 321 if (try_catch.HasCaught()) {
319 HandleException(try_catch); 322 HandleException(try_catch);
320 result = v8::Undefined(GetIsolate()); 323 result = v8::Undefined(GetIsolate());
321 } 324 }
(...skipping 21 matching lines...) Expand all
343 v8::Local<v8::Value> argv[]) { 346 v8::Local<v8::Value> argv[]) {
344 TRACE_EVENT2("v8", "v8.callModuleMethodSafe", "module_name", module_name, 347 TRACE_EVENT2("v8", "v8.callModuleMethodSafe", "module_name", module_name,
345 "method_name", method_name); 348 "method_name", method_name);
346 349
347 v8::HandleScope handle_scope(GetIsolate()); 350 v8::HandleScope handle_scope(GetIsolate());
348 v8::Local<v8::Context> v8_context = context()->v8_context(); 351 v8::Local<v8::Context> v8_context = context()->v8_context();
349 v8::Context::Scope context_scope(v8_context); 352 v8::Context::Scope context_scope(v8_context);
350 353
351 v8::Local<v8::Function> function = 354 v8::Local<v8::Function> function =
352 GetModuleFunction(module_name, method_name); 355 GetModuleFunction(module_name, method_name);
356 if (function.IsEmpty()) {
357 return;
358 }
353 359
354 { 360 {
355 v8::TryCatch try_catch(GetIsolate()); 361 v8::TryCatch try_catch(GetIsolate());
356 try_catch.SetCaptureMessage(true); 362 try_catch.SetCaptureMessage(true);
357 context_->SafeCallFunction(function, argc, argv); 363 context_->SafeCallFunction(function, argc, argv);
358 if (try_catch.HasCaught()) 364 if (try_catch.HasCaught())
359 HandleException(try_catch); 365 HandleException(try_catch);
360 } 366 }
361 } 367 }
362 368
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 !value->IsFunction()) { 821 !value->IsFunction()) {
816 Fatal(context_, module_name + "." + method_name + " is not a function"); 822 Fatal(context_, module_name + "." + method_name + " is not a function");
817 return function; 823 return function;
818 } 824 }
819 825
820 function = v8::Local<v8::Function>::Cast(value); 826 function = v8::Local<v8::Function>::Cast(value);
821 return function; 827 return function;
822 } 828 }
823 829
824 } // namespace extensions 830 } // namespace extensions
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