| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 part of bindings; | 5 part of bindings; |
| 6 | 6 |
| 7 abstract class Stub extends core.MojoEventStreamListener { | 7 abstract class Stub extends core.MojoEventStreamListener { |
| 8 int _outstandingResponseFutures = 0; | 8 int _outstandingResponseFutures = 0; |
| 9 bool _isClosing = false; | 9 bool _isClosing = false; |
| 10 | 10 |
| 11 Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint, | 11 Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint) |
| 12 {bool doListen: true, Function onClosed}) | 12 : super.fromEndpoint(endpoint); |
| 13 : super.fromEndpoint(endpoint, doListen: doListen, onClosed: onClosed); | |
| 14 | 13 |
| 15 Stub.fromHandle(core.MojoHandle handle, | 14 Stub.fromHandle(core.MojoHandle handle) : super.fromHandle(handle); |
| 16 {bool doListen: true, Function onClosed}) | |
| 17 : super.fromHandle(handle, doListen: doListen, onClosed: onClosed); | |
| 18 | 15 |
| 19 Stub.unbound() : super.unbound(); | 16 Stub.unbound() : super.unbound(); |
| 20 | 17 |
| 21 Future<Message> handleMessage(ServiceMessage message); | 18 Future<Message> handleMessage(ServiceMessage message); |
| 22 | 19 |
| 23 void handleRead() { | 20 void handleRead() { |
| 24 // Query how many bytes are available. | 21 // Query how many bytes are available. |
| 25 var result = endpoint.query(); | 22 var result = endpoint.query(); |
| 26 assert(result.status.isOk || result.status.isResourceExhausted); | 23 assert(result.status.isOk || result.status.isResourceExhausted); |
| 27 if (result.bytesRead == 0) { | 24 if (result.bytesRead == 0) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Message buildResponseWithId(Struct response, int name, int id, int flags) { | 91 Message buildResponseWithId(Struct response, int name, int id, int flags) { |
| 95 var header = new MessageHeader.withRequestId(name, flags, id); | 92 var header = new MessageHeader.withRequestId(name, flags, id); |
| 96 return response.serializeWithHeader(header); | 93 return response.serializeWithHeader(header); |
| 97 } | 94 } |
| 98 | 95 |
| 99 String toString() { | 96 String toString() { |
| 100 var superString = super.toString(); | 97 var superString = super.toString(); |
| 101 return "Stub(${superString})"; | 98 return "Stub(${superString})"; |
| 102 } | 99 } |
| 103 } | 100 } |
| OLD | NEW |