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

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

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 years, 8 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 | « pkg/unittest/test/unittest_test.dart ('k') | runtime/lib/deferred_load_patch.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind([String address = "127.0.0.1", 6 /* patch */ static Future<RawServerSocket> bind([String address = "127.0.0.1",
7 int port = 0, 7 int port = 0,
8 int backlog = 0]) { 8 int backlog = 0]) {
9 return _RawServerSocket.bind(address, port, backlog); 9 return _RawServerSocket.bind(address, port, backlog);
10 } 10 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }); 108 });
109 return completer.future; 109 return completer.future;
110 } 110 }
111 111
112 static Future<_NativeSocket> bind(String address, 112 static Future<_NativeSocket> bind(String address,
113 int port, 113 int port,
114 int backlog) { 114 int backlog) {
115 var socket = new _NativeSocket.listen(); 115 var socket = new _NativeSocket.listen();
116 var result = socket.nativeCreateBindListen(address, port, backlog); 116 var result = socket.nativeCreateBindListen(address, port, backlog);
117 if (result is OSError) { 117 if (result is OSError) {
118 return new Future.immediateError( 118 return new Future.error(
119 new SocketIOException("Failed to create server socket", result)); 119 new SocketIOException("Failed to create server socket", result));
120 } 120 }
121 if (port != 0) socket.localPort = port; 121 if (port != 0) socket.localPort = port;
122 return new Future.immediate(socket); 122 return new Future.value(socket);
123 } 123 }
124 124
125 _NativeSocket.normal() : typeFlags = TYPE_NORMAL_SOCKET { 125 _NativeSocket.normal() : typeFlags = TYPE_NORMAL_SOCKET {
126 eventHandlers = new List(EVENT_COUNT + 1); 126 eventHandlers = new List(EVENT_COUNT + 1);
127 _EventHandler._start(); 127 _EventHandler._start();
128 } 128 }
129 129
130 _NativeSocket.listen() : typeFlags = TYPE_LISTENING_SOCKET { 130 _NativeSocket.listen() : typeFlags = TYPE_LISTENING_SOCKET {
131 eventHandlers = new List(EVENT_COUNT + 1); 131 eventHandlers = new List(EVENT_COUNT + 1);
132 _EventHandler._start(); 132 _EventHandler._start();
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 onDone: () { 692 onDone: () {
693 done(); 693 done();
694 }, 694 },
695 cancelOnError: true); 695 cancelOnError: true);
696 } 696 }
697 return streamCompleter.future; 697 return streamCompleter.future;
698 } 698 }
699 699
700 Future<Socket> close() { 700 Future<Socket> close() {
701 socket._consumerDone(); 701 socket._consumerDone();
702 return new Future.immediate(socket); 702 return new Future.value(socket);
703 } 703 }
704 704
705 void write() { 705 void write() {
706 try { 706 try {
707 if (subscription == null) return; 707 if (subscription == null) return;
708 assert(buffer != null); 708 assert(buffer != null);
709 // Write as much as possible. 709 // Write as much as possible.
710 offset += socket._write(buffer, offset, buffer.length - offset); 710 offset += socket._write(buffer, offset, buffer.length - offset);
711 if (offset < buffer.length) { 711 if (offset < buffer.length) {
712 if (!paused) { 712 if (!paused) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 _raw.onBadCertificate = callback; 947 _raw.onBadCertificate = callback;
948 } 948 }
949 949
950 X509Certificate get peerCertificate { 950 X509Certificate get peerCertificate {
951 if (_raw == null) { 951 if (_raw == null) {
952 throw new StateError("peerCertificate called on destroyed SecureSocket"); 952 throw new StateError("peerCertificate called on destroyed SecureSocket");
953 } 953 }
954 return _raw.peerCertificate; 954 return _raw.peerCertificate;
955 } 955 }
956 } 956 }
OLDNEW
« no previous file with comments | « pkg/unittest/test/unittest_test.dart ('k') | runtime/lib/deferred_load_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698