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

Side by Side Diff: mojo/dart/embedder/io/socket_patch.dart

Issue 1964193002: Dart: Refactors Proxies (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address comments Created 4 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // 5 //
6 // Implementation of Socket and RawSocket for Mojo. 6 // Implementation of Socket and RawSocket for Mojo.
7 // 7 //
8 8
9 patch class Socket { 9 patch class Socket {
10 /* patch */ static Future<Socket> connect(host, int port, {sourceAddress}) { 10 /* patch */ static Future<Socket> connect(host, int port, {sourceAddress}) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 _controller = new StreamController(sync: true, 143 _controller = new StreamController(sync: true,
144 onListen: _onSubscriptionStateChange, 144 onListen: _onSubscriptionStateChange,
145 onCancel: _onSubscriptionStateChange, 145 onCancel: _onSubscriptionStateChange,
146 onPause: _onPauseStateChange, 146 onPause: _onPauseStateChange,
147 onResume: _onPauseStateChange); 147 onResume: _onPauseStateChange);
148 } 148 }
149 149
150 static Future<_MojoRawSocket> _connect(NetAddress source, 150 static Future<_MojoRawSocket> _connect(NetAddress source,
151 NetAddress dest) async { 151 NetAddress dest) async {
152 var rawSocket = new _MojoRawSocket(); 152 var rawSocket = new _MojoRawSocket();
153 var networkService = _getNetworkService().ptr; 153 var networkService = _getNetworkService();
154 assert(networkService != null); 154 assert(networkService != null);
155 var response = 155 var response =
156 await networkService.createTcpBoundSocket(source, 156 await networkService.createTcpBoundSocket(source,
157 rawSocket._tcpBoundSocket); 157 rawSocket._tcpBoundSocket);
158 if (!_NetworkService._okay(response.result)) { 158 if (!_NetworkService._okay(response.result)) {
159 rawSocket.close(); 159 rawSocket.close();
160 _NetworkService._throwOnError(response.result); 160 _NetworkService._throwOnError(response.result);
161 } 161 }
162 162
163 rawSocket._traceBoundSocket(); 163 rawSocket._traceBoundSocket();
164 164
165 rawSocket._localAddress = 165 rawSocket._localAddress =
166 _NetworkServiceCodec._fromNetAddress(response.boundTo); 166 _NetworkServiceCodec._fromNetAddress(response.boundTo);
167 rawSocket._localPort = 167 rawSocket._localPort =
168 _NetworkServiceCodec._portFromNetAddress(response.boundTo); 168 _NetworkServiceCodec._portFromNetAddress(response.boundTo);
169 169
170 rawSocket._setupIn(); 170 rawSocket._setupIn();
171 rawSocket._setupOut(); 171 rawSocket._setupOut();
172 172
173 // connect here. 173 // connect here.
174 response = 174 response =
175 await rawSocket._tcpBoundSocket.ptr.connect( 175 await rawSocket._tcpBoundSocket.connect(
176 dest, 176 dest,
177 rawSocket._pipeOut.consumer, 177 rawSocket._pipeOut.consumer,
178 rawSocket._pipeIn.producer, 178 rawSocket._pipeIn.producer,
179 rawSocket._tcpConnectedSocket); 179 rawSocket._tcpConnectedSocket);
180 180
181 rawSocket._remoteAddress = _NetworkServiceCodec._fromNetAddress(dest); 181 rawSocket._remoteAddress = _NetworkServiceCodec._fromNetAddress(dest);
182 rawSocket._remotePort = _NetworkServiceCodec._portFromNetAddress(dest); 182 rawSocket._remotePort = _NetworkServiceCodec._portFromNetAddress(dest);
183 183
184 if (!_NetworkService._okay(response.result)) { 184 if (!_NetworkService._okay(response.result)) {
185 rawSocket.close(); 185 rawSocket.close();
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 if (_raw != null) { 808 if (_raw != null) {
809 _raw.shutdown(SocketDirection.SEND); 809 _raw.shutdown(SocketDirection.SEND);
810 _disableWriteEvent(); 810 _disableWriteEvent();
811 } 811 }
812 } 812 }
813 } 813 }
814 814
815 Map _toJSON(bool ref) => _raw._toJSON(ref); 815 Map _toJSON(bool ref) => _raw._toJSON(ref);
816 void set _owner(owner) { _raw._owner = owner; } 816 void set _owner(owner) { _raw._owner = owner; }
817 } 817 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698