Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / cryptotoken / llhidgnubby.js
index 0f643bb..0587c5e 100644 (file)
@@ -40,6 +40,8 @@ llHidGnubby.NAMESPACE = 'hid';
 llHidGnubby.prototype.destroy = function() {
   if (!this.dev) return;  // Already dead.
 
+  this.gnubbies_.removeOpenDevice(
+      {namespace: llHidGnubby.NAMESPACE, device: this.id});
   this.closing = true;
 
   console.log(UTIL_fmt('llHidGnubby.destroy()'));
@@ -68,15 +70,9 @@ llHidGnubby.prototype.destroy = function() {
   var dev = this.dev;
   this.dev = null;
 
-  var self = this;
-
-  function onClosed() {
+  chrome.hid.disconnect(dev.connectionId, function() {
     console.log(UTIL_fmt('Device ' + dev.handle + ' closed'));
-    self.gnubbies_.removeOpenDevice(
-        {namespace: llHidGnubby.NAMESPACE, device: self.id});
-  }
-
-  chrome.hid.disconnect(dev.connectionId, onClosed);
+  });
 };
 
 /**
@@ -104,17 +100,6 @@ llHidGnubby.prototype.publishFrame_ = function(f) {
 };
 
 /**
- * @return {boolean} whether this device is open and ready to use.
- * @private
- */
-llHidGnubby.prototype.readyToUse_ = function() {
-  if (this.closing) return false;
-  if (!this.dev) return false;
-
-  return true;
-};
-
-/**
  * Register a client for this gnubby.
  * @param {*} who The client.
  */
@@ -299,7 +284,7 @@ llHidGnubby.prototype.updateLock_ = function(cid, cmd, arg) {
  * If queue was empty, initiate the write.
  * @param {number} cid The client's channel ID.
  * @param {number} cmd The command to send.
- * @param {ArrayBuffer} data Command arguments
+ * @param {ArrayBuffer|Uint8Array} data Command arguments
  */
 llHidGnubby.prototype.queueCommand = function(cid, cmd, data) {
   if (!this.dev) return;