| 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(MojoHandle handle) native "MojoHandle_Register"; | 8 static int register(MojoHandle handle) native "MojoHandle_Register"; |
| 9 static int close(int handle) native "MojoHandle_Close"; | 9 static int close(int handle) native "MojoHandle_Close"; |
| 10 static int wait(int handle, int signals, int deadline) | 10 static int wait(int handle, int signals, int deadline) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // The receive port on which we listen and receive events from the handle | 92 // The receive port on which we listen and receive events from the handle |
| 93 // watcher. | 93 // watcher. |
| 94 ReceivePort _receivePort; | 94 ReceivePort _receivePort; |
| 95 | 95 |
| 96 // The signals on this handle that we're interested in. | 96 // The signals on this handle that we're interested in. |
| 97 int _signals; | 97 int _signals; |
| 98 | 98 |
| 99 // Whether the handle has been added to the handle watcher. | 99 // Whether the handle has been added to the handle watcher. |
| 100 bool _eventHandlerAdded; | 100 bool _eventHandlerAdded; |
| 101 | 101 |
| 102 MojoHandle(this._handle) : | 102 MojoHandle(this._handle) : |
| 103 _signals = MojoHandleSignals.READABLE, | 103 _signals = MojoHandleSignals.READABLE, |
| 104 _eventHandlerAdded = false { | 104 _eventHandlerAdded = false { |
| 105 MojoResult result = RawMojoHandle.register(this); | 105 MojoResult result = RawMojoHandle.register(this); |
| 106 if (!result.isOk) { | 106 if (!result.isOk) { |
| 107 throw new Exception("Failed to register the MojoHandle"); | 107 throw new Exception("Failed to register the MojoHandle"); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 void close() { | 111 void close() { |
| 112 if (_eventHandlerAdded) { | 112 if (_eventHandlerAdded) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 if (!res.isOk) { | 213 if (!res.isOk) { |
| 214 throw new Exception("MojoHandleWatcher add failed: $res"); | 214 throw new Exception("MojoHandleWatcher add failed: $res"); |
| 215 } | 215 } |
| 216 _eventHandlerAdded = true; | 216 _eventHandlerAdded = true; |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 String toString() => "$_handle"; | 221 String toString() => "$_handle"; |
| 222 } | 222 } |
| OLD | NEW |