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

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

Issue 10532155: Upstream some more content/ DEPS-related cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove JNIHelper/BitmapHolder Created 8 years, 6 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_array.h ('k') | content/app/android/content_jni_registrar.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) 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 #include "base/android/jni_array.h" 5 #include "base/android/jni_array.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (!array) 73 if (!array)
74 return; 74 return;
75 jsize len = env->GetArrayLength(array); 75 jsize len = env->GetArrayLength(array);
76 for (jsize i = 0; i < len; ++i) { 76 for (jsize i = 0; i < len; ++i) {
77 ScopedJavaLocalRef<jstring> str(env, 77 ScopedJavaLocalRef<jstring> str(env,
78 static_cast<jstring>(env->GetObjectArrayElement(array, i))); 78 static_cast<jstring>(env->GetObjectArrayElement(array, i)));
79 out->push_back(ConvertJavaStringToUTF16(str)); 79 out->push_back(ConvertJavaStringToUTF16(str));
80 } 80 }
81 } 81 }
82 82
83 void AppendJavaStringArrayToStringVector(JNIEnv* env,
84 jobjectArray array,
85 std::vector<std::string>* out) {
86 DCHECK(out);
87 if (!array)
88 return;
89 jsize len = env->GetArrayLength(array);
90 for (jsize i = 0; i < len; ++i) {
91 ScopedJavaLocalRef<jstring> str(env,
92 static_cast<jstring>(env->GetObjectArrayElement(array, i)));
93 out->push_back(ConvertJavaStringToUTF8(str));
94 }
95 }
96
83 void AppendJavaByteArrayToByteVector(JNIEnv* env, 97 void AppendJavaByteArrayToByteVector(JNIEnv* env,
84 jbyteArray byte_array, 98 jbyteArray byte_array,
85 std::vector<uint8>* out) { 99 std::vector<uint8>* out) {
86 DCHECK(out); 100 DCHECK(out);
87 if (!byte_array) 101 if (!byte_array)
88 return; 102 return;
89 jsize len = env->GetArrayLength(byte_array); 103 jsize len = env->GetArrayLength(byte_array);
90 jbyte* bytes = env->GetByteArrayElements(byte_array, NULL); 104 jbyte* bytes = env->GetByteArrayElements(byte_array, NULL);
91 out->insert(out->end(), bytes, bytes + len); 105 out->insert(out->end(), bytes, bytes + len);
92 env->ReleaseByteArrayElements(byte_array, bytes, JNI_ABORT); 106 env->ReleaseByteArrayElements(byte_array, bytes, JNI_ABORT);
93 } 107 }
94 108
95 void JavaByteArrayToByteVector(JNIEnv* env, 109 void JavaByteArrayToByteVector(JNIEnv* env,
96 jbyteArray byte_array, 110 jbyteArray byte_array,
97 std::vector<uint8>* out) { 111 std::vector<uint8>* out) {
98 DCHECK(out); 112 DCHECK(out);
99 out->clear(); 113 out->clear();
100 AppendJavaByteArrayToByteVector(env, byte_array, out); 114 AppendJavaByteArrayToByteVector(env, byte_array, out);
101 } 115 }
102 116
103 } // namespace android 117 } // namespace android
104 } // namespace base 118 } // namespace base
OLDNEW
« no previous file with comments | « base/android/jni_array.h ('k') | content/app/android/content_jni_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698