| 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) => | 7 int align(int size) => |
| 8 size + ((kAlignment - (size & kAlignmentMask)) & kAlignmentMask); | 8 size + ((kAlignment - (size & kAlignmentMask)) & kAlignmentMask); |
| 9 | 9 |
| 10 const int kAlignment = 8; | 10 const int kAlignment = 8; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 void encodeInterface( | 212 void encodeInterface( |
| 213 Object interface, int offset, bool nullable) { | 213 Object interface, int offset, bool nullable) { |
| 214 if (interface == null) { | 214 if (interface == null) { |
| 215 encodeInvalideHandle(offset, nullable); | 215 encodeInvalideHandle(offset, nullable); |
| 216 // Set the version field to 0. | 216 // Set the version field to 0. |
| 217 encodeUint32(0, offset + kSerializedHandleSize); | 217 encodeUint32(0, offset + kSerializedHandleSize); |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 if (interface is Stub) { | 220 if (interface is Stub) { |
| 221 if (interface.isBound) { | 221 if (interface.ctrl.isBound) { |
| 222 throw new MojoCodecError( | 222 throw new MojoCodecError( |
| 223 'Cannot encode a bound stub for an interface'); | 223 'Cannot encode a bound stub for an interface'); |
| 224 } | 224 } |
| 225 var pipe = new core.MojoMessagePipe(); | 225 var pipe = new core.MojoMessagePipe(); |
| 226 interface.bind(pipe.endpoints[0]); | 226 interface.ctrl.bind(pipe.endpoints[0]); |
| 227 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); | 227 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); |
| 228 // Set the version to the version in the stub. | 228 // Set the version to the version in the stub. |
| 229 encodeUint32(interface.version, offset + kSerializedHandleSize); | 229 encodeUint32(interface.ctrl.version, offset + kSerializedHandleSize); |
| 230 } else if (interface is Proxy) { | 230 } else if (interface is Proxy) { |
| 231 if (!interface.ctrl.isBound) { | 231 if (!interface.ctrl.isBound) { |
| 232 throw new MojoCodecError( | 232 throw new MojoCodecError( |
| 233 'Cannot encode an unbound proxy for an interface'); | 233 'Cannot encode an unbound proxy for an interface'); |
| 234 } | 234 } |
| 235 if (!interface.ctrl.isOpen) { | 235 if (!interface.ctrl.isOpen) { |
| 236 // Make sure that we are listening so that state for the proxy is | 236 // Make sure that we are listening so that state for the proxy is |
| 237 // cleaned up when the message is sent and the handle is closed. | 237 // cleaned up when the message is sent and the handle is closed. |
| 238 interface.ctrl.beginHandlingEvents(); | 238 interface.ctrl.beginHandlingEvents(); |
| 239 } | 239 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 253 if (request is Proxy) { | 253 if (request is Proxy) { |
| 254 if (request.ctrl.isBound) { | 254 if (request.ctrl.isBound) { |
| 255 throw new MojoCodecError( | 255 throw new MojoCodecError( |
| 256 'Cannot encode a bound proxy for an interface request'); | 256 'Cannot encode a bound proxy for an interface request'); |
| 257 } | 257 } |
| 258 var pipe = new core.MojoMessagePipe(); | 258 var pipe = new core.MojoMessagePipe(); |
| 259 request.ctrl.bind(pipe.endpoints[0]); | 259 request.ctrl.bind(pipe.endpoints[0]); |
| 260 request.ctrl.beginHandlingEvents(); | 260 request.ctrl.beginHandlingEvents(); |
| 261 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); | 261 encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable); |
| 262 } else if (request is Stub) { | 262 } else if (request is Stub) { |
| 263 if (!request.isBound) { | 263 if (!request.ctrl.isBound) { |
| 264 throw new MojoCodecError( | 264 throw new MojoCodecError( |
| 265 'Cannot encode an unbound stub for an interface request'); | 265 'Cannot encode an unbound stub for an interface request'); |
| 266 } | 266 } |
| 267 if (!request.isOpen) { | 267 if (!request.ctrl.isOpen) { |
| 268 // Make sure that we are listening so that state for the stub is | 268 // Make sure that we are listening so that state for the stub is |
| 269 // cleaned up when the message is sent and the handle is closed. | 269 // cleaned up when the message is sent and the handle is closed. |
| 270 request.beginHandlingEvents(); | 270 request.ctrl.beginHandlingEvents(); |
| 271 } | 271 } |
| 272 encodeMessagePipeHandle(request.endpoint, offset, nullable); | 272 encodeMessagePipeHandle(request.ctrl.endpoint, offset, nullable); |
| 273 // Set the version to the current version of the stub. | 273 // Set the version to the current version of the stub. |
| 274 encodeUint32(request.version, offset + kSerializedHandleSize); | 274 encodeUint32(request.ctrl.version, offset + kSerializedHandleSize); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 void encodeNullPointer(int offset, bool nullable) { | 278 void encodeNullPointer(int offset, bool nullable) { |
| 279 if (!nullable) { | 279 if (!nullable) { |
| 280 throw new MojoCodecError( | 280 throw new MojoCodecError( |
| 281 'Cannot encode a null pointer for a non-nullable type'); | 281 'Cannot encode a null pointer for a non-nullable type'); |
| 282 } | 282 } |
| 283 _buffer.buffer.setUint64(_base + offset, 0, Endianness.LITTLE_ENDIAN); | 283 _buffer.buffer.setUint64(_base + offset, 0, Endianness.LITTLE_ENDIAN); |
| 284 } | 284 } |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 throw new MojoCodecError( | 1124 throw new MojoCodecError( |
| 1125 'Incorrect header for map. The size is incorrect.'); | 1125 'Incorrect header for map. The size is incorrect.'); |
| 1126 } | 1126 } |
| 1127 if (header.version != kMapStructHeader.version) { | 1127 if (header.version != kMapStructHeader.version) { |
| 1128 throw new MojoCodecError( | 1128 throw new MojoCodecError( |
| 1129 'Incorrect header for map. The version is incorrect.'); | 1129 'Incorrect header for map. The version is incorrect.'); |
| 1130 } | 1130 } |
| 1131 return header; | 1131 return header; |
| 1132 } | 1132 } |
| 1133 } | 1133 } |
| OLD | NEW |