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

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

Issue 1337703002: [Contextual Search] Add support for crushed sprites and animate the search provider icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO's for other planned tests Created 5 years, 2 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
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ScopedJavaLocalRef<jbyteArray> bytes_array( 228 ScopedJavaLocalRef<jbyteArray> bytes_array(
229 env, static_cast<jbyteArray>( 229 env, static_cast<jbyteArray>(
230 env->GetObjectArrayElement(array, i))); 230 env->GetObjectArrayElement(array, i)));
231 jsize bytes_len = env->GetArrayLength(bytes_array.obj()); 231 jsize bytes_len = env->GetArrayLength(bytes_array.obj());
232 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL); 232 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL);
233 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len); 233 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len);
234 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT); 234 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT);
235 } 235 }
236 } 236 }
237 237
238 void JavaArrayOfIntArrayToIntVector(
239 JNIEnv* env,
240 jobjectArray array,
241 std::vector<std::vector<int>>* out) {
242 DCHECK(out);
243 size_t len = SafeGetArrayLength(env, array);
244 out->resize(len);
245 for (size_t i = 0; i < len; ++i) {
246 ScopedJavaLocalRef<jintArray> int_array(
247 env, static_cast<jintArray>(env->GetObjectArrayElement(array, i)));
248 jsize array_len = env->GetArrayLength(int_array.obj());
249 jint* ints = env->GetIntArrayElements(int_array.obj(), NULL);
David Trainor- moved to gerrit 2015/10/15 21:04:56 nullptr
Theresa 2015/10/24 00:06:44 Done.
250 std::vector<int> vector_ints = out->at(i);
251 vector_ints.resize(array_len);
252 for (jsize j = 0; j < array_len; ++j) {
253 vector_ints[j] = static_cast<int>(ints[j]);
254 }
255
256 (*out)[i] = vector_ints;
257 env->ReleaseIntArrayElements(int_array.obj(), ints, JNI_ABORT);
258 }
259 }
260
238 } // namespace android 261 } // namespace android
239 } // namespace base 262 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698