1// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/android/animation_frame_time_histogram.h"
6
7#include "base/android/jni_string.h"
8#include "base/metrics/histogram_macros.h"
9#include "jni/AnimationFrameTimeHistogram_jni.h"
10
11using base::android::JavaParamRef;
12
13// static
14void SaveHistogram(JNIEnv* env,
15                   const JavaParamRef<jobject>& jcaller,
16                   const JavaParamRef<jstring>& j_histogram_name,
17                   const JavaParamRef<jlongArray>& j_frame_times_ms,
18                   jint j_count) {
19  jlong *frame_times_ms = env->GetLongArrayElements(j_frame_times_ms, NULL);
20  std::string histogram_name = base::android::ConvertJavaStringToUTF8(
21      env, j_histogram_name);
22
23  for (int i = 0; i < j_count; ++i) {
24    UMA_HISTOGRAM_TIMES(histogram_name.c_str(),
25                        base::TimeDelta::FromMilliseconds(frame_times_ms[i]));
26  }
27}
28
29namespace base {
30namespace android {
31
32// static
33bool RegisterAnimationFrameTimeHistogram(JNIEnv* env) {
34  return RegisterNativesImpl(env);
35}
36
37}  // namespace android
38}  // namespace base
39