Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: mojo/public/dart/src/data_pipe.dart

Issue 953953003: Introduce dartanalyze into our build. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 7
8 class _MojoDataPipeNatives { 8 class _MojoDataPipeNatives {
9 static List MojoCreateDataPipe( 9 static List MojoCreateDataPipe(
10 int elementBytes, int capacityBytes, int flags) 10 int elementBytes, int capacityBytes, int flags)
(...skipping 23 matching lines...) Expand all
34 static const int FLAG_NONE = 0; 34 static const int FLAG_NONE = 0;
35 static const int FLAG_ALL_OR_NONE = 1 << 0; 35 static const int FLAG_ALL_OR_NONE = 1 << 0;
36 36
37 MojoHandle handle; 37 MojoHandle handle;
38 MojoResult status; 38 MojoResult status;
39 final int elementBytes; 39 final int elementBytes;
40 40
41 MojoDataPipeProducer( 41 MojoDataPipeProducer(
42 this.handle, [this.status = MojoResult.OK, this.elementBytes = 1]); 42 this.handle, [this.status = MojoResult.OK, this.elementBytes = 1]);
43 43
44 int write(ByteData data, [int numBytes = -1, int flags = 0]) { 44 MojoResult write(ByteData data, [int numBytes = -1, int flags = 0]) {
45 if (handle == null) { 45 if (handle == null) {
46 status = MojoResult.INVALID_ARGUMENT; 46 status = MojoResult.INVALID_ARGUMENT;
47 return status; 47 return status;
48 } 48 }
49 49
50 int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes; 50 int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes;
51 List result = _MojoDataPipeNatives.MojoWriteData( 51 List result = _MojoDataPipeNatives.MojoWriteData(
52 handle.h, data, data_numBytes, flags); 52 handle.h, data, data_numBytes, flags);
53 if (result == null) { 53 if (result == null) {
54 status = MojoResult.INVALID_ARGUMENT; 54 status = MojoResult.INVALID_ARGUMENT;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 static const int FLAG_QUERY = 1 << 2; 97 static const int FLAG_QUERY = 1 << 2;
98 static const int FLAG_PEEK = 1 << 3; 98 static const int FLAG_PEEK = 1 << 3;
99 99
100 MojoHandle handle; 100 MojoHandle handle;
101 MojoResult status; 101 MojoResult status;
102 final int elementBytes; 102 final int elementBytes;
103 103
104 MojoDataPipeConsumer( 104 MojoDataPipeConsumer(
105 this.handle, [this.status = MojoResult.OK, this.elementBytes = 1]); 105 this.handle, [this.status = MojoResult.OK, this.elementBytes = 1]);
106 106
107 int read(ByteData data, [int numBytes = -1, int flags = 0]) { 107 MojoResult read(ByteData data, [int numBytes = -1, int flags = 0]) {
zra 2015/02/24 23:04:39 This should return the number of bytes read, so re
108 if (handle == null) { 108 if (handle == null) {
109 status = MojoResult.INVALID_ARGUMENT; 109 status = MojoResult.INVALID_ARGUMENT;
110 return status; 110 return status;
111 } 111 }
112 112
113 int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes; 113 int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes;
114 List result = _MojoDataPipeNatives.MojoReadData( 114 List result = _MojoDataPipeNatives.MojoReadData(
115 handle.h, data, data_numBytes, flags); 115 handle.h, data, data_numBytes, flags);
116 if (result == null) { 116 if (result == null) {
117 status = MojoResult.INVALID_ARGUMENT; 117 status = MojoResult.INVALID_ARGUMENT;
(...skipping 25 matching lines...) Expand all
143 MojoResult endRead(int bytesRead) { 143 MojoResult endRead(int bytesRead) {
144 if (handle == null) { 144 if (handle == null) {
145 status = MojoResult.INVALID_ARGUMENT; 145 status = MojoResult.INVALID_ARGUMENT;
146 return status; 146 return status;
147 } 147 }
148 int result = _MojoDataPipeNatives.MojoEndReadData(handle.h, bytesRead); 148 int result = _MojoDataPipeNatives.MojoEndReadData(handle.h, bytesRead);
149 status = new MojoResult(result); 149 status = new MojoResult(result);
150 return status; 150 return status;
151 } 151 }
152 152
153 int query() => read(null, 0, FLAG_QUERY); 153 MojoResult query() => read(null, 0, FLAG_QUERY);
zra 2015/02/24 23:04:39 back to int with fix to read.
154 } 154 }
155 155
156 156
157 class MojoDataPipe { 157 class MojoDataPipe {
158 static const int FLAG_NONE = 0; 158 static const int FLAG_NONE = 0;
159 static const int DEFAULT_ELEMENT_SIZE = 1; 159 static const int DEFAULT_ELEMENT_SIZE = 1;
160 static const int DEFAULT_CAPACITY = 0; 160 static const int DEFAULT_CAPACITY = 0;
161 161
162 MojoDataPipeProducer producer; 162 MojoDataPipeProducer producer;
163 MojoDataPipeConsumer consumer; 163 MojoDataPipeConsumer consumer;
(...skipping 18 matching lines...) Expand all
182 MojoHandle consumerHandle = new MojoHandle(result[2]); 182 MojoHandle consumerHandle = new MojoHandle(result[2]);
183 MojoDataPipe pipe = new MojoDataPipe._internal(); 183 MojoDataPipe pipe = new MojoDataPipe._internal();
184 pipe.producer = new MojoDataPipeProducer( 184 pipe.producer = new MojoDataPipeProducer(
185 producerHandle, new MojoResult(result[0]), elementBytes); 185 producerHandle, new MojoResult(result[0]), elementBytes);
186 pipe.consumer = new MojoDataPipeConsumer( 186 pipe.consumer = new MojoDataPipeConsumer(
187 consumerHandle, new MojoResult(result[0]), elementBytes); 187 consumerHandle, new MojoResult(result[0]), elementBytes);
188 pipe.status = new MojoResult(result[0]); 188 pipe.status = new MojoResult(result[0]);
189 return pipe; 189 return pipe;
190 } 190 }
191 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698