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

Unified Diff: remoting/webapp/host_native_messaging.js

Issue 16236008: Send enums as strings between Chromoting Native Messaging host and web-app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move constants and fix loops Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/host_native_messaging.js
diff --git a/remoting/webapp/host_native_messaging.js b/remoting/webapp/host_native_messaging.js
index 8ed628c9120bc2309a0b779d0674673677b773b0..957e881a57ffb2dfc78b233b08c072f82185938d 100644
--- a/remoting/webapp/host_native_messaging.js
+++ b/remoting/webapp/host_native_messaging.js
@@ -109,13 +109,11 @@ function checkType_(name, object, type) {
* @return {remoting.HostController.AsyncResult?} Converted result.
*/
function asAsyncResult_(result) {
- if (!checkType_('result', result, 'number')) {
+ if (!checkType_('result', result, 'string')) {
return null;
}
- for (var i in remoting.HostController.AsyncResult) {
- if (remoting.HostController.AsyncResult[i] == result) {
- return remoting.HostController.AsyncResult[i];
- }
+ if (result in remoting.HostController.AsyncResult) {
+ return remoting.HostController.AsyncResult[result];
Sergey Ulanov 2013/05/31 23:01:43 nit: I would swap this block and the error case at
Lambros 2013/06/03 21:28:44 Done.
}
console.error('NativeMessaging: unexpected result code: ', result);
return null;
@@ -129,13 +127,11 @@ function asAsyncResult_(result) {
* @return {remoting.HostController.State?} Converted result.
*/
function asHostState_(result) {
- if (!checkType_('result', result, 'number')) {
+ if (!checkType_('result', result, 'string')) {
return null;
}
- for (var i in remoting.HostController.State) {
- if (remoting.HostController.State[i] == result) {
- return remoting.HostController.State[i];
- }
+ if (result in remoting.HostController.State) {
+ return remoting.HostController.State[result];
}
console.error('NativeMessaging: unexpected result code: ', result);
return null;

Powered by Google App Engine
This is Rietveld 408576698