OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cronet/android/cronet_histogram_manager.h" | 5 #include "components/cronet/android/cronet_histogram_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/metrics/statistics_recorder.h" | 11 #include "base/metrics/statistics_recorder.h" |
12 #include "components/cronet/histogram_manager.h" | 12 #include "components/cronet/histogram_manager.h" |
13 | 13 |
14 #include "jni/CronetHistogramManager_jni.h" | 14 #include "jni/CronetHistogramManager_jni.h" |
15 | 15 |
16 namespace cronet { | 16 namespace cronet { |
17 | 17 |
18 // Explicitly register static JNI functions. | 18 // Explicitly register static JNI functions. |
19 bool CronetHistogramManagerRegisterJni(JNIEnv* env) { | 19 bool CronetHistogramManagerRegisterJni(JNIEnv* env) { |
20 return RegisterNativesImpl(env); | 20 return RegisterNativesImpl(env); |
21 } | 21 } |
22 | 22 |
23 static void EnsureInitialized(JNIEnv* env, jobject jcaller) { | 23 static void EnsureInitialized(JNIEnv* env, |
| 24 const JavaParamRef<jobject>& jcaller) { |
24 base::StatisticsRecorder::Initialize(); | 25 base::StatisticsRecorder::Initialize(); |
25 } | 26 } |
26 | 27 |
27 static ScopedJavaLocalRef<jbyteArray> GetHistogramDeltas(JNIEnv* env, | 28 static ScopedJavaLocalRef<jbyteArray> GetHistogramDeltas( |
28 jobject jcaller) { | 29 JNIEnv* env, |
| 30 const JavaParamRef<jobject>& jcaller) { |
29 std::vector<uint8> data; | 31 std::vector<uint8> data; |
30 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 32 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
31 return ScopedJavaLocalRef<jbyteArray>(); | 33 return ScopedJavaLocalRef<jbyteArray>(); |
32 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 34 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
33 } | 35 } |
34 | 36 |
35 } // namespace cronet | 37 } // namespace cronet |
OLD | NEW |