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

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

Issue 401743003: [android_webview] Introduce AwAssets to reference assets inside the apk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pakfiles
Patch Set: One char fix to make clang happy Created 6 years, 5 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
« no previous file with comments | « base/android/jni_array.h ('k') | no next file » | 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 DCHECK(out); 160 DCHECK(out);
161 out->clear(); 161 out->clear();
162 jsize len = env->GetArrayLength(int_array); 162 jsize len = env->GetArrayLength(int_array);
163 jint* ints = env->GetIntArrayElements(int_array, NULL); 163 jint* ints = env->GetIntArrayElements(int_array, NULL);
164 for (jsize i = 0; i < len; ++i) { 164 for (jsize i = 0; i < len; ++i) {
165 out->push_back(static_cast<int>(ints[i])); 165 out->push_back(static_cast<int>(ints[i]));
166 } 166 }
167 env->ReleaseIntArrayElements(int_array, ints, JNI_ABORT); 167 env->ReleaseIntArrayElements(int_array, ints, JNI_ABORT);
168 } 168 }
169 169
170 void JavaLongArrayToLongVector(JNIEnv* env,
171 jlongArray long_array,
172 std::vector<long>* out) {
173 DCHECK(out);
174 out->clear();
175 jsize len = env->GetArrayLength(long_array);
176 jlong* longs = env->GetLongArrayElements(long_array, NULL);
177 for (jsize i = 0; i < len; ++i) {
178 out->push_back(static_cast<long>(longs[i]));
179 }
180 env->ReleaseLongArrayElements(long_array, longs, JNI_ABORT);
181 }
182
170 void JavaFloatArrayToFloatVector(JNIEnv* env, 183 void JavaFloatArrayToFloatVector(JNIEnv* env,
171 jfloatArray float_array, 184 jfloatArray float_array,
172 std::vector<float>* out) { 185 std::vector<float>* out) {
173 DCHECK(out); 186 DCHECK(out);
174 out->clear(); 187 out->clear();
175 jsize len = env->GetArrayLength(float_array); 188 jsize len = env->GetArrayLength(float_array);
176 jfloat* floats = env->GetFloatArrayElements(float_array, NULL); 189 jfloat* floats = env->GetFloatArrayElements(float_array, NULL);
177 for (jsize i = 0; i < len; ++i) { 190 for (jsize i = 0; i < len; ++i) {
178 out->push_back(static_cast<float>(floats[i])); 191 out->push_back(static_cast<float>(floats[i]));
179 } 192 }
(...skipping 14 matching lines...) Expand all
194 env->GetObjectArrayElement(array, i))); 207 env->GetObjectArrayElement(array, i)));
195 jsize bytes_len = env->GetArrayLength(bytes_array.obj()); 208 jsize bytes_len = env->GetArrayLength(bytes_array.obj());
196 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL); 209 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL);
197 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len); 210 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len);
198 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT); 211 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT);
199 } 212 }
200 } 213 }
201 214
202 } // namespace android 215 } // namespace android
203 } // namespace base 216 } // namespace base
OLDNEW
« no previous file with comments | « base/android/jni_array.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698