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

Unified Diff: runtime/bin/socket_patch.dart

Issue 14034012: Support upgrading sockets to secure sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/io/secure_socket.dart » ('j') | sdk/lib/io/secure_socket.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_patch.dart
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index 67fbadf2baccc4f624e793e3e07a65aa50f84d00..f5c302656fb05e324a09839d69dc364ef4875e31 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -771,6 +771,7 @@ class _Socket extends Stream<List<int>> implements Socket {
_SocketStreamConsumer _consumer;
IOSink _sink;
var _subscription;
+ var _detachReady;
_Socket(RawSocket this._raw) {
_controller = new StreamController<List<int>>(
@@ -851,6 +852,17 @@ class _Socket extends Stream<List<int>> implements Socket {
String get remoteHost => _raw.remoteHost;
int get remotePort => _raw.remotePort;
+ Future _detachRaw() {
+ _detachReady = new Completer();
+ _sink.close();
+ return _detachReady.future.then((_) {
+ assert(_consumer.buffer == null);
+ var raw = _raw;
+ _raw = null;
+ return [raw, _subscription];
+ });
+ }
+
// Ensure a subscription on the raw socket. Both the stream and the
// consumer needs a subscription as they share the error and done
// events from the raw socket.
@@ -938,9 +950,13 @@ class _Socket extends Stream<List<int>> implements Socket {
}
void _consumerDone() {
- if (_raw != null) {
- _raw.shutdown(SocketDirection.SEND);
- _disableWriteEvent();
+ if (_detachReady != null) {
+ _detachReady.complete(null);
+ } else {
+ if (_raw != null) {
+ _raw.shutdown(SocketDirection.SEND);
+ _disableWriteEvent();
+ }
}
}
}
« no previous file with comments | « no previous file | sdk/lib/io/secure_socket.dart » ('j') | sdk/lib/io/secure_socket.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698