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

Side by Side Diff: chrome_test/tcpapp/tcp.js

Issue 1415743013: Run jshint over all JavaScript files (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@repo_conf
Patch Set: Created 5 years, 1 month 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 | « chrome_test/chrome_test.js ('k') | chrome_test/tests/extension_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 'use strict'; 7 'use strict';
8 8
9 // This is the PPAPI code for TCP FIN (disconnected). 9 // This is the PPAPI code for TCP FIN (disconnected).
10 var ERROR_CODE_FIN = -100; 10 var ERROR_CODE_FIN = -100;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 }); 56 });
57 57
58 chrome.runtime.onConnectExternal.addListener(function(port) { 58 chrome.runtime.onConnectExternal.addListener(function(port) {
59 var tcp = chrome.sockets.tcp; 59 var tcp = chrome.sockets.tcp;
60 60
61 port.onMessage.addListener(function(msg) { 61 port.onMessage.addListener(function(msg) {
62 function resolve(data) { 62 function resolve(data) {
63 var response = { 63 var response = {
64 name: msg.name + '_reply', 64 name: msg.name + '_reply',
65 data: data || null 65 data: data || null
66 } 66 };
67 port.postMessage(response); 67 port.postMessage(response);
68 } 68 }
69 function reject(err) { 69 function reject(err) {
70 var response = { 70 var response = {
71 name: msg.name + '_error', 71 name: msg.name + '_error',
72 error: err || null 72 error: err || null
73 } 73 };
74 port.postMessage(response); 74 port.postMessage(response);
75 } 75 }
76 76
77 switch (msg.name) { 77 switch (msg.name) {
78 case 'tcp_connect': 78 case 'tcp_connect':
79 if (msg.addr === undefined || msg.port === undefined) { 79 if (msg.addr === undefined || msg.port === undefined) {
80 reject('"addr" and "port" fields expected'); 80 reject('"addr" and "port" fields expected');
81 break; 81 break;
82 } 82 }
83 tcp.create({}, function(createInfo) { 83 tcp.create({}, function(createInfo) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // O(N) time, but there's something wrong if there are enough TCP 127 // O(N) time, but there's something wrong if there are enough TCP
128 // connections that the performance of this loop matters. 128 // connections that the performance of this loop matters.
129 for (var socket in portMap) { 129 for (var socket in portMap) {
130 if (portMap[socket] === port) { 130 if (portMap[socket] === port) {
131 delete portMap[socket]; 131 delete portMap[socket];
132 tcp.close(parseInt(socket), function() {}); 132 tcp.close(parseInt(socket), function() {});
133 } 133 }
134 } 134 }
135 }); 135 });
136 }); 136 });
OLDNEW
« no previous file with comments | « chrome_test/chrome_test.js ('k') | chrome_test/tests/extension_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698