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

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

Issue 1094133003: Added (incomplete) implementation of HostListApi using GCD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcd-client-fix
Patch Set: Created 5 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 representing the host-list portion of the home screen UI. 7 * Class representing the host-list portion of the home screen UI.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 */ 145 */
146 remoting.HostList.prototype.refresh = function(onDone) { 146 remoting.HostList.prototype.refresh = function(onDone) {
147 this.loadingIndicator_.classList.add('loading'); 147 this.loadingIndicator_.classList.add('loading');
148 /** @type {remoting.HostList} */ 148 /** @type {remoting.HostList} */
149 var that = this; 149 var that = this;
150 /** @param {!remoting.Error} error */ 150 /** @param {!remoting.Error} error */
151 var onError = function(error) { 151 var onError = function(error) {
152 that.lastError_ = error; 152 that.lastError_ = error;
153 onDone(false); 153 onDone(false);
154 }; 154 };
155 remoting.hostListApi.get().then(function(hosts) { 155 remoting.HostListApi.getInstance().get().then(function(hosts) {
156 onDone(that.onHostListResponse_(hosts)); 156 onDone(that.onHostListResponse_(hosts));
157 }).catch( 157 }).catch(
158 remoting.Error.handler(onError) 158 remoting.Error.handler(onError)
159 ); 159 );
160 }; 160 };
161 161
162 /** 162 /**
163 * Handle the results of the host list request. A success response will 163 * Handle the results of the host list request. A success response will
164 * include a JSON-encoded list of host descriptions, which we display if we're 164 * include a JSON-encoded list of host descriptions, which we display if we're
165 * able to successfully parse it. 165 * able to successfully parse it.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 * @param {remoting.HostTableEntry} hostTableEntry The host to be removed. 299 * @param {remoting.HostTableEntry} hostTableEntry The host to be removed.
300 * @return {void} Nothing. 300 * @return {void} Nothing.
301 * @private 301 * @private
302 */ 302 */
303 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) { 303 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) {
304 this.table_.removeChild(hostTableEntry.element()); 304 this.table_.removeChild(hostTableEntry.element());
305 var index = this.hostTableEntries_.indexOf(hostTableEntry); 305 var index = this.hostTableEntries_.indexOf(hostTableEntry);
306 if (index != -1) { 306 if (index != -1) {
307 this.hostTableEntries_.splice(index, 1); 307 this.hostTableEntries_.splice(index, 1);
308 } 308 }
309 remoting.hostListApi.remove(hostTableEntry.host.hostId). 309 remoting.HostListApi.getInstance().remove(hostTableEntry.host.hostId).
310 catch(this.onError_); 310 catch(this.onError_);
311 }; 311 };
312 312
313 /** 313 /**
314 * Prepare a host for renaming by replacing its name with an edit box. 314 * Prepare a host for renaming by replacing its name with an edit box.
315 * @param {remoting.HostTableEntry} hostTableEntry The host to be renamed. 315 * @param {remoting.HostTableEntry} hostTableEntry The host to be renamed.
316 * @return {void} Nothing. 316 * @return {void} Nothing.
317 */ 317 */
318 remoting.HostList.prototype.renameHost = function(hostTableEntry) { 318 remoting.HostList.prototype.renameHost = function(hostTableEntry) {
319 for (var i = 0; i < this.hosts_.length; ++i) { 319 for (var i = 0; i < this.hosts_.length; ++i) {
320 if (this.hosts_[i].hostId == hostTableEntry.host.hostId) { 320 if (this.hosts_[i].hostId == hostTableEntry.host.hostId) {
321 this.hosts_[i].hostName = hostTableEntry.host.hostName; 321 this.hosts_[i].hostName = hostTableEntry.host.hostName;
322 break; 322 break;
323 } 323 }
324 } 324 }
325 this.save_(); 325 this.save_();
326 326
327 remoting.hostListApi.put(hostTableEntry.host.hostId, 327 remoting.HostListApi.getInstance().put(
328 hostTableEntry.host.hostName, 328 hostTableEntry.host.hostId,
329 hostTableEntry.host.publicKey). 329 hostTableEntry.host.hostName,
330 hostTableEntry.host.publicKey).
330 catch(this.onError_); 331 catch(this.onError_);
Jamie 2015/04/22 23:46:01 Indentation is a bit confusing here. I suggest ass
John Williams 2015/04/23 23:55:42 Done.
331 }; 332 };
332 333
333 /** 334 /**
334 * Unregister a host. 335 * Unregister a host.
335 * @param {string} hostId The id of the host to be removed. 336 * @param {string} hostId The id of the host to be removed.
336 * @param {function(void)=} opt_onDone 337 * @param {function(void)=} opt_onDone
337 * @return {void} Nothing. 338 * @return {void} Nothing.
338 */ 339 */
339 remoting.HostList.prototype.unregisterHostById = function(hostId, opt_onDone) { 340 remoting.HostList.prototype.unregisterHostById = function(hostId, opt_onDone) {
340 var that = this; 341 var that = this;
341 var onDone = opt_onDone || base.doNothing; 342 var onDone = opt_onDone || base.doNothing;
342 343
343 var host = this.getHostForId(hostId); 344 var host = this.getHostForId(hostId);
344 if (!host) { 345 if (!host) {
345 console.log('Skipping host un-registration as the host is not registered ' + 346 console.log('Skipping host un-registration as the host is not registered ' +
346 'under the current account'); 347 'under the current account');
347 onDone(); 348 onDone();
348 return; 349 return;
349 } 350 }
350 351
351 remoting.hostListApi.remove(hostId). 352 remoting.HostListApi.getInstance().remove(hostId).
352 then(function() { 353 then(function() {
353 that.refresh(function() { 354 that.refresh(function() {
354 that.display(); 355 that.display();
355 onDone(); 356 onDone();
356 }); 357 });
357 }). 358 }).
358 catch(this.onError_); 359 catch(this.onError_);
359 }; 360 };
360 361
361 /** 362 /**
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 427 }
427 }; 428 };
428 429
429 /** 430 /**
430 * Key name under which Me2Me hosts are cached. 431 * Key name under which Me2Me hosts are cached.
431 */ 432 */
432 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; 433 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts';
433 434
434 /** @type {remoting.HostList} */ 435 /** @type {remoting.HostList} */
435 remoting.hostList = null; 436 remoting.hostList = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698