Index: base/android/java/src/org/chromium/base/ParcelableChannelClient.java |
diff --git a/base/android/java/src/org/chromium/base/ParcelableChannelClient.java b/base/android/java/src/org/chromium/base/ParcelableChannelClient.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4fe1e446c77af6f499278c98b88dbe0a7f1c4c1c |
--- /dev/null |
+++ b/base/android/java/src/org/chromium/base/ParcelableChannelClient.java |
@@ -0,0 +1,36 @@ |
+// Copyright 2017 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.base; |
+ |
+import android.os.Parcelable; |
+import android.os.RemoteException; |
+ |
+import org.chromium.base.annotations.CalledByNative; |
+import org.chromium.base.annotations.JNINamespace; |
+ |
+/** |
+ * Wraps a IParcelableChannel so it can be called from native code. |
+ */ |
+@JNINamespace("base::android") |
+public final class ParcelableChannelClient { |
+ private static final String TAG = "ParcelableChanClient"; |
+ |
+ private IParcelableChannel mIParcelableChannel; |
+ |
+ public ParcelableChannelClient(IParcelableChannel parcelableChannel) { |
+ mIParcelableChannel = parcelableChannel; |
+ } |
+ |
+ @CalledByNative |
+ public boolean sendParcelable(int id, Parcelable parcelable) { |
+ try { |
+ mIParcelableChannel.sendParcelable(new ParcelableWrapper(id, parcelable)); |
+ return true; |
+ } catch (RemoteException e) { |
+ Log.e(TAG, "Failed to send parcelable.", e); |
+ return false; |
+ } |
+ } |
+} |