Speculative fix for the white/stale tab issue on Windows.
[chromium-blink-merge.git] / base / android / jni_array.h
blobfbc131ed54bac64ff054fef26c3a6f1d3894953e
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
3 // found in the LICENSE file.
5 #ifndef BASE_ANDROID_JNI_ARRAY_H_
6 #define BASE_ANDROID_JNI_ARRAY_H_
8 #include <jni.h>
9 #include <string>
10 #include <vector>
12 #include "base/android/scoped_java_ref.h"
13 #include "base/basictypes.h"
14 #include "base/string16.h"
16 namespace base {
17 namespace android {
19 // Returns a new Java byte array converted from the given bytes array.
20 BASE_EXPORT ScopedJavaLocalRef<jbyteArray> ToJavaByteArray(
21 JNIEnv* env, const uint8* bytes, size_t len);
23 // Returns a array of Java byte array converted from |v|.
24 BASE_EXPORT ScopedJavaLocalRef<jobjectArray> ToJavaArrayOfByteArray(
25 JNIEnv* env, const std::vector<std::string>& v);
27 BASE_EXPORT ScopedJavaLocalRef<jobjectArray> ToJavaArrayOfStrings(
28 JNIEnv* env, const std::vector<std::string>& v);
30 BASE_EXPORT ScopedJavaLocalRef<jobjectArray> ToJavaArrayOfStrings(
31 JNIEnv* env, const std::vector<string16>& v);
33 // Converts a Java string array to a native array.
34 BASE_EXPORT void AppendJavaStringArrayToStringVector(
35 JNIEnv* env,
36 jobjectArray array,
37 std::vector<string16>* out);
39 BASE_EXPORT void AppendJavaStringArrayToStringVector(
40 JNIEnv* env,
41 jobjectArray array,
42 std::vector<std::string>* out);
44 // Appends the Java bytes in |bytes_array| onto the end of |out|.
45 BASE_EXPORT void AppendJavaByteArrayToByteVector(
46 JNIEnv* env,
47 jbyteArray byte_array,
48 std::vector<uint8>* out);
50 // Replaces the content of |out| with the Java bytes in |bytes_array|.
51 BASE_EXPORT void JavaByteArrayToByteVector(
52 JNIEnv* env,
53 jbyteArray byte_array,
54 std::vector<uint8>* out);
56 // Replaces the content of |out| with the Java ints in |int_array|.
57 BASE_EXPORT void JavaIntArrayToIntVector(
58 JNIEnv* env,
59 jintArray int_array,
60 std::vector<int>* out);
62 // Assuming |array| is an byte[][] (array of byte arrays), replaces the
63 // content of |out| with the corresponding vector of strings. No UTF-8
64 // conversion is performed.
65 void JavaArrayOfByteArrayToStringVector(
66 JNIEnv* env,
67 jobjectArray array,
68 std::vector<std::string>* out);
70 } // namespace android
71 } // namespace base
73 #endif // BASE_ANDROID_JNI_ARRAY_H_