| 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 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment; | 7 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment; |
| 8 | 8 |
| 9 const int kAlignment = 8; | 9 const int kAlignment = 8; |
| 10 const int kSerializedHandleSize = 4; | 10 const int kSerializedHandleSize = 4; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void encodeInterface( | 203 void encodeInterface( |
| 204 core.MojoEventStreamListener interface, int offset, bool nullable) { | 204 core.MojoEventStreamListener interface, int offset, bool nullable) { |
| 205 if (interface == null) { | 205 if (interface == null) { |
| 206 encodeInvalideHandle(offset, nullable); | 206 encodeInvalideHandle(offset, nullable); |
| 207 return; | 207 return; |
| 208 } | 208 } |
| 209 if (interface is Stub) { | 209 if (interface is Stub) { |
| 210 assert(!interface.isBound); | 210 assert(!interface.isBound); |
| 211 var pipe = new core.MojoMessagePipe(); | 211 var pipe = new core.MojoMessagePipe(); |
| 212 interface.bind(pipe.endpoints[0]); | 212 interface.bind(pipe.endpoints[0]); |
| 213 interface.listen(); |
| 213 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); | 214 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); |
| 214 } else if (interface is Proxy) { | 215 } else if (interface is Proxy) { |
| 215 assert(interface.isBound); | 216 assert(interface.isBound); |
| 216 if (!interface.isOpen) { | 217 if (!interface.isOpen) { |
| 217 // Make sure that we are listening so that state for the proxy is | 218 // Make sure that we are listening so that state for the proxy is |
| 218 // cleaned up when the message is sent and the handle is closed. | 219 // cleaned up when the message is sent and the handle is closed. |
| 219 interface.listen(); | 220 interface.listen(); |
| 220 } | 221 } |
| 221 encodeMessagePipeHandle(interface.endpoint, offset, nullable); | 222 encodeMessagePipeHandle(interface.endpoint, offset, nullable); |
| 222 } else { | 223 } else { |
| 223 throw new MojoCodecError( | 224 throw new MojoCodecError( |
| 224 'Trying to encode an unknown MojoEventStreamListener'); | 225 'Trying to encode an unknown MojoEventStreamListener'); |
| 225 } | 226 } |
| 226 } | 227 } |
| 227 | 228 |
| 228 void encodeInterfaceRequest(ProxyBase client, int offset, bool nullable) { | 229 void encodeInterfaceRequest(ProxyBase client, int offset, bool nullable) { |
| 229 if (client == null) { | 230 if (client == null) { |
| 230 encodeInvalideHandle(offset, nullable); | 231 encodeInvalideHandle(offset, nullable); |
| 231 return; | 232 return; |
| 232 } | 233 } |
| 233 var pipe = new core.MojoMessagePipe(); | 234 var pipe = new core.MojoMessagePipe(); |
| 234 client.impl.bind(pipe.endpoints[0]); | 235 client.impl.bind(pipe.endpoints[0]); |
| 236 client.impl.listen(); |
| 235 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); | 237 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); |
| 236 } | 238 } |
| 237 | 239 |
| 238 void encodeNullPointer(int offset, bool nullable) { | 240 void encodeNullPointer(int offset, bool nullable) { |
| 239 if (!nullable) { | 241 if (!nullable) { |
| 240 throw new MojoCodecError( | 242 throw new MojoCodecError( |
| 241 'Trying to encode a null pointer for a non-nullable type'); | 243 'Trying to encode a null pointer for a non-nullable type'); |
| 242 } | 244 } |
| 243 _buffer.buffer.setUint64(_base + offset, 0, Endianness.LITTLE_ENDIAN); | 245 _buffer.buffer.setUint64(_base + offset, 0, Endianness.LITTLE_ENDIAN); |
| 244 } | 246 } |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 throw new MojoCodecError( | 824 throw new MojoCodecError( |
| 823 'Incorrect header for map. The size is incorrect.'); | 825 'Incorrect header for map. The size is incorrect.'); |
| 824 } | 826 } |
| 825 if (header.version != kMapStructHeader.version) { | 827 if (header.version != kMapStructHeader.version) { |
| 826 throw new MojoCodecError( | 828 throw new MojoCodecError( |
| 827 'Incorrect header for map. The version is incorrect.'); | 829 'Incorrect header for map. The version is incorrect.'); |
| 828 } | 830 } |
| 829 return header; | 831 return header; |
| 830 } | 832 } |
| 831 } | 833 } |
| OLD | NEW |