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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 std::vector<uint8_t>* out) { | 162 std::vector<uint8_t>* out) { |
163 DCHECK(out); | 163 DCHECK(out); |
164 if (!byte_array) | 164 if (!byte_array) |
165 return; | 165 return; |
166 size_t len = SafeGetArrayLength(env, byte_array); | 166 size_t len = SafeGetArrayLength(env, byte_array); |
167 if (!len) | 167 if (!len) |
168 return; | 168 return; |
169 size_t back = out->size(); | 169 size_t back = out->size(); |
170 out->resize(back + len); | 170 out->resize(back + len); |
171 env->GetByteArrayRegion(byte_array, 0, len, | 171 env->GetByteArrayRegion(byte_array, 0, len, |
172 reinterpret_cast<int8*>(&(*out)[back])); | 172 reinterpret_cast<int8_t*>(&(*out)[back])); |
173 } | 173 } |
174 | 174 |
175 void JavaByteArrayToByteVector(JNIEnv* env, | 175 void JavaByteArrayToByteVector(JNIEnv* env, |
176 jbyteArray byte_array, | 176 jbyteArray byte_array, |
177 std::vector<uint8_t>* out) { | 177 std::vector<uint8_t>* out) { |
178 DCHECK(out); | 178 DCHECK(out); |
179 DCHECK(byte_array); | 179 DCHECK(byte_array); |
180 out->clear(); | 180 out->clear(); |
181 AppendJavaByteArrayToByteVector(env, byte_array, out); | 181 AppendJavaByteArrayToByteVector(env, byte_array, out); |
182 } | 182 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 out->resize(len); | 253 out->resize(len); |
254 for (size_t i = 0; i < len; ++i) { | 254 for (size_t i = 0; i < len; ++i) { |
255 ScopedJavaLocalRef<jintArray> int_array( | 255 ScopedJavaLocalRef<jintArray> int_array( |
256 env, static_cast<jintArray>(env->GetObjectArrayElement(array, i))); | 256 env, static_cast<jintArray>(env->GetObjectArrayElement(array, i))); |
257 JavaIntArrayToIntVector(env, int_array.obj(), &((*out)[i])); | 257 JavaIntArrayToIntVector(env, int_array.obj(), &((*out)[i])); |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 } // namespace android | 261 } // namespace android |
262 } // namespace base | 262 } // namespace base |
OLD | NEW |