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/MojoResult.java

Issue 228723002: Java API for mojo system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding shared handle. Created 6 years, 8 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
Index: mojo/public/java/src/org/chromium/mojo/system/MojoResult.java
diff --git a/mojo/public/java/src/org/chromium/mojo/system/MojoResult.java b/mojo/public/java/src/org/chromium/mojo/system/MojoResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..9d1a8550c714aa233a0f0b27dcc15c78713fcd4c
--- /dev/null
+++ b/mojo/public/java/src/org/chromium/mojo/system/MojoResult.java
@@ -0,0 +1,66 @@
+// 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 java.util.HashMap;
+import java.util.Map;
+
+public enum MojoResult {
bulach 2014/04/14 17:39:56 enums are a no-go in java.. :(
qsr 2014/04/15 08:37:37 Not sure to understand. We are still supporting ja
+ OK(0),
+ CANCELLED(-1),
+ UNKNOWN(-2),
+ INVALID_ARGUMENT(-3),
+ DEADLINE_EXCEEDED(-4),
+ NOT_FOUND(-5),
+ ALREADY_EXISTS(-6),
+ PERMISSION_DENIED(-7),
+ RESOURCE_EXHAUSTED(-8),
+ FAILED_PRECONDITION(-9),
+ ABORTED(-10),
+ OUT_OF_RANGE(-11),
+ UNIMPLEMENTED(-12),
+ INTERNAL(-13),
+ UNAVAILABLE(-14),
+ DATA_LOSS(-15),
+ BUSY(-16),
+ SHOULD_WAIT(-17);
+
+ private static final Map<Integer, MojoResult> sMojoResultByCode =
+ new HashMap<Integer, MojoResult>();
+
+ static {
+ for (MojoResult mr : MojoResult.values()) {
+ MojoResult.sMojoResultByCode.put(mr.getCode(), mr);
+ }
+ }
+
+ private int mCode;
+
+ private MojoResult(int code) {
+ mCode = code;
+ }
+
+ public int getCode() {
+ return mCode;
+ }
+
+ /**
+ * TODO(qsr):
+ *
+ * @param code
+ * @return TODO(qsr)
+ */
+ public static MojoResult forCode(int code) {
+ // All positive codes are success.
+ if (code >= 0) {
+ return OK;
+ }
+ if (sMojoResultByCode.containsKey(code)) {
+ return sMojoResultByCode.get(code);
+ }
+ // Handle new result as unknown.
+ return UNKNOWN;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698