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

Side by Side Diff: runtime/bin/socket_impl.dart

Issue 8363044: Only call the dataReceived callback for sockets if there is actually data available (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /* 5 /*
6 * SocketNativeWrapper is defined in native and holds a field to store the 6 * SocketNativeWrapper is defined in native and holds a field to store the
7 * native socket object. 7 * native socket object.
8 */ 8 */
9 class _SocketBase { 9 class _SocketBase {
10 10
(...skipping 24 matching lines...) Expand all
35 /* 35 /*
36 * Multiplexes socket events to the right socket handler. 36 * Multiplexes socket events to the right socket handler.
37 */ 37 */
38 void _multiplex(List<int> message) { 38 void _multiplex(List<int> message) {
39 assert(message.length == 1); 39 assert(message.length == 1);
40 _canActivateHandlers = false; 40 _canActivateHandlers = false;
41 int event_mask = message[0]; 41 int event_mask = message[0];
42 for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) { 42 for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) {
43 if (((event_mask & (1 << i)) != 0) && _handlerMap[i] !== null) { 43 if (((event_mask & (1 << i)) != 0) && _handlerMap[i] !== null) {
44 var handleEvent = _handlerMap[i]; 44 var handleEvent = _handlerMap[i];
45 /* 45
46 * Unregister the out handler before executing it. 46 // Unregister the out handler before executing it.
47 */ 47 if (i == _OUT_EVENT) _setHandler(i, null);
48 if (i == _OUT_EVENT) { 48
49 _setHandler(i, null); 49 // Don't call the in handler if there is no data available
50 } 50 // after all.
51 if (i == _IN_EVENT && this is _Socket && available() == 0) continue;
52
51 handleEvent(); 53 handleEvent();
52 } 54 }
53 } 55 }
54 _canActivateHandlers = true; 56 _canActivateHandlers = true;
55 _doActivateHandlers(); 57 _doActivateHandlers();
56 } 58 }
57 59
58 void _setHandler(int event, void callback()) { 60 void _setHandler(int event, void callback()) {
59 if (callback === null) { 61 if (callback === null) {
60 _handlerMask &= ~(1 << event); 62 _handlerMask &= ~(1 << event);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 if (_outputStream == null) { 289 if (_outputStream == null) {
288 _outputStream = new SocketOutputStream(this); 290 _outputStream = new SocketOutputStream(this);
289 } 291 }
290 return _outputStream; 292 return _outputStream;
291 } 293 }
292 294
293 SocketInputStream _inputStream; 295 SocketInputStream _inputStream;
294 SocketOutputStream _outputStream; 296 SocketOutputStream _outputStream;
295 } 297 }
296 298
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698