| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 if (!GetAvailability(apiFunction.name).is_available || | 311 if (!GetAvailability(apiFunction.name).is_available || |
| 312 (checkUnprivileged && !isSchemaAccessAllowed(functionDef))) { | 312 (checkUnprivileged && !isSchemaAccessAllowed(functionDef))) { |
| 313 this.apiFunctions_.registerUnavailable(functionDef.name); | 313 this.apiFunctions_.registerUnavailable(functionDef.name); |
| 314 return; | 314 return; |
| 315 } | 315 } |
| 316 | 316 |
| 317 // TODO(aa): It would be best to run this in a unit test, but in order | 317 // TODO(aa): It would be best to run this in a unit test, but in order |
| 318 // to do that we would need to better factor this code so that it | 318 // to do that we would need to better factor this code so that it |
| 319 // doesn't depend on so much v8::Extension machinery. | 319 // doesn't depend on so much v8::Extension machinery. |
| 320 if (logging.DCHECK_IS_ON() && | 320 if (!logging.DCHECK_IS_OFF() && |
| 321 schemaUtils.isFunctionSignatureAmbiguous(apiFunction.definition)) { | 321 schemaUtils.isFunctionSignatureAmbiguous(apiFunction.definition)) { |
| 322 throw new Error( | 322 throw new Error( |
| 323 apiFunction.name + ' has ambiguous optional arguments. ' + | 323 apiFunction.name + ' has ambiguous optional arguments. ' + |
| 324 'To implement custom disambiguation logic, add ' + | 324 'To implement custom disambiguation logic, add ' + |
| 325 '"allowAmbiguousOptionalArguments" to the function\'s schema.'); | 325 '"allowAmbiguousOptionalArguments" to the function\'s schema.'); |
| 326 } | 326 } |
| 327 | 327 |
| 328 this.apiFunctions_.register(functionDef.name, apiFunction); | 328 this.apiFunctions_.register(functionDef.name, apiFunction); |
| 329 | 329 |
| 330 mod[functionDef.name] = $Function.bind(function() { | 330 mod[functionDef.name] = $Function.bind(function() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 348 var optArgs = { | 348 var optArgs = { |
| 349 customCallback: this.customCallback | 349 customCallback: this.customCallback |
| 350 }; | 350 }; |
| 351 retval = sendRequest(this.name, args, | 351 retval = sendRequest(this.name, args, |
| 352 this.definition.parameters, | 352 this.definition.parameters, |
| 353 optArgs); | 353 optArgs); |
| 354 } | 354 } |
| 355 sendRequestHandler.clearCalledSendRequest(); | 355 sendRequestHandler.clearCalledSendRequest(); |
| 356 | 356 |
| 357 // Validate return value if in sanity check mode. | 357 // Validate return value if in sanity check mode. |
| 358 if (logging.DCHECK_IS_ON() && this.definition.returns) | 358 if (!logging.DCHECK_IS_OFF() && this.definition.returns) |
| 359 schemaUtils.validate([retval], [this.definition.returns]); | 359 schemaUtils.validate([retval], [this.definition.returns]); |
| 360 return retval; | 360 return retval; |
| 361 }, apiFunction); | 361 }, apiFunction); |
| 362 }, this); | 362 }, this); |
| 363 } | 363 } |
| 364 | 364 |
| 365 // Setup Events | 365 // Setup Events |
| 366 if (schema.events) { | 366 if (schema.events) { |
| 367 $Array.forEach(schema.events, function(eventDef) { | 367 $Array.forEach(schema.events, function(eventDef) { |
| 368 if (eventDef.name in mod) { | 368 if (eventDef.name in mod) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 availability.message); | 479 availability.message); |
| 480 return; | 480 return; |
| 481 } | 481 } |
| 482 | 482 |
| 483 this.runHooks_(mod); | 483 this.runHooks_(mod); |
| 484 return mod; | 484 return mod; |
| 485 } | 485 } |
| 486 }; | 486 }; |
| 487 | 487 |
| 488 exports.Binding = Binding; | 488 exports.Binding = Binding; |
| OLD | NEW |