summaryrefslogtreecommitdiffstats
path: root/mojo/public/dart/src/handle_watcher.dart
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2014-11-21 17:51:49 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-22 01:52:09 +0000
commit46da0c1f3810737c10c40c64a244991509a15c0e (patch)
tree0924244effcc1e79054e65d6550706116124d4c8 /mojo/public/dart/src/handle_watcher.dart
parentfa8ed5bdb9f2f5f917a2e2d7adbf3ec9599f675e (diff)
downloadchromium_src-46da0c1f3810737c10c40c64a244991509a15c0e.zip
chromium_src-46da0c1f3810737c10c40c64a244991509a15c0e.tar.gz
chromium_src-46da0c1f3810737c10c40c64a244991509a15c0e.tar.bz2
Update mojo sdk to rev 5aa6dbdccf1950daf0cd3014bf763f35899bccf9
BUG=433814 Review URL: https://codereview.chromium.org/748113004 Cr-Commit-Position: refs/heads/master@{#305339}
Diffstat (limited to 'mojo/public/dart/src/handle_watcher.dart')
-rw-r--r--mojo/public/dart/src/handle_watcher.dart44
1 files changed, 30 insertions, 14 deletions
diff --git a/mojo/public/dart/src/handle_watcher.dart b/mojo/public/dart/src/handle_watcher.dart
index 47f3675..5f05654 100644
--- a/mojo/public/dart/src/handle_watcher.dart
+++ b/mojo/public/dart/src/handle_watcher.dart
@@ -103,12 +103,6 @@ class MojoHandleWatcher {
watcher._routeEvent(res);
// Remove the handle from the list.
watcher._removeHandle(handle);
- } else if (res == MojoResult.kFailedPrecondition) {
- // None of the handles can ever be satisfied, including the control
- // handle. This probably means we are going down. Clean up and
- // shutdown.
- watcher._pruneClosedHandles();
- watcher._shutdown = true;
} else {
// Some handle was closed, but not by us.
// We have to go through the list and find it.
@@ -159,7 +153,7 @@ class MojoHandleWatcher {
_close(result[0]);
break;
case SHUTDOWN:
- _shutdown = true;
+ _shutdownHandleWatcher();
break;
default:
throw new Exception("Invalid Command: $command");
@@ -204,7 +198,7 @@ class MojoHandleWatcher {
}
}
- void _close(int mojoHandle) {
+ void _close(int mojoHandle, {bool pruning : false}) {
int idx = _handleIndices[mojoHandle];
if (idx == null) {
throw new Exception("Close on a non-existent handle: idx = $idx.");
@@ -215,13 +209,19 @@ class MojoHandleWatcher {
_tempHandle.h = _handles[idx];
_tempHandle.close();
_tempHandle.h = RawMojoHandle.INVALID;
+ if (pruning) {
+ // If this handle is being pruned, notify the application isolate
+ // by sending MojoHandleSignals.NONE.
+ _ports[idx].send(MojoHandleSignals.NONE);
+ }
_removeHandle(mojoHandle);
}
void _toggleWrite(int mojoHandle) {
int idx = _handleIndices[mojoHandle];
if (idx == null) {
- throw new Exception("Toggle write on a non-existent handle: idx = $idx.");
+ throw new Exception(
+ "Toggle write on a non-existent handle: $mojoHandle.");
}
if (idx == 0) {
throw new Exception("The control handle (idx = 0) cannot be toggled.");
@@ -240,10 +240,17 @@ class MojoHandleWatcher {
_tempHandle.h = RawMojoHandle.INVALID;
}
for (var h in closed) {
- _close(h);
+ _close(h, pruning: true);
}
}
+ void _shutdownHandleWatcher() {
+ _shutdown = true;
+ _tempHandle.h = _controlHandle;
+ _tempHandle.close();
+ _tempHandle.h = RawMojoHandle.INVALID;
+ }
+
static MojoResult _sendControlData(RawMojoHandle mojoHandle,
SendPort port,
int data) {
@@ -251,14 +258,17 @@ class MojoHandleWatcher {
if (controlHandle == RawMojoHandle.INVALID) {
throw new Exception("Found invalid control handle");
}
+
+ int rawHandle = RawMojoHandle.INVALID;
+ if (mojoHandle != null) {
+ rawHandle = mojoHandle.h;
+ }
var result = _MojoHandleWatcherNatives.sendControlData(
- controlHandle, mojoHandle.h, port, data);
+ controlHandle, rawHandle, port, data);
return new MojoResult(result);
}
static Future<Isolate> Start() {
- // 5. Return Future<bool> giving true on success.
-
// Make a control message pipe,
MojoMessagePipe pipe = new MojoMessagePipe();
int consumerHandle = pipe.endpoints[0].handle.h;
@@ -275,7 +285,13 @@ class MojoHandleWatcher {
}
static void Stop() {
- _sendControlData(RawMojoHandle.INVALID, null, _encodeCommand(SHUTDOWN));
+ // Send the shutdown command.
+ _sendControlData(null, null, _encodeCommand(SHUTDOWN));
+
+ // Close the control handle.
+ int controlHandle = _MojoHandleWatcherNatives.getControlHandle();
+ var handle = new RawMojoHandle(controlHandle);
+ handle.close();
}
static MojoResult close(RawMojoHandle mojoHandle) {