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

Side by Side Diff: remoting/webapp/base/js/ipc.js

Issue 959963002: [Chromoting] Enable jscompile for webapp unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix key tester 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
« no previous file with comments | « remoting/webapp/base/js/auth_init.js ('k') | remoting/webapp/crd/html/template_unittest.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * 7 *
8 * In Chrome Apps, some platform APIs can only be called from the background 8 * In Chrome Apps, some platform APIs can only be called from the background
9 * page (e.g. reloading a chrome.app.AppWindow). Likewise, some chrome API's 9 * page (e.g. reloading a chrome.app.AppWindow). Likewise, some chrome API's
10 * must be initiated by user interaction, which can only be called from the 10 * must be initiated by user interaction, which can only be called from the
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 * @private 82 * @private
83 */ 83 */
84 base.Ipc.Request_ = function(methodName, params) { 84 base.Ipc.Request_ = function(methodName, params) {
85 this.methodName = methodName; 85 this.methodName = methodName;
86 this.params = params; 86 this.params = params;
87 }; 87 };
88 88
89 89
90 /** 90 /**
91 * @param {string} methodName 91 * @param {string} methodName
92 * @param {function(...?)} handler The handler can be invoked by calling 92 * @param {Function} handler The handler can be invoked by calling
93 * base.Ipc.invoke(|methodName|, arg1, arg2, ...) 93 * base.Ipc.invoke(|methodName|, arg1, arg2, ...)
94 * Async handlers that return promises are currently not supported. 94 * Async handlers that return promises are currently not supported.
95 * @return {boolean} Whether the handler is successfully registered. 95 * @return {boolean} Whether the handler is successfully registered.
96 */ 96 */
97 base.Ipc.prototype.register = function(methodName, handler) { 97 base.Ipc.prototype.register = function(methodName, handler) {
98 if (methodName in this.handlers_) { 98 if (methodName in this.handlers_) {
99 console.error('service ' + methodName + ' is already registered.'); 99 console.error('service ' + methodName + ' is already registered.');
100 return false; 100 return false;
101 } 101 }
102 this.handlers_[methodName] = handler; 102 this.handlers_[methodName] = handler;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } catch (/** @type {Error} */ e) { 138 } catch (/** @type {Error} */ e) {
139 sendResponse({error: e.message}); 139 sendResponse({error: e.message});
140 } 140 }
141 }; 141 };
142 142
143 /** 143 /**
144 * Invokes a method on a remote page 144 * Invokes a method on a remote page
145 * 145 *
146 * @param {string} methodName 146 * @param {string} methodName
147 * @param {...} var_args 147 * @param {...} var_args
148 * @return A Promise that would resolve to the return value of the handler or 148 * @return {Promise} A Promise that would resolve to the return value of the
149 * reject if the handler throws an exception. 149 * handler or reject if the handler throws an exception.
150 */ 150 */
151 base.Ipc.invoke = function(methodName, var_args) { 151 base.Ipc.invoke = function(methodName, var_args) {
152 var params = Array.prototype.slice.call(arguments, 1); 152 var params = Array.prototype.slice.call(arguments, 1);
153 var sendMessage = base.Promise.as( 153 var sendMessage = base.Promise.as(
154 chrome.runtime.sendMessage, 154 chrome.runtime.sendMessage,
155 [null, new base.Ipc.Request_(methodName, params)]); 155 [null, new base.Ipc.Request_(methodName, params)]);
156 156
157 return sendMessage.then( 157 return sendMessage.then(
158 /** @param {?{error: Error}} response */ 158 /** @param {?{error: Error}} response */
159 function(response) { 159 function(response) {
(...skipping 18 matching lines...) Expand all
178 }; 178 };
179 179
180 base.Ipc.deleteInstance = function() { 180 base.Ipc.deleteInstance = function() {
181 if (instance_) { 181 if (instance_) {
182 instance_.dispose_(); 182 instance_.dispose_();
183 instance_ = null; 183 instance_ = null;
184 } 184 }
185 }; 185 };
186 186
187 })(); 187 })();
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/auth_init.js ('k') | remoting/webapp/crd/html/template_unittest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698