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

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

Issue 874543003: Add support for TraceEvent before the native library is loaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments, cleanup and a JNI unittest. Created 5 years, 9 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') | base/android/jni_array_unittest.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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return; 156 return;
157 size_t len = SafeGetArrayLength(env, byte_array); 157 size_t len = SafeGetArrayLength(env, byte_array);
158 if (!len) 158 if (!len)
159 return; 159 return;
160 size_t back = out->size(); 160 size_t back = out->size();
161 out->resize(back + len); 161 out->resize(back + len);
162 env->GetByteArrayRegion(byte_array, 0, len, 162 env->GetByteArrayRegion(byte_array, 0, len,
163 reinterpret_cast<int8*>(&(*out)[back])); 163 reinterpret_cast<int8*>(&(*out)[back]));
164 } 164 }
165 165
166 void AppendJavaLongArrayToLongVector(JNIEnv* env,
167 jlongArray long_array,
168 std::vector<int64_t>* out) {
169 DCHECK(out);
170 if (!long_array)
171 return;
172 jsize len = env->GetArrayLength(long_array);
173 jlong* longs = env->GetLongArrayElements(long_array, NULL);
174 out->insert(out->end(), longs, longs + len);
175 env->ReleaseLongArrayElements(long_array, longs, JNI_ABORT);
176 }
177
166 void JavaByteArrayToByteVector(JNIEnv* env, 178 void JavaByteArrayToByteVector(JNIEnv* env,
167 jbyteArray byte_array, 179 jbyteArray byte_array,
168 std::vector<uint8>* out) { 180 std::vector<uint8>* out) {
169 DCHECK(out); 181 DCHECK(out);
170 DCHECK(byte_array); 182 DCHECK(byte_array);
171 out->clear(); 183 out->clear();
172 AppendJavaByteArrayToByteVector(env, byte_array, out); 184 AppendJavaByteArrayToByteVector(env, byte_array, out);
173 } 185 }
174 186
175 void JavaIntArrayToIntVector(JNIEnv* env, 187 void JavaIntArrayToIntVector(JNIEnv* env,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 env->GetObjectArrayElement(array, i))); 232 env->GetObjectArrayElement(array, i)));
221 jsize bytes_len = env->GetArrayLength(bytes_array.obj()); 233 jsize bytes_len = env->GetArrayLength(bytes_array.obj());
222 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL); 234 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL);
223 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len); 235 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len);
224 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT); 236 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT);
225 } 237 }
226 } 238 }
227 239
228 } // namespace android 240 } // namespace android
229 } // namespace base 241 } // namespace base
OLDNEW
« no previous file with comments | « base/android/jni_array.h ('k') | base/android/jni_array_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698