Index: components/cronet/android/histogram_manager.cc |
diff --git a/components/cronet/android/histogram_manager.cc b/components/cronet/android/histogram_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..173dc666ed06085a08f2ce3456d940811cdbb926 |
--- /dev/null |
+++ b/components/cronet/android/histogram_manager.cc |
@@ -0,0 +1,31 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/cronet/android/histogram_manager.h" |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/android/jni_array.h" |
+#include "components/metrics/histogram_manager.h" |
+ |
+#include "jni/HistogramManager_jni.h" |
+ |
+namespace cronet { |
+ |
+// Explicitly register static JNI functions. |
+bool HistogramManagerRegisterJni(JNIEnv* env) { |
+ return RegisterNativesImpl(env); |
+} |
+ |
+static jbyteArray GetHistogramDeltas(JNIEnv* env, jobject jcaller) { |
+ std::vector<uint8> data = |
+ metrics::HistogramManager::GetInstance()->GetDeltas(); |
mef
2014/12/11 23:11:40
qq: how big are deltas? Would this result in extra
ramant (doing other things)
2014/12/12 02:43:05
Do we do return value optimization on Android?
A
|
+ if (!data.empty()) { |
+ return base::android::ToJavaByteArray(env, &data[0], data.size()).Release(); |
mef
2014/12/11 23:11:40
nit: no need for curly braces.
ramant (doing other things)
2014/12/12 02:43:05
Done.
|
+ } |
+ return NULL; |
+} |
+ |
+} // namespace cronet |