diff options
author | kelvinp <kelvinp@chromium.org> | 2015-10-02 10:47:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-02 17:48:16 +0000 |
commit | c431b2d4a25c1ee727d2fd7b23198a7c3392d0c1 (patch) | |
tree | b932562144bf6333933914498b89141c75f5cf44 /remoting | |
parent | 909a0a52b2de576ecc83c7df1dd29072545ea13c (diff) | |
download | chromium_src-c431b2d4a25c1ee727d2fd7b23198a7c3392d0c1.zip chromium_src-c431b2d4a25c1ee727d2fd7b23198a7c3392d0c1.tar.gz chromium_src-c431b2d4a25c1ee727d2fd7b23198a7c3392d0c1.tar.bz2 |
Detect plugin initialization failures with the error event.
This CL uses the "error" event to detect initialization error instead of
a timeout. This avoid the problems of having a timeout that is too long
to be meaningful or having a timeout that is too short to error out
prematurely.
BUG=535016
Review URL: https://codereview.chromium.org/1382033003
Cr-Commit-Position: refs/heads/master@{#352068}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/webapp/base/js/client_plugin_impl.js | 44 | ||||
-rw-r--r-- | remoting/webapp/js_proto/dom_proto.js | 8 |
2 files changed, 24 insertions, 28 deletions
diff --git a/remoting/webapp/base/js/client_plugin_impl.js b/remoting/webapp/base/js/client_plugin_impl.js index 892de83..f115a7e 100644 --- a/remoting/webapp/base/js/client_plugin_impl.js +++ b/remoting/webapp/base/js/client_plugin_impl.js @@ -66,10 +66,8 @@ remoting.ClientPluginImpl = function(container, capabilities) { * @private {Array<remoting.ClientSession.Capability>} */ this.hostCapabilities_ = null; - /** @private {boolean} */ - this.helloReceived_ = false; /** @private {base.Deferred} */ - this.onInitializedDeferred_ = null; + this.onInitializedDeferred_ = new base.Deferred(); /** @private {function(string, string):void} */ this.onPairingComplete_ = function(clientId, sharedSecret) {}; /** @private {remoting.ClientSession.PerfStats} */ @@ -82,8 +80,9 @@ remoting.ClientPluginImpl = function(container, capabilities) { new base.DomEventHook( this.plugin_, 'message', this.handleMessage_.bind(this), false), new base.DomEventHook( - this.plugin_, 'crash', this.onPluginCrashed_.bind(this), false)); - + this.plugin_, 'crash', this.onPluginCrashed_.bind(this), false), + new base.DomEventHook( + this.plugin_, 'error', this.onPluginLoadError_.bind(this), false)); /** @private */ this.hostDesktop_ = new remoting.ClientPlugin.HostDesktopImpl( this, this.postMessage_.bind(this)); @@ -179,6 +178,13 @@ remoting.ClientPluginImpl.prototype.onPluginCrashed_ = function(event) { console.error('Plugin crashed.'); }; +/** @private */ +remoting.ClientPluginImpl.prototype.onPluginLoadError_ = function() { + console.error('Failed to load plugin : ' + this.plugin_.lastError); + this.onInitializedDeferred_.reject( + new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); +}; + /** * @param {remoting.ClientPluginMessage} * message Parsed message from the plugin. @@ -247,12 +253,7 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) { } if (message.method == 'hello') { - this.helloReceived_ = true; - if (this.onInitializedDeferred_ != null) { - this.onInitializedDeferred_.resolve(true); - this.onInitializedDeferred_ = null; - } - + this.onInitializedDeferred_.resolve(); } else if (message.method == 'onDesktopSize') { this.hostDesktop_.onSizeUpdated(message); } else if (message.method == 'onDesktopShape') { @@ -366,28 +367,15 @@ remoting.ClientPluginImpl.prototype.element = function() { }; /** - * @return {Promise} A promise that resolves to true if the plugin initializes. + * @override {remoting.ClientPlugin} */ remoting.ClientPluginImpl.prototype.initialize = function() { - // 99.9 percentile of plugin initialize time from our stats is 141 seconds. - var PLUGIN_INTIALIZE_TIMEOUT = 150 * 1000; - + // If Nacl is disabled, we won't receive any error events, rejecting the + // promise immediately. if (!base.isNaclEnabled()) { return Promise.reject(new remoting.Error(remoting.Error.Tag.NACL_DISABLED)); } - - if (this.helloReceived_) { - return Promise.resolve(true); - } - - if (!this.onInitializedDeferred_) { - this.onInitializedDeferred_ = new base.Deferred(); - } - - return base.Promise.rejectAfterTimeout( - this.onInitializedDeferred_.promise(), - PLUGIN_INTIALIZE_TIMEOUT, - new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); + return this.onInitializedDeferred_.promise(); }; /** diff --git a/remoting/webapp/js_proto/dom_proto.js b/remoting/webapp/js_proto/dom_proto.js index de12493..c47c990 100644 --- a/remoting/webapp/js_proto/dom_proto.js +++ b/remoting/webapp/js_proto/dom_proto.js @@ -212,3 +212,11 @@ chrome.ConsoleMessageBrowserEvent.prototype.message; /** @type {string} */ chrome.ConsoleMessageBrowserEvent.prototype.sourceId; + +/** + * The last error of the NaCL embed element. + * https://developer.chrome.com/native-client/devguide/coding/progress-events + * + * @type {string} + */ +HTMLEmbedElement.prototype.lastError; |