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

Unified Diff: chrome/renderer/resources/extensions/bluetooth_custom_bindings.js

Issue 12632004: Revert 186643 - Caused a 10% regression on SunSpider benchmark (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/bluetooth_custom_bindings.js
===================================================================
--- chrome/renderer/resources/extensions/bluetooth_custom_bindings.js (revision 186747)
+++ chrome/renderer/resources/extensions/bluetooth_custom_bindings.js (working copy)
@@ -2,27 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Custom binding for the Bluetooth API.
+// Custom bindings for the Bluetooth API.
-var binding = require('binding').Binding.create('bluetooth');
-
var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
-var chrome = requireNative('chrome').GetChrome();
var sendRequest = require('sendRequest').sendRequest;
var lastError = require('lastError');
-// Use custom binding to create an undocumented event listener that will
+// Use custom bindings to create an undocumented event listener that will
// receive events about device discovery and call the event listener that was
// provided with the request to begin discovery.
-binding.registerCustomHook(function(api) {
+chromeHidden.registerCustomHook('bluetooth', function(api) {
var apiFunctions = api.apiFunctions;
chromeHidden.bluetooth = {};
- function callCallbackIfPresent(args, error) {
- var callback = args[args.length - 1];
- if (typeof(callback) == "function")
- lastError.run(error, callback);
+ function callCallbackIfPresent(args) {
+ if (typeof(args[args.length-1]) == "function") {
+ args[args.length-1]();
+ }
}
chromeHidden.bluetooth.deviceDiscoveredHandler = null;
@@ -38,7 +35,8 @@
var args = arguments;
if (args.length > 0 && args[0] && args[0].deviceCallback) {
if (chromeHidden.bluetooth.deviceDiscoveredHandler != null) {
- callCallbackIfPresent(args, "Concurrent discovery is not allowed.");
+ lastError.set("Concurrent discovery is not allowed.");
+ callCallbackIfPresent(args);
return;
}
@@ -51,9 +49,8 @@
this.definition.parameters,
{customCallback:this.customCallback});
} else {
- callCallbackIfPresent(
- args, "deviceCallback is required in the options object");
- return;
+ lastError.set("deviceCallback is required in the options object");
+ callCallbackIfPresent(args);
}
});
apiFunctions.setCustomCallback('startDiscovery',
@@ -157,5 +154,3 @@
return args;
});
});
-
-exports.binding = binding.generate();

Powered by Google App Engine
This is Rietveld 408576698