| 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 var Event = require('event_bindings').Event; | 5 var Event = require('event_bindings').Event; |
| 6 var forEach = require('utils').forEach; | 6 var forEach = require('utils').forEach; |
| 7 var GetAvailability = requireNative('v8_context').GetAvailability; | 7 var GetAvailability = requireNative('v8_context').GetAvailability; |
| 8 var exceptionHandler = require('uncaught_exception_handler'); | 8 var exceptionHandler = require('uncaught_exception_handler'); |
| 9 var lastError = require('lastError'); | 9 var lastError = require('lastError'); |
| 10 var logActivity = requireNative('activityLogger'); | 10 var logActivity = requireNative('activityLogger'); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return this.setHook_(apiName, 'handleRequest', function() { | 70 return this.setHook_(apiName, 'handleRequest', function() { |
| 71 var name = prefix + '.' + apiName; | 71 var name = prefix + '.' + apiName; |
| 72 logActivity.LogAPICall(extensionId, name, $Array.slice(arguments)); | 72 logActivity.LogAPICall(extensionId, name, $Array.slice(arguments)); |
| 73 var stack = exceptionHandler.getExtensionStackTrace(); | 73 var stack = exceptionHandler.getExtensionStackTrace(); |
| 74 var callback = arguments[arguments.length - 1]; | 74 var callback = arguments[arguments.length - 1]; |
| 75 var args = $Array.slice(arguments, 0, arguments.length - 1); | 75 var args = $Array.slice(arguments, 0, arguments.length - 1); |
| 76 var keepAlivePromise = requireAsync('keep_alive').then(function(module) { | 76 var keepAlivePromise = requireAsync('keep_alive').then(function(module) { |
| 77 return module.createKeepAlive(); | 77 return module.createKeepAlive(); |
| 78 }); | 78 }); |
| 79 $Function.apply(customizedFunction, this, args).then(function(result) { | 79 $Function.apply(customizedFunction, this, args).then(function(result) { |
| 80 sendRequestHandler.safeCallbackApply( | 80 if (callback) { |
| 81 name, {'stack': stack}, callback, [result]); | 81 sendRequestHandler.safeCallbackApply(name, {'stack': stack}, callback, |
| 82 [result]); |
| 83 } |
| 82 }).catch(function(error) { | 84 }).catch(function(error) { |
| 83 var message = exceptionHandler.safeErrorToString(error, true); | 85 if (callback) { |
| 84 lastError.run(name, message, stack, callback); | 86 var message = exceptionHandler.safeErrorToString(error, true); |
| 87 lastError.run(name, message, stack, callback); |
| 88 } |
| 85 }).then(function() { | 89 }).then(function() { |
| 86 keepAlivePromise.then(function(keepAlive) { | 90 keepAlivePromise.then(function(keepAlive) { |
| 87 keepAlive.close(); | 91 keepAlive.close(); |
| 88 }); | 92 }); |
| 89 }); | 93 }); |
| 90 }); | 94 }); |
| 91 }; | 95 }; |
| 92 | 96 |
| 93 APIFunctions.prototype.setUpdateArgumentsPostValidate = | 97 APIFunctions.prototype.setUpdateArgumentsPostValidate = |
| 94 function(apiName, customizedFunction) { | 98 function(apiName, customizedFunction) { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 availability.message); | 483 availability.message); |
| 480 return; | 484 return; |
| 481 } | 485 } |
| 482 | 486 |
| 483 this.runHooks_(mod); | 487 this.runHooks_(mod); |
| 484 return mod; | 488 return mod; |
| 485 } | 489 } |
| 486 }; | 490 }; |
| 487 | 491 |
| 488 exports.Binding = Binding; | 492 exports.Binding = Binding; |
| OLD | NEW |