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

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

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Starting implementation Created 9 years, 2 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 | Annotate | Revision Log
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 23 matching lines...) Expand all
34 34
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 print("Event " + i);
44 var handleEvent = _handlerMap[i]; 45 var handleEvent = _handlerMap[i];
45 /* 46 /*
46 * Unregister the out handler before executing it. 47 * Unregister the out handler before executing it.
47 */ 48 */
48 if (i == _OUT_EVENT) { 49 if (i == _OUT_EVENT) {
49 _setHandler(i, null); 50 _setHandler(i, null);
50 } 51 }
51 handleEvent(); 52 handleEvent();
52 } 53 }
53 } 54 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 271
271 void setDataHandler(void callback()) { 272 void setDataHandler(void callback()) {
272 _setHandler(_IN_EVENT, callback); 273 _setHandler(_IN_EVENT, callback);
273 } 274 }
274 275
275 void setCloseHandler(void callback()) { 276 void setCloseHandler(void callback()) {
276 _setHandler(_CLOSE_EVENT, callback); 277 _setHandler(_CLOSE_EVENT, callback);
277 } 278 }
278 279
279 InputStream get inputStream() { 280 InputStream get inputStream() {
281 if (_inputStream2 != null) {
282 throw new SocketIOException("Illegal input stream use");
283 }
280 if (_inputStream === null) { 284 if (_inputStream === null) {
281 _inputStream = new SocketInputStream(this); 285 _inputStream = new SocketInputStream(this);
282 } 286 }
283 return _inputStream; 287 return _inputStream;
284 } 288 }
285 289
290 InputStream2 get inputStream2() {
291 if (_inputStream != null) {
292 throw new SocketIOException("Illegal input stream use");
293 }
294 if (_inputStream2 === null) {
295 _inputStream2 = new SocketInputStream2(this);
296 }
297 return _inputStream2;
298 }
299
286 OutputStream get outputStream() { 300 OutputStream get outputStream() {
287 if (_outputStream === null) { 301 if (_outputStream === null) {
288 _outputStream = new SocketOutputStream(this); 302 _outputStream = new SocketOutputStream(this);
289 } 303 }
290 return _outputStream; 304 return _outputStream;
291 } 305 }
292 306
293 SocketInputStream _inputStream; 307 SocketInputStream _inputStream;
308 SocketInputStream2 _inputStream2;
294 SocketOutputStream _outputStream; 309 SocketOutputStream _outputStream;
295 } 310 }
296 311
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698