| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_ANDROID_JNI_ARRAY_H_ | 5 #ifndef BASE_ANDROID_JNI_ARRAY_H_ |
| 6 #define BASE_ANDROID_JNI_ARRAY_H_ | 6 #define BASE_ANDROID_JNI_ARRAY_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stddef.h> |
| 9 #include <stdint.h> | 10 #include <stdint.h> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 namespace android { | 18 namespace android { |
| 18 | 19 |
| 19 // Returns a new Java byte array converted from the given bytes array. | 20 // Returns a new Java byte array converted from the given bytes array. |
| 20 BASE_EXPORT ScopedJavaLocalRef<jbyteArray> ToJavaByteArray(JNIEnv* env, | 21 BASE_EXPORT ScopedJavaLocalRef<jbyteArray> ToJavaByteArray(JNIEnv* env, |
| 21 const uint8_t* bytes, | 22 const uint8_t* bytes, |
| 22 size_t len); | 23 size_t len); |
| 23 | 24 |
| 24 BASE_EXPORT ScopedJavaLocalRef<jbyteArray> ToJavaByteArray( | 25 BASE_EXPORT ScopedJavaLocalRef<jbyteArray> ToJavaByteArray( |
| 25 JNIEnv* env, | 26 JNIEnv* env, |
| 26 const std::vector<uint8_t>& bytes); | 27 const std::vector<uint8_t>& bytes); |
| 27 | 28 |
| 28 // Returns a new Java int array converted from the given int array. | 29 // Returns a new Java int array converted from the given int array. |
| 29 BASE_EXPORT ScopedJavaLocalRef<jintArray> ToJavaIntArray( | 30 BASE_EXPORT ScopedJavaLocalRef<jintArray> ToJavaIntArray( |
| 30 JNIEnv* env, const int* ints, size_t len); | 31 JNIEnv* env, const int* ints, size_t len); |
| 31 | 32 |
| 32 BASE_EXPORT ScopedJavaLocalRef<jintArray> ToJavaIntArray( | 33 BASE_EXPORT ScopedJavaLocalRef<jintArray> ToJavaIntArray( |
| 33 JNIEnv* env, const std::vector<int>& ints); | 34 JNIEnv* env, const std::vector<int>& ints); |
| 34 | 35 |
| 35 // Returns a new Java long array converted from the given int64 array. | 36 // Returns a new Java long array converted from the given int64_t array. |
| 36 BASE_EXPORT ScopedJavaLocalRef<jlongArray> ToJavaLongArray(JNIEnv* env, | 37 BASE_EXPORT ScopedJavaLocalRef<jlongArray> ToJavaLongArray(JNIEnv* env, |
| 37 const int64_t* longs, | 38 const int64_t* longs, |
| 38 size_t len); | 39 size_t len); |
| 39 | 40 |
| 40 BASE_EXPORT ScopedJavaLocalRef<jlongArray> ToJavaLongArray( | 41 BASE_EXPORT ScopedJavaLocalRef<jlongArray> ToJavaLongArray( |
| 41 JNIEnv* env, | 42 JNIEnv* env, |
| 42 const std::vector<int64_t>& longs); | 43 const std::vector<int64_t>& longs); |
| 43 | 44 |
| 44 // Returns a array of Java byte array converted from |v|. | 45 // Returns a array of Java byte array converted from |v|. |
| 45 BASE_EXPORT ScopedJavaLocalRef<jobjectArray> ToJavaArrayOfByteArray( | 46 BASE_EXPORT ScopedJavaLocalRef<jobjectArray> ToJavaArrayOfByteArray( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // contents of |out| with the corresponding vectors of ints. | 108 // contents of |out| with the corresponding vectors of ints. |
| 108 BASE_EXPORT void JavaArrayOfIntArrayToIntVector( | 109 BASE_EXPORT void JavaArrayOfIntArrayToIntVector( |
| 109 JNIEnv* env, | 110 JNIEnv* env, |
| 110 jobjectArray array, | 111 jobjectArray array, |
| 111 std::vector<std::vector<int>>* out); | 112 std::vector<std::vector<int>>* out); |
| 112 | 113 |
| 113 } // namespace android | 114 } // namespace android |
| 114 } // namespace base | 115 } // namespace base |
| 115 | 116 |
| 116 #endif // BASE_ANDROID_JNI_ARRAY_H_ | 117 #endif // BASE_ANDROID_JNI_ARRAY_H_ |
| OLD | NEW |