| 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 exceptionHandler = require('uncaught_exception_handler'); | 5 var exceptionHandler = require('uncaught_exception_handler'); |
| 6 var lastError = require('lastError'); | 6 var lastError = require('lastError'); |
| 7 var logging = requireNative('logging'); | 7 var logging = requireNative('logging'); |
| 8 var natives = requireNative('sendRequest'); | 8 var natives = requireNative('sendRequest'); |
| 9 var validate = require('schemaUtils').validate; | 9 var validate = require('schemaUtils').validate; |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 request, | 58 request, |
| 59 request.customCallback, | 59 request.customCallback, |
| 60 $Array.concat([name, request], responseList)); | 60 $Array.concat([name, request], responseList)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 if (request.callback) { | 63 if (request.callback) { |
| 64 // Validate callback in debug only -- and only when the | 64 // Validate callback in debug only -- and only when the |
| 65 // caller has provided a callback. Implementations of api | 65 // caller has provided a callback. Implementations of api |
| 66 // calls may not return data if they observe the caller | 66 // calls may not return data if they observe the caller |
| 67 // has not provided a callback. | 67 // has not provided a callback. |
| 68 if (logging.DCHECK_IS_ON() && !error) { | 68 if (!logging.DCHECK_IS_OFF() && !error) { |
| 69 if (!request.callbackSchema.parameters) | 69 if (!request.callbackSchema.parameters) |
| 70 throw new Error(name + ": no callback schema defined"); | 70 throw new Error(name + ": no callback schema defined"); |
| 71 validate(responseList, request.callbackSchema.parameters); | 71 validate(responseList, request.callbackSchema.parameters); |
| 72 } | 72 } |
| 73 safeCallbackApply(name, request, request.callback, responseList); | 73 safeCallbackApply(name, request, request.callback, responseList); |
| 74 } | 74 } |
| 75 | 75 |
| 76 if (error && | 76 if (error && |
| 77 !lastError.hasAccessed(chrome) && | 77 !lastError.hasAccessed(chrome) && |
| 78 !lastError.hasAccessed(callerChrome)) { | 78 !lastError.hasAccessed(callerChrome)) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 calledSendRequest = false; | 153 calledSendRequest = false; |
| 154 } | 154 } |
| 155 | 155 |
| 156 exports.sendRequest = sendRequest; | 156 exports.sendRequest = sendRequest; |
| 157 exports.getCalledSendRequest = getCalledSendRequest; | 157 exports.getCalledSendRequest = getCalledSendRequest; |
| 158 exports.clearCalledSendRequest = clearCalledSendRequest; | 158 exports.clearCalledSendRequest = clearCalledSendRequest; |
| 159 exports.safeCallbackApply = safeCallbackApply; | 159 exports.safeCallbackApply = safeCallbackApply; |
| 160 | 160 |
| 161 // Called by C++. | 161 // Called by C++. |
| 162 exports.handleResponse = handleResponse; | 162 exports.handleResponse = handleResponse; |
| OLD | NEW |