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

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

Issue 830593003: Update mojo sdk to rev 9fbbc4f0fef1187312316c0ed992342474e139f1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cherry-pick mojo 9d3b8dd17f12d20035a14737fdc38dd926890ff8 Created 5 years, 11 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 5
6 part of core; 6 part of core;
7 7
8 8
9 class MojoResult { 9 class MojoResult {
10 static const int kOk = 0; 10 static const int kOk = 0;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 case kResourceExhausted: return RESOURCE_EXHAUSTED; 62 case kResourceExhausted: return RESOURCE_EXHAUSTED;
63 case kFailedPrecondition: return FAILED_PRECONDITION; 63 case kFailedPrecondition: return FAILED_PRECONDITION;
64 case kAborted: return ABORTED; 64 case kAborted: return ABORTED;
65 case kOutOfRange: return OUT_OF_RANGE; 65 case kOutOfRange: return OUT_OF_RANGE;
66 case kUnimplemented: return UNIMPLEMENTED; 66 case kUnimplemented: return UNIMPLEMENTED;
67 case kInternal: return INTERNAL; 67 case kInternal: return INTERNAL;
68 case kUnavailable: return UNAVAILABLE; 68 case kUnavailable: return UNAVAILABLE;
69 case kDataLoss: return DATA_LOSS; 69 case kDataLoss: return DATA_LOSS;
70 case kBusy: return BUSY; 70 case kBusy: return BUSY;
71 case kShouldWait: return SHOULD_WAIT; 71 case kShouldWait: return SHOULD_WAIT;
72 default: return null; 72 default:
73 throw 'Invalid Mojo result';
73 } 74 }
74 } 75 }
75 76
76 bool get isOk => (this == OK); 77 bool get isOk => (this == OK);
77 bool get isCancelled => (this == CANCELLED); 78 bool get isCancelled => (this == CANCELLED);
78 bool get isUnknown => (this == UNKNOWN); 79 bool get isUnknown => (this == UNKNOWN);
79 bool get isInvalidArgument => (this == INVALID_ARGUMENT); 80 bool get isInvalidArgument => (this == INVALID_ARGUMENT);
80 bool get isDeadlineExceeded => (this == DEADLINE_EXCEEDED); 81 bool get isDeadlineExceeded => (this == DEADLINE_EXCEEDED);
81 bool get isNotFound => (this == NOT_FOUND); 82 bool get isNotFound => (this == NOT_FOUND);
82 bool get isAlreadExists => (this == ALREADY_EXISTS); 83 bool get isAlreadExists => (this == ALREADY_EXISTS);
(...skipping 29 matching lines...) Expand all
112 case kDataLoss: return "DATA_LOSS"; 113 case kDataLoss: return "DATA_LOSS";
113 case kBusy: return "BUSY"; 114 case kBusy: return "BUSY";
114 case kShouldWait: return "SHOULD_WAIT"; 115 case kShouldWait: return "SHOULD_WAIT";
115 default: return "<invalid result>"; 116 default: return "<invalid result>";
116 } 117 }
117 } 118 }
118 } 119 }
119 120
120 121
121 class MojoHandleSignals { 122 class MojoHandleSignals {
122 static const int NONE = 0; 123 static const int kNone = 0;
123 static const int READABLE = 1 << 0; 124 static const int kReadable = 1 << 0;
124 static const int WRITABLE = 1 << 1; 125 static const int kWritable = 1 << 1;
125 static const int PEER_CLOSED = 1 << 2; 126 static const int kPeerClosed = 1 << 2;
126 static const int READWRITE = READABLE | WRITABLE; 127 static const int kReadWrite = kReadable | kWritable;
128 static const int kAll = kReadable | kWritable | kPeerClosed;
127 129
128 static bool isNone(int mask) => mask == NONE; 130 // TODO(zra): Does PEER_CLOSED | anything else make sense?
129 static bool isReadable(int mask) => (mask & READABLE) == READABLE; 131 static const NONE = const MojoHandleSignals._(kNone);
130 static bool isWritable(int mask) => (mask & WRITABLE) == WRITABLE; 132 static const READABLE = const MojoHandleSignals._(kReadable);
131 static bool isReadWrite(int mask) => (mask & READWRITE) == READWRITE; 133 static const WRITABLE = const MojoHandleSignals._(kWritable);
132 static int toggleWrite(int mask) => 134 static const PEER_CLOSED = const MojoHandleSignals._(kPeerClosed);
133 isWritable(mask) ? (mask & ~WRITABLE) : (mask | WRITABLE); 135 static const READWRITE = const MojoHandleSignals._(kReadWrite);
136 static const ALL = const MojoHandleSignals._(kAll);
137
138 final int value;
139
140 const MojoHandleSignals._(this.value);
141
142 factory MojoHandleSignals(int value) {
143 switch (value) {
144 case kNone: return NONE;
145 case kReadable: return READABLE;
146 case kWritable: return WRITABLE;
147 case kPeerClosed: return PEER_CLOSED;
148 case kReadWrite: return READWRITE;
149 case kAll: return ALL;
150 default:
151 throw 'Invalid handle signal';
152 }
153 }
154
155 bool get isNone => (this == NONE);
156 bool get isReadable => (value & kReadable) == kReadable;
157 bool get isWritable => (value & kWritable) == kWritable;
158 bool get isPeerClosed => (value & kPeerClosed) == kPeerClosed;
159 bool get isReadWrite => (value & kReadWrite) == kReadWrite;
160 bool get isAll => (this == ALL);
161
162 MojoHandleSignals operator +(MojoHandleSignals other) {
163 return new MojoHandleSignals(value | other.value);
164 }
165
166 MojoHandleSignals operator -(MojoHandleSignals other) {
167 return new MojoHandleSignals(value & ~other.value);
168 }
169
170 String toString() {
171 switch (value) {
172 case kNone: return "NONE";
173 case kReadable: return "READABLE";
174 case kWritable: return "WRITABLE";
175 case kPeerClosed: return "PEER_CLOSED";
176 case kReadWrite: return "READWRITE";
177 case kAll: return "ALL";
178 default: return "<invalid signal>";
179 }
180 }
134 } 181 }
135 182
136 183
137 class MojoHandleSignalsState { 184 class MojoHandleSignalsState {
138 const MojoHandleSignalsState(this.satisfied_signals, 185 MojoHandleSignalsState(this.satisfied_signals,
139 this.satisfiable_signals); 186 this.satisfiable_signals);
140 final int satisfied_signals; 187 final int satisfied_signals;
141 final int satisfiable_signals; 188 final int satisfiable_signals;
142 } 189 }
190
191
192 class MojoWaitResult {
193 MojoWaitResult(this.result, this.state);
194 final MojoResult result;
195 MojoHandleSignalsState state;
196 }
197
198
199 class MojoWaitManyResult {
200 MojoWaitManyResult(this.result, this.index, this.states);
201 final MojoResult result;
202 final int index;
203 List<MojoHandleSignalsState> states;
204
205 bool get isIndexValid => (this.index != null);
206 bool get areSignalStatesValid => (this.states != null);
207 }
OLDNEW
« no previous file with comments | « mojo/public/dart/src/timer_queue.dart ('k') | mojo/public/interfaces/bindings/tests/test_unions.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698