| OLD | NEW |
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 void JavaByteArrayToByteVector(JNIEnv* env, | 109 void JavaByteArrayToByteVector(JNIEnv* env, |
| 110 jbyteArray byte_array, | 110 jbyteArray byte_array, |
| 111 std::vector<uint8>* out) { | 111 std::vector<uint8>* out) { |
| 112 DCHECK(out); | 112 DCHECK(out); |
| 113 out->clear(); | 113 out->clear(); |
| 114 AppendJavaByteArrayToByteVector(env, byte_array, out); | 114 AppendJavaByteArrayToByteVector(env, byte_array, out); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void JavaIntArrayToIntVector(JNIEnv* env, |
| 118 jintArray array, |
| 119 std::vector<int>* out) { |
| 120 DCHECK(out); |
| 121 out->clear(); |
| 122 jsize len = env->GetArrayLength(array); |
| 123 jint* ints = env->GetIntArrayElements(array, NULL); |
| 124 for (jsize i = 0; i < len; ++i) { |
| 125 out->push_back(static_cast<int>(ints[i])); |
| 126 } |
| 127 env->ReleaseIntArrayElements(array, ints, JNI_ABORT); |
| 128 } |
| 129 |
| 117 } // namespace android | 130 } // namespace android |
| 118 } // namespace base | 131 } // namespace base |
| OLD | NEW |