| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 APIFunctions.prototype.setHandleRequestWithPromise = | 67 APIFunctions.prototype.setHandleRequestWithPromise = |
| 68 function(apiName, customizedFunction) { | 68 function(apiName, customizedFunction) { |
| 69 var prefix = this.namespace; | 69 var prefix = this.namespace; |
| 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) { |
| 77 return module.createKeepAlive(); |
| 78 }); |
| 76 $Function.apply(customizedFunction, this, args).then(function(result) { | 79 $Function.apply(customizedFunction, this, args).then(function(result) { |
| 77 sendRequestHandler.safeCallbackApply( | 80 sendRequestHandler.safeCallbackApply( |
| 78 name, {'stack': stack}, callback, [result]); | 81 name, {'stack': stack}, callback, [result]); |
| 79 }).catch(function(error) { | 82 }).catch(function(error) { |
| 80 var message = exceptionHandler.safeErrorToString(error, true); | 83 var message = exceptionHandler.safeErrorToString(error, true); |
| 81 lastError.run(name, message, stack, callback); | 84 lastError.run(name, message, stack, callback); |
| 85 }).then(function() { |
| 86 keepAlivePromise.then(function(keepAlive) { |
| 87 keepAlive.close(); |
| 88 }); |
| 82 }); | 89 }); |
| 83 }); | 90 }); |
| 84 }; | 91 }; |
| 85 | 92 |
| 86 APIFunctions.prototype.setUpdateArgumentsPostValidate = | 93 APIFunctions.prototype.setUpdateArgumentsPostValidate = |
| 87 function(apiName, customizedFunction) { | 94 function(apiName, customizedFunction) { |
| 88 return this.setHook_( | 95 return this.setHook_( |
| 89 apiName, 'updateArgumentsPostValidate', customizedFunction); | 96 apiName, 'updateArgumentsPostValidate', customizedFunction); |
| 90 }; | 97 }; |
| 91 | 98 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 availability.message); | 479 availability.message); |
| 473 return; | 480 return; |
| 474 } | 481 } |
| 475 | 482 |
| 476 this.runHooks_(mod); | 483 this.runHooks_(mod); |
| 477 return mod; | 484 return mod; |
| 478 } | 485 } |
| 479 }; | 486 }; |
| 480 | 487 |
| 481 exports.Binding = Binding; | 488 exports.Binding = Binding; |
| OLD | NEW |