diff options
author | Dan Beam <dbeam@chromium.org> | 2015-04-22 15:24:56 -0700 |
---|---|---|
committer | Dan Beam <dbeam@chromium.org> | 2015-04-22 22:26:21 +0000 |
commit | fb1e8404607c8117407865bcce0db2c01b04d1f8 (patch) | |
tree | 6264d63f292822cabaf879cc52b7eed3a2d042ca /remoting | |
parent | f9890dca378b4a0434071cad64d7d5cd0d3472db (diff) | |
download | chromium_src-fb1e8404607c8117407865bcce0db2c01b04d1f8.zip chromium_src-fb1e8404607c8117407865bcce0db2c01b04d1f8.tar.gz chromium_src-fb1e8404607c8117407865bcce0db2c01b04d1f8.tar.bz2 |
Fix some closure compiler nits in remoting/ to bump compiler.
R=jamiewalch@chromium.org
BUG=none
TEST=newer compiler.jar builds clean
Review URL: https://codereview.chromium.org/1050953004
Cr-Commit-Position: refs/heads/master@{#326381}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/webapp/browser_test/timeout_waiter.js | 49 | ||||
-rw-r--r-- | remoting/webapp/crd/js/app_launcher.js | 143 | ||||
-rw-r--r-- | remoting/webapp/crd/js/client_plugin_impl.js | 11 | ||||
-rw-r--r-- | remoting/webapp/crd/js/host_installer.js | 51 | ||||
-rw-r--r-- | remoting/webapp/unittests/spy_promise.js | 4 |
5 files changed, 133 insertions, 125 deletions
diff --git a/remoting/webapp/browser_test/timeout_waiter.js b/remoting/webapp/browser_test/timeout_waiter.js index fd75ada..cb1a3a4 100644 --- a/remoting/webapp/browser_test/timeout_waiter.js +++ b/remoting/webapp/browser_test/timeout_waiter.js @@ -34,31 +34,32 @@ browserTest.Predicate.prototype.description = function() {}; * @return {Promise} */ browserTest.waitFor = function(predicate, opt_timeout) { - /** - * @param {function():void} fulfill - * @param {function(Error):void} reject - */ - return new Promise(function (fulfill, reject) { - if (opt_timeout === undefined) { - opt_timeout = browserTest.Timeout.DEFAULT; - } + return new Promise( + /** + * @param {function(boolean):void} fulfill + * @param {function(Error):void} reject + */ + function (fulfill, reject) { + if (opt_timeout === undefined) { + opt_timeout = browserTest.Timeout.DEFAULT; + } - var timeout = /** @type {number} */ (opt_timeout); - var end = Number(Date.now()) + timeout; - var testPredicate = function() { - if (predicate.evaluate()) { - console.log(predicate.description() + ' satisfied.'); - fulfill(true); - } else if (Date.now() >= end) { - reject(new Error('Timed out (' + opt_timeout + 'ms) waiting for ' + - predicate.description())); - } else { - console.log(predicate.description() + ' not yet satisfied.'); - window.setTimeout(testPredicate, 500); - } - }; - testPredicate(); - }); + var timeout = /** @type {number} */ (opt_timeout); + var end = Number(Date.now()) + timeout; + var testPredicate = function() { + if (predicate.evaluate()) { + console.log(predicate.description() + ' satisfied.'); + fulfill(true); + } else if (Date.now() >= end) { + reject(new Error('Timed out (' + opt_timeout + 'ms) waiting for ' + + predicate.description())); + } else { + console.log(predicate.description() + ' not yet satisfied.'); + window.setTimeout(testPredicate, 500); + } + }; + testPredicate(); + }); }; /** diff --git a/remoting/webapp/crd/js/app_launcher.js b/remoting/webapp/crd/js/app_launcher.js index e5f158d..fc28ab7 100644 --- a/remoting/webapp/crd/js/app_launcher.js +++ b/remoting/webapp/crd/js/app_launcher.js @@ -52,38 +52,41 @@ remoting.V1AppLauncher = function() {}; remoting.V1AppLauncher.prototype.launch = function(opt_launchArgs) { var url = base.urlJoin('main.html', opt_launchArgs); - /** - * @param {function(*=):void} resolve - * @param {function(*=):void} reject - */ - return new Promise(function(resolve, reject) { - chrome.tabs.create({ url: url, selected: true }, - /** @param {chrome.Tab} tab The created tab. */ - function(tab) { - if (!tab) { - reject(new Error(chrome.runtime.lastError.message)); - } else { - resolve(String(tab.id)); - } - }); - }); + return new Promise( + /** + * @param {function(*=):void} resolve + * @param {function(*=):void} reject + */ + function(resolve, reject) { + chrome.tabs.create({ url: url, selected: true }, + /** @param {chrome.Tab} tab The created tab. */ + function(tab) { + if (!tab) { + reject(new Error(chrome.runtime.lastError.message)); + } else { + resolve(String(tab.id)); + } + }); + }); }; remoting.V1AppLauncher.prototype.close = function(id) { - /** - * @param {function(*=):void} resolve - * @param {function(*=):void} reject - */ - return new Promise(function(resolve, reject) { - /** @param {chrome.Tab} tab The retrieved tab. */ - chrome.tabs.get(id, function(tab) { - if (!tab) { - reject(new Error(chrome.runtime.lastError.message)); - } else { - chrome.tabs.remove(tab.id, /** @type {function(*=):void} */ (resolve)); - } - }); - }); + return new Promise( + /** + * @param {function(*=):void} resolve + * @param {function(*=):void} reject + */ + function(resolve, reject) { + chrome.tabs.get(id, + /** @param {chrome.Tab} tab The retrieved tab. */ + function(tab) { + if (!tab) { + reject(new Error(chrome.runtime.lastError.message)); + } else { + chrome.tabs.remove(tab.id, /** function(*=):void */ (resolve)); + } + }); + }); }; @@ -110,49 +113,51 @@ remoting.V2AppLauncher.prototype.restart = function(id) { remoting.V2AppLauncher.prototype.launch = function(opt_launchArgs) { var url = base.urlJoin(APP_MAIN_URL, opt_launchArgs); - /** - * @param {function(*=):void} resolve - * @param {function(*=):void} reject - */ - return new Promise(function(resolve, reject) { - var START_FULLSCREEN = 'start-fullscreen'; - /** @param {Object} values */ - var onValues = function(values) { - /** @type {string} */ - var state = values[START_FULLSCREEN] ? 'fullscreen' : 'normal'; - chrome.app.window.create(url, { - 'width': 800, - 'height': 600, - 'frame': 'none', - 'id': String(getNextWindowId()), - 'state': state - }, - /** @param {AppWindow=} appWindow */ - function(appWindow) { - if (!appWindow) { - reject(new Error(chrome.runtime.lastError.message)); - } else { - resolve(appWindow.id); - } - }); - }; - chrome.storage.local.get(START_FULLSCREEN, onValues); - }); + return new Promise( + /** + * @param {function(*=):void} resolve + * @param {function(*=):void} reject + */ + function(resolve, reject) { + var START_FULLSCREEN = 'start-fullscreen'; + /** @param {Object} values */ + var onValues = function(values) { + /** @type {string} */ + var state = values[START_FULLSCREEN] ? 'fullscreen' : 'normal'; + chrome.app.window.create(url, { + 'width': 800, + 'height': 600, + 'frame': 'none', + 'id': String(getNextWindowId()), + 'state': state + }, + /** @param {AppWindow=} appWindow */ + function(appWindow) { + if (!appWindow) { + reject(new Error(chrome.runtime.lastError.message)); + } else { + resolve(appWindow.id); + } + }); + }; + chrome.storage.local.get(START_FULLSCREEN, onValues); + }); }; remoting.V2AppLauncher.prototype.close = function(id) { - /** - * @param {function(*=):void} resolve - * @param {function(*=):void} reject - */ - return new Promise(function(resolve, reject) { - var appWindow = chrome.app.window.get(id); - if (!appWindow) { - return Promise.reject(new Error(chrome.runtime.lastError.message)); - } - appWindow.onClosed.addListener(resolve); - appWindow.close(); - }); + return new Promise( + /** + * @param {function(*=):void} resolve + * @param {function(*=):void} reject + */ + function(resolve, reject) { + var appWindow = chrome.app.window.get(id); + if (!appWindow) { + return Promise.reject(new Error(chrome.runtime.lastError.message)); + } + appWindow.onClosed.addListener(resolve); + appWindow.close(); + }); }; /** diff --git a/remoting/webapp/crd/js/client_plugin_impl.js b/remoting/webapp/crd/js/client_plugin_impl.js index b441ef6..6248956 100644 --- a/remoting/webapp/crd/js/client_plugin_impl.js +++ b/remoting/webapp/crd/js/client_plugin_impl.js @@ -83,11 +83,12 @@ remoting.ClientPluginImpl = function(container, /** @type {remoting.ClientPluginImpl} */ var that = this; - /** @param {Event} event Message event from the plugin. */ - this.plugin_.addEventListener('message', function(event) { - that.handleMessage_( - /** @type {remoting.ClientPluginMessage} */ (event.data)); - }, false); + this.plugin_.addEventListener('message', + /** @param {Event} event Message event from the plugin. */ + function(event) { + that.handleMessage_( + /** @type {remoting.ClientPluginMessage} */ (event.data)); + }, false); if (remoting.settings.CLIENT_PLUGIN_TYPE == 'native') { window.setTimeout(this.showPluginForClickToPlay_.bind(this), 500); diff --git a/remoting/webapp/crd/js/host_installer.js b/remoting/webapp/crd/js/host_installer.js index 3ff1013..c8a15a3 100644 --- a/remoting/webapp/crd/js/host_installer.js +++ b/remoting/webapp/crd/js/host_installer.js @@ -47,31 +47,32 @@ remoting.HostInstaller.isInstalled = function() { // Always do a fresh check as we don't get notified when the host is // uninstalled. - /** @param {function(*=):void} resolve */ - return new Promise(function(resolve) { - // TODO(kelvinp): Use different native messaging ports for the Me2me host - // vs It2MeHost. - /** @type {chrome.runtime.Port} */ - var port = - chrome.runtime.connectNative('com.google.chrome.remote_assistance'); - - function onMessage() { - port.onDisconnect.removeListener(onDisconnected); - port.onMessage.removeListener(onMessage); - port.disconnect(); - resolve(true); - } - - function onDisconnected() { - port.onDisconnect.removeListener(onDisconnected); - port.onMessage.removeListener(onMessage); - resolve(false); - } - - port.onDisconnect.addListener(onDisconnected); - port.onMessage.addListener(onMessage); - port.postMessage({type: 'hello'}); - }); + return new Promise( + /** @param {function(*=):void} resolve */ + function(resolve) { + // TODO(kelvinp): Use different native messaging ports for the Me2me + // host vs It2MeHost. + /** @type {chrome.runtime.Port} */ + var port = + chrome.runtime.connectNative('com.google.chrome.remote_assistance'); + + function onMessage() { + port.onDisconnect.removeListener(onDisconnected); + port.onMessage.removeListener(onMessage); + port.disconnect(); + resolve(true); + } + + function onDisconnected() { + port.onDisconnect.removeListener(onDisconnected); + port.onMessage.removeListener(onMessage); + resolve(false); + } + + port.onDisconnect.addListener(onDisconnected); + port.onMessage.addListener(onMessage); + port.postMessage({type: 'hello'}); + }); }; /** @type {Object<string,string>} */ diff --git a/remoting/webapp/unittests/spy_promise.js b/remoting/webapp/unittests/spy_promise.js index 3429d27..bb76799 100644 --- a/remoting/webapp/unittests/spy_promise.js +++ b/remoting/webapp/unittests/spy_promise.js @@ -245,7 +245,7 @@ base.SpyPromise.activate = function() { if (Promise === base.SpyPromise) { throw Error('base.SpyPromise is already active'); } - Promise = base.SpyPromise; + Promise = /** @type {function(new:Promise)} */(base.SpyPromise); }; /** @@ -291,4 +291,4 @@ base.SpyPromise.run = function(func, opt_timeoutMs) { }); } }; -})();
\ No newline at end of file +})(); |