| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 internal; | 5 part of internal; |
| 6 | 6 |
| 7 class MojoCoreNatives { | 7 class MojoCoreNatives { |
| 8 static int getTimeTicksNow() native "Mojo_GetTimeTicksNow"; | 8 static int getTimeTicksNow() native "Mojo_GetTimeTicksNow"; |
| 9 } | 9 } |
| 10 | 10 |
| 11 class MojoHandleNatives { | 11 class MojoHandleNatives { |
| 12 static int register(Object eventStream, int handle) | 12 static Set<int> _unclosedHandles = new Set<int>(); |
| 13 native "MojoHandle_Register"; | 13 |
| 14 static void addUnclosed(int handle) { |
| 15 _unclosedHandles.add(handle); |
| 16 } |
| 17 |
| 18 static void removeUnclosed(int handle) { |
| 19 _unclosedHandles.remove(handle); |
| 20 } |
| 21 |
| 22 static int registerFinalizer(Object eventStream, int handle) |
| 23 native "MojoHandle_RegisterFinalizer"; |
| 24 |
| 14 static int close(int handle) native "MojoHandle_Close"; | 25 static int close(int handle) native "MojoHandle_Close"; |
| 26 |
| 15 static List wait(int handle, int signals, int deadline) | 27 static List wait(int handle, int signals, int deadline) |
| 16 native "MojoHandle_Wait"; | 28 native "MojoHandle_Wait"; |
| 29 |
| 17 static List waitMany(List<int> handles, List<int> signals, int deadline) | 30 static List waitMany(List<int> handles, List<int> signals, int deadline) |
| 18 native "MojoHandle_WaitMany"; | 31 native "MojoHandle_WaitMany"; |
| 32 |
| 33 // Called from the embedder's unhandled exception callback. |
| 34 // Returns the number of successfully closed handles. |
| 35 static int _closeUnclosedHandles() { |
| 36 int count = 0; |
| 37 _unclosedHandles.forEach((h) { |
| 38 if (MojoHandleNatives.close(h) == 0) { |
| 39 count++; |
| 40 } |
| 41 }); |
| 42 _unclosedHandles.clear(); |
| 43 return count; |
| 44 } |
| 19 } | 45 } |
| 20 | 46 |
| 21 class MojoHandleWatcherNatives { | 47 class MojoHandleWatcherNatives { |
| 22 static int sendControlData( | 48 static int sendControlData( |
| 23 int controlHandle, int mojoHandle, SendPort port, int data) | 49 int controlHandle, int mojoHandle, SendPort port, int data) |
| 24 native "MojoHandleWatcher_SendControlData"; | 50 native "MojoHandleWatcher_SendControlData"; |
| 25 static List recvControlData(int controlHandle) | 51 static List recvControlData(int controlHandle) |
| 26 native "MojoHandleWatcher_RecvControlData"; | 52 native "MojoHandleWatcher_RecvControlData"; |
| 27 static int setControlHandle(int controlHandle) | 53 static int setControlHandle(int controlHandle) |
| 28 native "MojoHandleWatcher_SetControlHandle"; | 54 native "MojoHandleWatcher_SetControlHandle"; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 99 |
| 74 static List Duplicate(int bufferHandle, int flags) | 100 static List Duplicate(int bufferHandle, int flags) |
| 75 native "MojoSharedBuffer_Duplicate"; | 101 native "MojoSharedBuffer_Duplicate"; |
| 76 | 102 |
| 77 static List Map( | 103 static List Map( |
| 78 Object buffer, int bufferHandle, int offset, int numBytes, int flags) | 104 Object buffer, int bufferHandle, int offset, int numBytes, int flags) |
| 79 native "MojoSharedBuffer_Map"; | 105 native "MojoSharedBuffer_Map"; |
| 80 | 106 |
| 81 static int Unmap(ByteData buffer) native "MojoSharedBuffer_Unmap"; | 107 static int Unmap(ByteData buffer) native "MojoSharedBuffer_Unmap"; |
| 82 } | 108 } |
| OLD | NEW |