| 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 core; | 5 part of core; |
| 6 | 6 |
| 7 class _MojoDataPipeNatives { | 7 class _MojoDataPipeNatives { |
| 8 static List MojoCreateDataPipe(int elementBytes, int capacityBytes, | 8 static List MojoCreateDataPipe(int elementBytes, int capacityBytes, |
| 9 int flags) native "MojoDataPipe_Create"; | 9 int flags) native "MojoDataPipe_Create"; |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 MojoHandle handle; | 34 MojoHandle handle; |
| 35 MojoResult status; | 35 MojoResult status; |
| 36 final int elementBytes; | 36 final int elementBytes; |
| 37 | 37 |
| 38 MojoDataPipeProducer(this.handle, | 38 MojoDataPipeProducer(this.handle, |
| 39 [this.status = MojoResult.OK, this.elementBytes = 1]); | 39 [this.status = MojoResult.OK, this.elementBytes = 1]); |
| 40 | 40 |
| 41 int write(ByteData data, [int numBytes = -1, int flags = 0]) { | 41 int write(ByteData data, [int numBytes = -1, int flags = 0]) { |
| 42 if (handle == null) { | 42 if (handle == null) { |
| 43 status = MojoResult.INVALID_ARGUMENT; | 43 status = MojoResult.INVALID_ARGUMENT; |
| 44 return status; | 44 return 0; |
| 45 } | 45 } |
| 46 | 46 |
| 47 int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes; | 47 int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes; |
| 48 List result = _MojoDataPipeNatives.MojoWriteData( | 48 List result = _MojoDataPipeNatives.MojoWriteData( |
| 49 handle.h, data, data_numBytes, flags); | 49 handle.h, data, data_numBytes, flags); |
| 50 if (result == null) { | 50 if (result == null) { |
| 51 status = MojoResult.INVALID_ARGUMENT; | 51 status = MojoResult.INVALID_ARGUMENT; |
| 52 return status; | 52 return 0; |
| 53 } | 53 } |
| 54 | 54 |
| 55 assert((result is List) && (result.length == 2)); | 55 assert((result is List) && (result.length == 2)); |
| 56 status = new MojoResult(result[0]); | 56 status = new MojoResult(result[0]); |
| 57 return result[1]; | 57 return result[1]; |
| 58 } | 58 } |
| 59 | 59 |
| 60 ByteData beginWrite(int bufferBytes, [int flags = 0]) { | 60 ByteData beginWrite(int bufferBytes, [int flags = 0]) { |
| 61 if (handle == null) { | 61 if (handle == null) { |
| 62 status = MojoResult.INVALID_ARGUMENT; | 62 status = MojoResult.INVALID_ARGUMENT; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 MojoHandle consumerHandle = new MojoHandle(result[2]); | 181 MojoHandle consumerHandle = new MojoHandle(result[2]); |
| 182 MojoDataPipe pipe = new MojoDataPipe._internal(); | 182 MojoDataPipe pipe = new MojoDataPipe._internal(); |
| 183 pipe.producer = new MojoDataPipeProducer( | 183 pipe.producer = new MojoDataPipeProducer( |
| 184 producerHandle, new MojoResult(result[0]), elementBytes); | 184 producerHandle, new MojoResult(result[0]), elementBytes); |
| 185 pipe.consumer = new MojoDataPipeConsumer( | 185 pipe.consumer = new MojoDataPipeConsumer( |
| 186 consumerHandle, new MojoResult(result[0]), elementBytes); | 186 consumerHandle, new MojoResult(result[0]), elementBytes); |
| 187 pipe.status = new MojoResult(result[0]); | 187 pipe.status = new MojoResult(result[0]); |
| 188 return pipe; | 188 return pipe; |
| 189 } | 189 } |
| 190 } | 190 } |
| OLD | NEW |