| 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, {bool doListen: true, | 11 Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint) |
| 12 Function onClosed}) | 12 : super.fromEndpoint(endpoint); |
| 13 : super.fromEndpoint(endpoint, doListen: doListen, onClosed: onClosed); | |
| 14 | 13 |
| 15 Stub.fromHandle(core.MojoHandle handle, {bool doListen: true, | 14 Stub.fromHandle(core.MojoHandle handle) |
| 16 Function onClosed}) | 15 : super.fromHandle(handle); |
| 17 : super.fromHandle(handle, doListen: doListen, onClosed: onClosed); | |
| 18 | 16 |
| 19 Stub.unbound() : super.unbound(); | 17 Stub.unbound() : super.unbound(); |
| 20 | 18 |
| 21 Future<Message> handleMessage(ServiceMessage message); | 19 Future<Message> handleMessage(ServiceMessage message); |
| 22 | 20 |
| 23 void handleRead() { | 21 void handleRead() { |
| 24 // Query how many bytes are available. | 22 // Query how many bytes are available. |
| 25 var result = endpoint.query(); | 23 var result = endpoint.query(); |
| 26 assert(result.status.isOk || result.status.isResourceExhausted); | 24 assert(result.status.isOk || result.status.isResourceExhausted); |
| 27 if (result.bytesRead == 0) { | 25 if (result.bytesRead == 0) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 Message buildResponse(Struct response, int name) { | 89 Message buildResponse(Struct response, int name) { |
| 92 var header = new MessageHeader(name); | 90 var header = new MessageHeader(name); |
| 93 return response.serializeWithHeader(header); | 91 return response.serializeWithHeader(header); |
| 94 } | 92 } |
| 95 | 93 |
| 96 Message buildResponseWithId(Struct response, int name, int id, int flags) { | 94 Message buildResponseWithId(Struct response, int name, int id, int flags) { |
| 97 var header = new MessageHeader.withRequestId(name, flags, id); | 95 var header = new MessageHeader.withRequestId(name, flags, id); |
| 98 return response.serializeWithHeader(header); | 96 return response.serializeWithHeader(header); |
| 99 } | 97 } |
| 100 } | 98 } |
| OLD | NEW |