Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java

Issue 288993002: Add AsyncWaiter implementation to java API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding missing super calls. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/mojo.gyp ('k') | mojo/public/java/src/org/chromium/mojo/system/Core.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java
diff --git a/mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java b/mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java
new file mode 100644
index 0000000000000000000000000000000000000000..f62ac76a11b8623233d29e3a268a9d714aa6fa4a
--- /dev/null
+++ b/mojo/public/java/src/org/chromium/mojo/system/AsyncWaiter.java
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.mojo.system;
+
+import org.chromium.mojo.system.Core.WaitFlags;
+
+/**
+ * A class which implements the {@link AsyncWaiter} allows asynchronously waiting on a background
+ * thread.
+ */
+public interface AsyncWaiter {
+
+ /**
+ * Allows cancellation of an asyncWait operation.
+ */
+ interface Cancellable {
+ /**
+ * Cancels an asyncWait operation. Has no effect if the operation has already been canceled
+ * or the callback has already been called.
+ * <p>
+ * Must be called from the same thread as {@link AsyncWaiter#asyncWait} was called from.
+ */
+ void cancel();
+ }
+
+ /**
+ * Callback passed to {@link AsyncWaiter#asyncWait}.
+ */
+ public interface Callback {
+ /**
+ * Called when the handle is ready.
+ */
+ public void onResult(int result);
+
+ /**
+ * Called when an error occurred while waiting.
+ */
+ public void onError(MojoException exception);
+ }
+
+ /**
+ * Asynchronously call wait on a background thread. The given {@link Callback} will be notified
+ * of the result of the wait on the same thread as asyncWait was called.
+ *
+ * @return a {@link Cancellable} object that can be used to cancel waiting. The cancellable
+ * should only be used on the current thread, and becomes invalid once the callback has
+ * been notified.
+ */
+ Cancellable asyncWait(Handle handle, WaitFlags flags, long deadline, Callback callback);
+
+}
« no previous file with comments | « mojo/mojo.gyp ('k') | mojo/public/java/src/org/chromium/mojo/system/Core.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698