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

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

Issue 803653004: Update Chromoting to use /third_party/closure_compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused types Created 5 years, 11 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 }; 84 };
85 85
86 /** 86 /**
87 * Connects to the native messaging host and sends a hello message. 87 * Connects to the native messaging host and sends a hello message.
88 * 88 *
89 * @return {Promise} A promise that fulfills when the connection attempt 89 * @return {Promise} A promise that fulfills when the connection attempt
90 * succeeds or fails. 90 * succeeds or fails.
91 * @private 91 * @private
92 */ 92 */
93 remoting.HostDaemonFacade.prototype.connectNative_ = function() { 93 remoting.HostDaemonFacade.prototype.connectNative_ = function() {
94 return new Promise( 94 /**
95 /** 95 * @this {remoting.HostDaemonFacade}
96 * @param {function(*=):void} resolve 96 * @param {function(?):void} resolve
97 * @param {function(*=):void} reject 97 * @param {function(*):void} reject
98 * @this {remoting.HostDaemonFacade} 98 */
99 */ 99 var connect = function(resolve, reject) {
100 function(resolve, reject) { 100 try {
101 try { 101 this.port_ = chrome.runtime.connectNative(
102 this.port_ = chrome.runtime.connectNative( 102 'com.google.chrome.remote_desktop');
103 'com.google.chrome.remote_desktop'); 103 this.port_.onMessage.addListener(this.onIncomingMessageCallback_);
104 this.port_.onMessage.addListener(this.onIncomingMessageCallback_); 104 this.port_.onDisconnect.addListener(this.onDisconnectCallback_);
105 this.port_.onDisconnect.addListener(this.onDisconnectCallback_); 105 this.postMessageInternal_({type: 'hello'}, resolve, reject);
106 this.postMessageInternal_({type: 'hello'}, resolve, reject); 106 } catch (/** @type {*} */ err) {
107 } catch (err) { 107 console.log('Native Messaging initialization failed: ', err);
108 console.log('Native Messaging initialization failed: ', 108 reject(false);
kelvinp 2015/01/12 22:51:28 why false here?
garykac 2015/01/13 00:28:39 reject() requires at least 1 argument(s) and no mo
Tyler Breisacher (Chromium) 2015/01/13 03:01:00 We actually changed this in https://github.com/goo
109 /** @type {*} */ (err)); 109 }
110 reject(); 110 };
111 } 111
112 }.bind(this) 112 return new Promise(connect.bind(this));
113 );
114 }; 113 };
115 114
116 /** 115 /**
117 * Type used for entries of |pendingReplies_| list. 116 * Type used for entries of |pendingReplies_| list.
118 * 117 *
119 * @param {string} type Type of the originating request. 118 * @param {string} type Type of the originating request.
120 * @param {function(...):void} onDone Response callback. Parameters depend on 119 * @param {function(...):void} onDone Response callback. Parameters depend on
121 * the request type. 120 * the request type.
122 * @param {function(remoting.Error):void} onError Callback to call on error. 121 * @param {function(remoting.Error):void} onError Callback to call on error.
123 * @constructor 122 * @constructor
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 205 }
207 delete this.pendingReplies_[id]; 206 delete this.pendingReplies_[id];
208 207
209 try { 208 try {
210 var type = getStringAttr(message, 'type'); 209 var type = getStringAttr(message, 'type');
211 if (type != reply.type) { 210 if (type != reply.type) {
212 throw 'Expected reply type: ' + reply.type + ', got: ' + type; 211 throw 'Expected reply type: ' + reply.type + ', got: ' + type;
213 } 212 }
214 213
215 this.handleIncomingMessage_(message, reply.onDone); 214 this.handleIncomingMessage_(message, reply.onDone);
216 } catch (e) { 215 } catch (/** @type {*} */ e) {
217 console.error('Error while processing native message' + 216 console.error('Error while processing native message' + e);
218 /** @type {*} */ (e));
219 reply.onError(remoting.Error.UNEXPECTED); 217 reply.onError(remoting.Error.UNEXPECTED);
220 } 218 }
221 } 219 }
222 220
223 /** 221 /**
224 * Handler for incoming Native Messages. 222 * Handler for incoming Native Messages.
225 * 223 *
226 * @param {Object} message The received message. 224 * @param {Object} message The received message.
227 * @param {function(...):void} onDone Function to call when we're done 225 * @param {function(...):void} onDone Function to call when we're done
228 * processing the message. 226 * processing the message.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 331
334 // If initialization hasn't finished then assume that the port was 332 // If initialization hasn't finished then assume that the port was
335 // disconnected because Native Messaging host is not installed. 333 // disconnected because Native Messaging host is not installed.
336 this.error_ = this.initializingPromise_ ? remoting.Error.MISSING_PLUGIN : 334 this.error_ = this.initializingPromise_ ? remoting.Error.MISSING_PLUGIN :
337 remoting.Error.UNEXPECTED; 335 remoting.Error.UNEXPECTED;
338 336
339 // Notify the error-handlers of any requests that are still outstanding. 337 // Notify the error-handlers of any requests that are still outstanding.
340 var pendingReplies = this.pendingReplies_; 338 var pendingReplies = this.pendingReplies_;
341 this.pendingReplies_ = {}; 339 this.pendingReplies_ = {};
342 for (var id in pendingReplies) { 340 for (var id in pendingReplies) {
343 pendingReplies[/** @type {number} */(id)].onError(this.error_); 341 var num_id = parseInt(id, 10);
342 pendingReplies[num_id].onError(this.error_);
344 } 343 }
345 } 344 }
346 345
347 /** 346 /**
348 * Gets local hostname. 347 * Gets local hostname.
349 * 348 *
350 * @param {function(string):void} onDone Callback to return result. 349 * @param {function(string):void} onDone Callback to return result.
351 * @param {function(remoting.Error):void} onError Callback to call on error. 350 * @param {function(remoting.Error):void} onError Callback to call on error.
352 * @return {void} Nothing. 351 * @return {void} Nothing.
353 */ 352 */
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 * @param {function(remoting.Error):void} onError Callback to call on error. 558 * @param {function(remoting.Error):void} onError Callback to call on error.
560 * @return {void} Nothing. 559 * @return {void} Nothing.
561 */ 560 */
562 remoting.HostDaemonFacade.prototype.getCredentialsFromAuthCode = 561 remoting.HostDaemonFacade.prototype.getCredentialsFromAuthCode =
563 function(authorizationCode, onDone, onError) { 562 function(authorizationCode, onDone, onError) {
564 this.postMessage_({ 563 this.postMessage_({
565 type: 'getCredentialsFromAuthCode', 564 type: 'getCredentialsFromAuthCode',
566 authorizationCode: authorizationCode 565 authorizationCode: authorizationCode
567 }, onDone, onError); 566 }, onDone, onError);
568 }; 567 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698