Chromium Code Reviews| Index: mojo/public/dart/mojo/sdk_ext/src/natives.dart |
| diff --git a/mojo/public/dart/mojo/sdk_ext/src/natives.dart b/mojo/public/dart/mojo/sdk_ext/src/natives.dart |
| index 236069efdcbf3c431f211cf9714c88aab69983a3..a9ec169ab442a9319f3f5bc02182256c3f98dad5 100644 |
| --- a/mojo/public/dart/mojo/sdk_ext/src/natives.dart |
| +++ b/mojo/public/dart/mojo/sdk_ext/src/natives.dart |
| @@ -9,13 +9,39 @@ class MojoCoreNatives { |
| } |
| class MojoHandleNatives { |
| - static int register(Object eventStream, int handle) |
| - native "MojoHandle_Register"; |
| + static Set<int> _unclosedHandles = new Set<int>(); |
|
Cutch
2015/10/26 17:10:03
This is redundant with the code in handle.dart. We
zra
2015/10/26 17:53:54
Yah. This CL was getting big, so I'm going to do t
|
| + |
| + static void addUnclosed(int handle) { |
| + _unclosedHandles.add(handle); |
| + } |
| + |
| + static void removeUnclosed(int handle) { |
| + _unclosedHandles.remove(handle); |
| + } |
| + |
| + static int registerFinalizer(Object eventStream, int handle) |
| + native "MojoHandle_RegisterFinalizer"; |
| + |
| static int close(int handle) native "MojoHandle_Close"; |
| + |
| static List wait(int handle, int signals, int deadline) |
| native "MojoHandle_Wait"; |
| + |
| static List waitMany(List<int> handles, List<int> signals, int deadline) |
| native "MojoHandle_WaitMany"; |
| + |
| + // Called from the embedder's unhandled exception callback. |
| + // Returns the number of successfully closed handles. |
| + static int _closeUnclosedHandles() { |
| + int count = 0; |
| + _unclosedHandles.forEach((h) { |
| + if (MojoHandleNatives.close(h) == 0) { |
| + count++; |
| + } |
| + }); |
| + _unclosedHandles.clear(); |
| + return count; |
| + } |
| } |
| class MojoHandleWatcherNatives { |