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