OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/basictypes.h" |
| 14 |
12 namespace base { | 15 namespace base { |
13 namespace android { | 16 namespace android { |
14 | 17 |
15 // Returns a new Java byte array converted from the given bytes array. | 18 // Returns a new Java byte array converted from the given bytes array. |
16 jbyteArray ToJavaByteArray(JNIEnv* env, const unsigned char* bytes, size_t len); | 19 ScopedJavaLocalRef<jbyteArray> ToJavaByteArray( |
| 20 JNIEnv* env, const uint8* bytes, size_t len); |
17 | 21 |
18 // Returns a array of Java byte array converted from |v|. | 22 // Returns a array of Java byte array converted from |v|. |
19 jobjectArray ToJavaArrayOfByteArray(JNIEnv* env, | 23 ScopedJavaLocalRef<jobjectArray> ToJavaArrayOfByteArray( |
20 const std::vector<std::string>& v); | 24 JNIEnv* env, const std::vector<std::string>& v); |
21 | 25 |
22 jobjectArray ToJavaArrayOfStrings(JNIEnv* env, | 26 ScopedJavaLocalRef<jobjectArray> ToJavaArrayOfStrings( |
23 const std::vector<std::string>& v); | 27 JNIEnv* env, const std::vector<std::string>& v); |
| 28 |
| 29 // Appends the Java bytes in |bytes_array| onto the end of |out|. |
| 30 void AppendJavaByteArrayToByteVector(JNIEnv* env, |
| 31 jbyteArray byte_array, |
| 32 std::vector<uint8>* out); |
| 33 |
| 34 // Replaces the content of |out| with the Java bytes in |bytes_array|. |
| 35 void JavaByteArrayToByteVector(JNIEnv* env, |
| 36 jbyteArray byte_array, |
| 37 std::vector<uint8>* out); |
24 | 38 |
25 } // namespace android | 39 } // namespace android |
26 } // namespace base | 40 } // namespace base |
27 | 41 |
28 #endif // BASE_ANDROID_JNI_ARRAY_H_ | 42 #endif // BASE_ANDROID_JNI_ARRAY_H_ |
OLD | NEW |