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

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

Issue 2621403004: Create proper object types when loading host cache. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « remoting/webapp/base/js/host_options.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 * @param {function():void} onDone Completion callback. 102 * @param {function():void} onDone Completion callback.
103 */ 103 */
104 remoting.HostList.prototype.load = function(onDone) { 104 remoting.HostList.prototype.load = function(onDone) {
105 // Load the cache of the last host-list, if present. 105 // Load the cache of the last host-list, if present.
106 /** @type {remoting.HostList} */ 106 /** @type {remoting.HostList} */
107 var that = this; 107 var that = this;
108 /** @param {Object<string>} items */ 108 /** @param {Object<string>} items */
109 var storeHostList = function(items) { 109 var storeHostList = function(items) {
110 if (items[remoting.HostList.HOSTS_KEY]) { 110 if (items[remoting.HostList.HOSTS_KEY]) {
111 var cached = base.jsonParseSafe(items[remoting.HostList.HOSTS_KEY]); 111 var cached = base.jsonParseSafe(items[remoting.HostList.HOSTS_KEY]);
112 if (cached) { 112 if (cached && cached instanceof Array) {
113 that.hosts_ = /** @type {Array<remoting.Host>} */ (cached); 113 that.hosts_ = cached
114 .map((host) => remoting.Host.fromObject(host))
115 .filter((host) => Boolean(host));
114 } else { 116 } else {
115 console.error('Invalid value for ' + remoting.HostList.HOSTS_KEY); 117 console.error('Invalid value for ' + remoting.HostList.HOSTS_KEY);
116 } 118 }
117 } 119 }
118 onDone(); 120 onDone();
119 }; 121 };
120 chrome.storage.local.get(remoting.HostList.HOSTS_KEY, storeHostList); 122 chrome.storage.local.get(remoting.HostList.HOSTS_KEY, storeHostList);
121 }; 123 };
122 124
123 /** 125 /**
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 476 }
475 }; 477 };
476 478
477 /** 479 /**
478 * Key name under which Me2Me hosts are cached. 480 * Key name under which Me2Me hosts are cached.
479 */ 481 */
480 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; 482 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts';
481 483
482 /** @type {remoting.HostList} */ 484 /** @type {remoting.HostList} */
483 remoting.hostList = null; 485 remoting.hostList = null;
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/host_options.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698