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 Interface { | 7 abstract class Interface { |
8 core.MojoMessagePipeEndpoint _endpoint; | 8 core.MojoMessagePipeEndpoint _endpoint; |
9 core.MojoHandle _handle; | 9 core.MojoHandle _handle; |
10 List _sendQueue; | 10 List _sendQueue; |
(...skipping 12 matching lines...) Expand all Loading... |
23 var result = _endpoint.query(); | 23 var result = _endpoint.query(); |
24 if (!result.status.isOk && !result.status.isResourceExhausted) { | 24 if (!result.status.isOk && !result.status.isResourceExhausted) { |
25 // If something else happens, it means the handle wasn't really ready | 25 // If something else happens, it means the handle wasn't really ready |
26 // for reading, which indicates a bug in MojoHandle or the | 26 // for reading, which indicates a bug in MojoHandle or the |
27 // event listener. | 27 // event listener. |
28 throw new Exception("message pipe query failed: ${result.status}"); | 28 throw new Exception("message pipe query failed: ${result.status}"); |
29 } | 29 } |
30 | 30 |
31 // Read the data and view as a message. | 31 // Read the data and view as a message. |
32 var bytes = new ByteData(result.bytesRead); | 32 var bytes = new ByteData(result.bytesRead); |
33 var handles = new List<RawMojoHandle>(result.handlesRead); | 33 var handles = new List<core.RawMojoHandle>(result.handlesRead); |
34 result = _endpoint.read(bytes, result.bytesRead, handles); | 34 result = _endpoint.read(bytes, result.bytesRead, handles); |
35 if (!result.status.isOk && !result.status.isResourceExhausted) { | 35 if (!result.status.isOk && !result.status.isResourceExhausted) { |
36 // If something else happens, it means the handle wasn't really ready | 36 // If something else happens, it means the handle wasn't really ready |
37 // for reading, which indicates a bug in MojoHandle or the | 37 // for reading, which indicates a bug in MojoHandle or the |
38 // event listener. | 38 // event listener. |
39 throw new Exception("message pipe read failed: ${result.status}"); | 39 throw new Exception("message pipe read failed: ${result.status}"); |
40 } | 40 } |
41 var message = new Message(bytes, handles); | 41 var message = new Message(bytes, handles); |
42 var reader = new MessageReader(message); | 42 var reader = new MessageReader(message); |
43 | 43 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return builder.finish(); | 77 return builder.finish(); |
78 } | 78 } |
79 | 79 |
80 Message buildResponseWithID(Type t, int name, int id, Object response) { | 80 Message buildResponseWithID(Type t, int name, int id, Object response) { |
81 var builder = new MessageWithRequestIDBuilder( | 81 var builder = new MessageWithRequestIDBuilder( |
82 name, align(getEncodedSize(t)), id); | 82 name, align(getEncodedSize(t)), id); |
83 builder.encodeStruct(t, response); | 83 builder.encodeStruct(t, response); |
84 return builder.finish(); | 84 return builder.finish(); |
85 } | 85 } |
86 } | 86 } |
OLD | NEW |