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

Side by Side Diff: remoting/webapp/crd/js/host_daemon_facade.js

Issue 1004513002: Eliminated named constants for instances of remoting.Error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class to communicate with the host daemon via Native Messaging. 7 * Class to communicate with the host daemon via Native Messaging.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 24 matching lines...) Expand all
35 this.afterInitializationTasks_ = []; 35 this.afterInitializationTasks_ = [];
36 36
37 /** 37 /**
38 * A promise that fulfills when the daemon finishes initializing. 38 * A promise that fulfills when the daemon finishes initializing.
39 * It will be set to null when the promise fulfills. 39 * It will be set to null when the promise fulfills.
40 * @private {Promise} 40 * @private {Promise}
41 */ 41 */
42 this.initializingPromise_ = null; 42 this.initializingPromise_ = null;
43 43
44 /** @private {!remoting.Error} */ 44 /** @private {!remoting.Error} */
45 this.error_ = remoting.Error.NONE; 45 this.error_ = remoting.Error.none();
46 46
47 /** @private */ 47 /** @private */
48 this.onIncomingMessageCallback_ = this.onIncomingMessage_.bind(this); 48 this.onIncomingMessageCallback_ = this.onIncomingMessage_.bind(this);
49 49
50 /** @private */ 50 /** @private */
51 this.onDisconnectCallback_ = this.onDisconnect_.bind(this); 51 this.onDisconnectCallback_ = this.onDisconnect_.bind(this);
52 52
53 this.initialize_(); 53 this.initialize_();
54 }; 54 };
55 55
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 delete this.pendingReplies_[id]; 199 delete this.pendingReplies_[id];
200 200
201 try { 201 try {
202 var type = getStringAttr(message, 'type'); 202 var type = getStringAttr(message, 'type');
203 if (type != reply.type) { 203 if (type != reply.type) {
204 throw 'Expected reply type: ' + reply.type + ', got: ' + type; 204 throw 'Expected reply type: ' + reply.type + ', got: ' + type;
205 } 205 }
206 206
207 this.handleIncomingMessage_(message, reply.onDone); 207 this.handleIncomingMessage_(message, reply.onDone);
208 } catch (/** @type {*} */ e) { 208 } catch (/** @type {*} */ e) {
209 console.error('Error while processing native message' + e); 209 console.error('Error while processing native message', e);
210 reply.onError(remoting.Error.UNEXPECTED); 210 reply.onError(remoting.Error.unexpected());
211 } 211 }
212 } 212 }
213 213
214 /** 214 /**
215 * Handler for incoming Native Messages. 215 * Handler for incoming Native Messages.
216 * 216 *
217 * @param {Object} message The received message. 217 * @param {Object} message The received message.
218 * @param {function(...):void} onDone Function to call when we're done 218 * @param {function(...):void} onDone Function to call when we're done
219 * processing the message. 219 * processing the message.
220 * @return {void} Nothing. 220 * @return {void} Nothing.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 */ 317 */
318 remoting.HostDaemonFacade.prototype.onDisconnect_ = function() { 318 remoting.HostDaemonFacade.prototype.onDisconnect_ = function() {
319 console.error('Native Message port disconnected'); 319 console.error('Native Message port disconnected');
320 320
321 this.port_.onDisconnect.removeListener(this.onDisconnectCallback_); 321 this.port_.onDisconnect.removeListener(this.onDisconnectCallback_);
322 this.port_.onMessage.removeListener(this.onIncomingMessageCallback_); 322 this.port_.onMessage.removeListener(this.onIncomingMessageCallback_);
323 this.port_ = null; 323 this.port_ = null;
324 324
325 // If initialization hasn't finished then assume that the port was 325 // If initialization hasn't finished then assume that the port was
326 // disconnected because Native Messaging host is not installed. 326 // disconnected because Native Messaging host is not installed.
327 this.error_ = this.initializingPromise_ ? remoting.Error.MISSING_PLUGIN : 327 this.error_ = this.initializingPromise_ ?
328 remoting.Error.UNEXPECTED; 328 new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN) :
329 remoting.Error.unexpected();
329 330
330 // Notify the error-handlers of any requests that are still outstanding. 331 // Notify the error-handlers of any requests that are still outstanding.
331 var pendingReplies = this.pendingReplies_; 332 var pendingReplies = this.pendingReplies_;
332 this.pendingReplies_ = {}; 333 this.pendingReplies_ = {};
333 for (var id in pendingReplies) { 334 for (var id in pendingReplies) {
334 var num_id = parseInt(id, 10); 335 var num_id = parseInt(id, 10);
335 pendingReplies[num_id].onError(this.error_); 336 pendingReplies[num_id].onError(this.error_);
336 } 337 }
337 } 338 }
338 339
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 * @param {function(!remoting.Error):void} onError Callback to call on error. 552 * @param {function(!remoting.Error):void} onError Callback to call on error.
552 * @return {void} Nothing. 553 * @return {void} Nothing.
553 */ 554 */
554 remoting.HostDaemonFacade.prototype.getCredentialsFromAuthCode = 555 remoting.HostDaemonFacade.prototype.getCredentialsFromAuthCode =
555 function(authorizationCode, onDone, onError) { 556 function(authorizationCode, onDone, onError) {
556 this.postMessage_({ 557 this.postMessage_({
557 type: 'getCredentialsFromAuthCode', 558 type: 'getCredentialsFromAuthCode',
558 authorizationCode: authorizationCode 559 authorizationCode: authorizationCode
559 }, onDone, onError); 560 }, onDone, onError);
560 }; 561 };
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/host_controller.js ('k') | remoting/webapp/crd/js/host_install_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698