OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/android/metrics/uma_utils.h" | 5 #include "chrome/browser/android/metrics/uma_utils.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "components/metrics/metrics_reporting_default_state.h" | 10 #include "components/metrics/metrics_reporting_default_state.h" |
11 #include "jni/UmaUtils_jni.h" | 11 #include "jni/UmaUtils_jni.h" |
12 | 12 |
| 13 using base::android::JavaParamRef; |
| 14 |
13 class PrefService; | 15 class PrefService; |
14 | 16 |
15 namespace chrome { | 17 namespace chrome { |
16 namespace android { | 18 namespace android { |
17 | 19 |
18 base::Time GetMainEntryPointTime() { | 20 base::Time GetMainEntryPointTime() { |
19 JNIEnv* env = base::android::AttachCurrentThread(); | 21 JNIEnv* env = base::android::AttachCurrentThread(); |
20 int64_t startTimeUnixMs = Java_UmaUtils_getMainEntryPointWallTime(env); | 22 int64_t startTimeUnixMs = Java_UmaUtils_getMainEntryPointWallTime(env); |
21 return base::Time::UnixEpoch() + | 23 return base::Time::UnixEpoch() + |
22 base::TimeDelta::FromMilliseconds(startTimeUnixMs); | 24 base::TimeDelta::FromMilliseconds(startTimeUnixMs); |
23 } | 25 } |
24 | 26 |
25 static void RecordMetricsReportingDefaultOptIn(JNIEnv* env, | 27 static void RecordMetricsReportingDefaultOptIn(JNIEnv* env, |
26 const JavaParamRef<jclass>& obj, | 28 const JavaParamRef<jclass>& obj, |
27 jboolean opt_in) { | 29 jboolean opt_in) { |
28 DCHECK(g_browser_process); | 30 DCHECK(g_browser_process); |
29 PrefService* local_state = g_browser_process->local_state(); | 31 PrefService* local_state = g_browser_process->local_state(); |
30 metrics::RecordMetricsReportingDefaultState( | 32 metrics::RecordMetricsReportingDefaultState( |
31 local_state, opt_in ? metrics::EnableMetricsDefault::OPT_IN | 33 local_state, opt_in ? metrics::EnableMetricsDefault::OPT_IN |
32 : metrics::EnableMetricsDefault::OPT_OUT); | 34 : metrics::EnableMetricsDefault::OPT_OUT); |
33 } | 35 } |
34 | 36 |
35 bool RegisterStartupMetricUtils(JNIEnv* env) { | 37 bool RegisterStartupMetricUtils(JNIEnv* env) { |
36 return RegisterNativesImpl(env); | 38 return RegisterNativesImpl(env); |
37 } | 39 } |
38 | 40 |
39 } // namespace android | 41 } // namespace android |
40 } // namespace chrome | 42 } // namespace chrome |
OLD | NEW |