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

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

Issue 10872033: Change getters syntax in dart:io library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « runtime/bin/socket.dart ('k') | runtime/bin/socket_stream_impl.dart » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class _SocketBase { 6 class _SocketBase {
7 // Bit flags used when communicating between the eventhandler and 7 // Bit flags used when communicating between the eventhandler and
8 // dart code. The EVENT flags are used to indicate events of 8 // dart code. The EVENT flags are used to indicate events of
9 // interest when sending a message from dart code to the 9 // interest when sending a message from dart code to the
10 // eventhandler. When receiving a message from the eventhandler the 10 // eventhandler. When receiving a message from the eventhandler the
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 data |= (1 << _LISTENING_SOCKET); 117 data |= (1 << _LISTENING_SOCKET);
118 } else { 118 } else {
119 if (_closedRead) { data &= ~(1 << _IN_EVENT); } 119 if (_closedRead) { data &= ~(1 << _IN_EVENT); }
120 if (_closedWrite) { data &= ~(1 << _OUT_EVENT); } 120 if (_closedWrite) { data &= ~(1 << _OUT_EVENT); }
121 if (_isPipe()) data |= (1 << _PIPE); 121 if (_isPipe()) data |= (1 << _PIPE);
122 } 122 }
123 _sendToEventHandler(data); 123 _sendToEventHandler(data);
124 } 124 }
125 } 125 }
126 126
127 int get port() { 127 int get port {
128 if (_port === null) { 128 if (_port === null) {
129 _port = _getPort(); 129 _port = _getPort();
130 } 130 }
131 return _port; 131 return _port;
132 } 132 }
133 133
134 void close([bool halfClose = false]) { 134 void close([bool halfClose = false]) {
135 if (_id >= 0) { 135 if (_id >= 0) {
136 if (halfClose) { 136 if (halfClose) {
137 _closeWrite(); 137 _closeWrite();
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 void set onClosed(void callback()) { 473 void set onClosed(void callback()) {
474 if (_inputStream != null) throw new StreamException( 474 if (_inputStream != null) throw new StreamException(
475 "Cannot set close handler when input stream is used"); 475 "Cannot set close handler when input stream is used");
476 _onClosed = callback; 476 _onClosed = callback;
477 } 477 }
478 478
479 bool _isListenSocket() => false; 479 bool _isListenSocket() => false;
480 480
481 bool _isPipe() => _pipe; 481 bool _isPipe() => _pipe;
482 482
483 InputStream get inputStream() { 483 InputStream get inputStream {
484 if (_inputStream == null) { 484 if (_inputStream == null) {
485 if (_handlerMap[_SocketBase._IN_EVENT] !== null || 485 if (_handlerMap[_SocketBase._IN_EVENT] !== null ||
486 _handlerMap[_SocketBase._CLOSE_EVENT] !== null) { 486 _handlerMap[_SocketBase._CLOSE_EVENT] !== null) {
487 throw new StreamException( 487 throw new StreamException(
488 "Cannot get input stream when socket handlers are used"); 488 "Cannot get input stream when socket handlers are used");
489 } 489 }
490 _inputStream = new SocketInputStream(this); 490 _inputStream = new SocketInputStream(this);
491 } 491 }
492 return _inputStream; 492 return _inputStream;
493 } 493 }
494 494
495 OutputStream get outputStream() { 495 OutputStream get outputStream {
496 if (_outputStream == null) { 496 if (_outputStream == null) {
497 if (_handlerMap[_SocketBase._OUT_EVENT] !== null) { 497 if (_handlerMap[_SocketBase._OUT_EVENT] !== null) {
498 throw new StreamException( 498 throw new StreamException(
499 "Cannot get input stream when socket handlers are used"); 499 "Cannot get input stream when socket handlers are used");
500 } 500 }
501 _outputStream = new SocketOutputStream(this); 501 _outputStream = new SocketOutputStream(this);
502 } 502 }
503 return _outputStream; 503 return _outputStream;
504 } 504 }
505 505
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 _onWrite = null; 549 _onWrite = null;
550 } else { 550 } else {
551 if (_seenFirstOutEvent) { 551 if (_seenFirstOutEvent) {
552 _onWrite = _clientWriteHandler; 552 _onWrite = _clientWriteHandler;
553 } else { 553 } else {
554 _onWrite = firstWriteHandler; 554 _onWrite = firstWriteHandler;
555 } 555 }
556 } 556 }
557 } 557 }
558 558
559 int get remotePort() { 559 int get remotePort {
560 if (_remotePort === null) { 560 if (_remotePort === null) {
561 remoteHost; 561 remoteHost;
562 } 562 }
563 return _remotePort; 563 return _remotePort;
564 } 564 }
565 565
566 String get remoteHost() { 566 String get remoteHost {
567 if (_remoteHost === null) { 567 if (_remoteHost === null) {
568 List peer = _getRemotePeer(); 568 List peer = _getRemotePeer();
569 _remoteHost = peer[0]; 569 _remoteHost = peer[0];
570 _remotePort = peer[1]; 570 _remotePort = peer[1];
571 } 571 }
572 return _remoteHost; 572 return _remoteHost;
573 } 573 }
574 574
575 List _getRemotePeer() native "Socket_GetRemotePeer"; 575 List _getRemotePeer() native "Socket_GetRemotePeer";
576 576
577 static SendPort _newServicePort() native "Socket_NewServicePort"; 577 static SendPort _newServicePort() native "Socket_NewServicePort";
578 578
579 static void _ensureSocketService() { 579 static void _ensureSocketService() {
580 if (_socketService == null) { 580 if (_socketService == null) {
581 _socketService = _Socket._newServicePort(); 581 _socketService = _Socket._newServicePort();
582 } 582 }
583 } 583 }
584 584
585 bool _seenFirstOutEvent = false; 585 bool _seenFirstOutEvent = false;
586 bool _pipe = false; 586 bool _pipe = false;
587 Function _clientConnectHandler; 587 Function _clientConnectHandler;
588 Function _clientWriteHandler; 588 Function _clientWriteHandler;
589 SocketInputStream _inputStream; 589 SocketInputStream _inputStream;
590 SocketOutputStream _outputStream; 590 SocketOutputStream _outputStream;
591 String _remoteHost; 591 String _remoteHost;
592 int _remotePort; 592 int _remotePort;
593 static SendPort _socketService; 593 static SendPort _socketService;
594 } 594 }
OLDNEW
« no previous file with comments | « runtime/bin/socket.dart ('k') | runtime/bin/socket_stream_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698