| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.blimp.session; | |
| 6 | |
| 7 import org.chromium.base.annotations.CalledByNative; | |
| 8 import org.chromium.base.annotations.JNINamespace; | |
| 9 | |
| 10 /** | |
| 11 * The Java representation of a native BlimpClientSession. This is primarily us
ed to provide access | |
| 12 * to the native session methods and to facilitate passing a BlimpClientSession
object between Java | |
| 13 * classes with native counterparts. | |
| 14 */ | |
| 15 @JNINamespace("blimp::client") | |
| 16 public class BlimpClientSession { | |
| 17 private long mNativeBlimpClientSessionAndroidPtr; | |
| 18 | |
| 19 public BlimpClientSession() { | |
| 20 mNativeBlimpClientSessionAndroidPtr = nativeInit(); | |
| 21 } | |
| 22 | |
| 23 /** | |
| 24 * Destroys the native BlimpClientSession. This class should not be used af
ter this is called. | |
| 25 */ | |
| 26 public void destroy() { | |
| 27 if (mNativeBlimpClientSessionAndroidPtr == 0) return; | |
| 28 | |
| 29 nativeDestroy(mNativeBlimpClientSessionAndroidPtr); | |
| 30 mNativeBlimpClientSessionAndroidPtr = 0; | |
| 31 } | |
| 32 | |
| 33 // Methods that are called by native via JNI. | |
| 34 @CalledByNative | |
| 35 private long getNativePtr() { | |
| 36 assert mNativeBlimpClientSessionAndroidPtr != 0; | |
| 37 return mNativeBlimpClientSessionAndroidPtr; | |
| 38 } | |
| 39 | |
| 40 private native long nativeInit(); | |
| 41 private native void nativeDestroy(long nativeBlimpClientSessionAndroid); | |
| 42 } | |
| OLD | NEW |