Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: base/android/jni_array.h

Issue 9358028: Upstream Android JNI code, allowing us to use more ScopedJava references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased and added a TODO Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/android/jni_android.cc ('k') | base/android/jni_array.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_
OLDNEW
« no previous file with comments | « base/android/jni_android.cc ('k') | base/android/jni_array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698