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 _MojoHandleNatives { | 7 class _MojoHandleNatives { |
8 static int register(MojoEventStream eventStream) native "MojoHandle_Register"; | 8 static int register(MojoEventStream eventStream) native "MojoHandle_Register"; |
9 static int close(int handle) native "MojoHandle_Close"; | 9 static int close(int handle) native "MojoHandle_Close"; |
10 static List wait( | 10 static List wait( |
(...skipping 26 matching lines...) Expand all Loading... |
37 switch (mwr.result) { | 37 switch (mwr.result) { |
38 case MojoResult.OK: | 38 case MojoResult.OK: |
39 return true; | 39 return true; |
40 case MojoResult.DEADLINE_EXCEEDED: | 40 case MojoResult.DEADLINE_EXCEEDED: |
41 case MojoResult.CANCELLED: | 41 case MojoResult.CANCELLED: |
42 case MojoResult.INVALID_ARGUMENT: | 42 case MojoResult.INVALID_ARGUMENT: |
43 case MojoResult.FAILED_PRECONDITION: | 43 case MojoResult.FAILED_PRECONDITION: |
44 return false; | 44 return false; |
45 default: | 45 default: |
46 // Should be unreachable. | 46 // Should be unreachable. |
47 throw "Unexpected result $res for wait on $h"; | 47 throw "Unexpected result $mwr for wait on $h"; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 bool get readyRead => _ready(MojoHandleSignals.PEER_CLOSED_READABLE); | 51 bool get readyRead => _ready(MojoHandleSignals.PEER_CLOSED_READABLE); |
52 bool get readyWrite => _ready(MojoHandleSignals.WRITABLE); | 52 bool get readyWrite => _ready(MojoHandleSignals.WRITABLE); |
53 | 53 |
54 static MojoWaitManyResult waitMany( | 54 static MojoWaitManyResult waitMany( |
55 List<int> handles, List<int> signals, int deadline) { | 55 List<int> handles, List<int> signals, int deadline) { |
56 List result = _MojoHandleNatives.waitMany(handles, signals, deadline); | 56 List result = _MojoHandleNatives.waitMany(handles, signals, deadline); |
57 return new MojoWaitManyResult( | 57 return new MojoWaitManyResult( |
(...skipping 11 matching lines...) Expand all Loading... |
69 return "MojoHandle(INVALID)"; | 69 return "MojoHandle(INVALID)"; |
70 } | 70 } |
71 var mwr = wait(MojoHandleSignals.kAll, 0); | 71 var mwr = wait(MojoHandleSignals.kAll, 0); |
72 return "MojoHandle(h: $h, status: $mwr)"; | 72 return "MojoHandle(h: $h, status: $mwr)"; |
73 } | 73 } |
74 | 74 |
75 bool operator ==(MojoHandle other) { | 75 bool operator ==(MojoHandle other) { |
76 return h == other.h; | 76 return h == other.h; |
77 } | 77 } |
78 } | 78 } |
OLD | NEW |