Commit 06e66ef3 authored by gayane's avatar gayane Committed by Commit bot

Modifications for recording whether UMA/Crash default state for iOS.

BUG=612828

Review-Url: https://codereview.chromium.org/2014463003
Cr-Commit-Position: refs/heads/master@{#398116}
parent b744ad3d
......@@ -7,7 +7,7 @@
#include <stdint.h>
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/metrics_reporting_state.h"
#include "components/metrics/metrics_reporting_default_state.h"
#include "jni/UmaUtils_jni.h"
class PrefService;
......@@ -27,7 +27,7 @@ static void RecordMetricsReportingDefaultOptIn(JNIEnv* env,
jboolean opt_in) {
DCHECK(g_browser_process);
PrefService* local_state = g_browser_process->local_state();
::RecordMetricsReportingDefaultOptIn(local_state, opt_in);
metrics::RecordMetricsReportingDefaultOptIn(local_state, opt_in);
}
bool RegisterStartupMetricUtils(JNIEnv* env) {
......
......@@ -11,12 +11,12 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/first_run/first_run_dialog.h"
#include "chrome/browser/metrics/metrics_reporting_state.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/master_preferences.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/metrics_reporting_default_state.h"
#include "components/prefs/pref_service.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
......@@ -32,8 +32,9 @@ void DoPostImportPlatformSpecificTasks(Profile* profile) {
// has not already set preferences.
if (internal::IsOrganicFirstRun() && !local_state_file_exists) {
if (ShowFirstRunDialog(profile)) {
RecordMetricsReportingDefaultOptIn(g_browser_process->local_state(),
first_run::IsMetricsReportingOptIn());
metrics::RecordMetricsReportingDefaultOptIn(
g_browser_process->local_state(),
first_run::IsMetricsReportingOptIn());
startup_metric_utils::SetNonBrowserUIDisplayed();
}
}
......
......@@ -43,6 +43,7 @@
#include "components/metrics/file_metrics_provider.h"
#include "components/metrics/gpu/gpu_metrics_provider.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/metrics_reporting_default_state.h"
#include "components/metrics/metrics_service.h"
#include "components/metrics/metrics_service_client.h"
#include "components/metrics/metrics_state_manager.h"
......@@ -233,7 +234,7 @@ void ChromeMetricsServiceClient::RegisterPrefs(PrefRegistrySimple* registry) {
RegisterInstallerFileMetricsPreferences(registry);
RegisterMetricsReportingStatePrefs(registry);
metrics::RegisterMetricsReportingStatePrefs(registry);
#if BUILDFLAG(ANDROID_JAVA_UI)
AndroidMetricsProvider::RegisterPrefs(registry);
......@@ -359,7 +360,8 @@ bool ChromeMetricsServiceClient::IsReportingPolicyManaged() {
metrics::MetricsServiceClient::EnableMetricsDefault
ChromeMetricsServiceClient::GetDefaultOptIn() {
return GetMetricsReportingDefaultOptIn(g_browser_process->local_state());
return metrics::GetMetricsReportingDefaultOptIn(
g_browser_process->local_state());
}
void ChromeMetricsServiceClient::Initialize() {
......
......@@ -124,11 +124,6 @@ void InitiateMetricsReportingChange(
base::Bind(&SetMetricsReporting, enabled, callback_fn));
}
void RegisterMetricsReportingStatePrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(prefs::kMetricsDefaultOptIn,
metrics::MetricsServiceClient::DEFAULT_UNKNOWN);
}
bool IsMetricsReportingPolicyManaged() {
const PrefService* pref_service = g_browser_process->local_state();
const PrefService::Preference* pref =
......@@ -136,20 +131,6 @@ bool IsMetricsReportingPolicyManaged() {
return pref && pref->IsManaged();
}
void RecordMetricsReportingDefaultOptIn(PrefService* local_state, bool opt_in) {
DCHECK(GetMetricsReportingDefaultOptIn(local_state) ==
metrics::MetricsServiceClient::DEFAULT_UNKNOWN);
local_state->SetInteger(prefs::kMetricsDefaultOptIn,
opt_in ? metrics::MetricsServiceClient::OPT_IN
: metrics::MetricsServiceClient::OPT_OUT);
}
metrics::MetricsServiceClient::EnableMetricsDefault
GetMetricsReportingDefaultOptIn(PrefService* local_state) {
return static_cast<metrics::MetricsServiceClient::EnableMetricsDefault>(
local_state->GetInteger(prefs::kMetricsDefaultOptIn));
}
// TODO(gayane): Add unittest which will check that observer on device settings
// will trigger this function and kMetricsReportinEnabled as well as metrics
// service state will be updated accordingly.
......
......@@ -27,21 +27,6 @@ void InitiateMetricsReportingChange(
// Android).
bool IsMetricsReportingPolicyManaged();
// Register prefs relating to metrics reporting state. Currently only registers
// a pref for metrics reporting default opt-in state.
void RegisterMetricsReportingStatePrefs(PrefRegistrySimple* registry);
// Sets whether metrics reporting was opt-in or not. If it was opt-in, then the
// enable checkbox on first-run was default unchecked. If it was opt-out, then
// the checkbox was default checked. This should only be set once, and only
// during first-run.
void RecordMetricsReportingDefaultOptIn(PrefService* local_state, bool opt_in);
// Gets information about the default value for the enable metrics reporting
// checkbox shown during first-run.
metrics::MetricsServiceClient::EnableMetricsDefault
GetMetricsReportingDefaultOptIn(PrefService* local_state);
// Initialize kMetricsReportingEnabled based on kStatsReportingPref device
// setting and add an observer as it is the source of truth on Chrome OS.
void SetupMetricsStateForChromeOS();
......
......@@ -1277,13 +1277,6 @@ const char kCrashReportingEnabled[] =
"user_experience_metrics_crash.reporting_enabled";
#endif
// An enum value indicating the default value of the enable metrics reporting
// checkbox shown during first-run. If it's opt-in, then the checkbox defaulted
// to unchecked, if it's opt-out, then it defaulted to checked. This value is
// only recorded during first-run, so older clients will not set it. The enum
// used for the value is metrics::MetricsServiceClient::EnableMetricsDefault.
const char kMetricsDefaultOptIn[] = "user_experience_metrics.default_opt_in";
// This is the location of a list of dictionaries of plugin stability stats.
const char kStabilityPluginStats[] =
"user_experience_metrics.stability.plugin_stats2";
......
......@@ -437,8 +437,6 @@ extern const char kGLVersionString[];
extern const char kCrashReportingEnabled[];
#endif
extern const char kMetricsDefaultOptIn[];
extern const char kDeviceOpenNetworkConfiguration[];
extern const char kProfileLastUsed[];
......
......@@ -60,6 +60,8 @@
'metrics/metrics_pref_names.h',
'metrics/metrics_provider.cc',
'metrics/metrics_provider.h',
'metrics/metrics_reporting_default_state.cc',
'metrics/metrics_reporting_default_state.h',
'metrics/metrics_reporting_scheduler.cc',
'metrics/metrics_reporting_scheduler.h',
'metrics/metrics_service.cc',
......
......@@ -56,6 +56,8 @@ source_set("metrics") {
"metrics_pref_names.h",
"metrics_provider.cc",
"metrics_provider.h",
"metrics_reporting_default_state.cc",
"metrics_reporting_default_state.h",
"metrics_reporting_scheduler.cc",
"metrics_reporting_scheduler.h",
"metrics_service.cc",
......
......@@ -16,6 +16,13 @@ const char kInstallDate[] = "uninstall_metrics.installation_date2";
// new prefs to do a one-time reset of the previous values.
const char kMetricsClientID[] = "user_experience_metrics.client_id2";
// An enum value indicating the default value of the enable metrics reporting
// checkbox shown during first-run. If it's opt-in, then the checkbox defaulted
// to unchecked, if it's opt-out, then it defaulted to checked. This value is
// only recorded during first-run, so older clients will not set it. The enum
// used for the value is metrics::MetricsServiceClient::EnableMetricsDefault.
const char kMetricsDefaultOptIn[] = "user_experience_metrics.default_opt_in";
// Array of strings that are each UMA logs that were supposed to be sent in the
// first minute of a browser session. These logs include things like crash count
// info, etc.
......
......@@ -12,6 +12,7 @@ namespace prefs {
// component. Document each in the .cc file.
extern const char kInstallDate[];
extern const char kMetricsClientID[];
extern const char kMetricsDefaultOptIn[];
extern const char kMetricsInitialLogs[];
extern const char kMetricsLowEntropySource[];
extern const char kMetricsMachineId[];
......
// Copyright 2016 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/metrics/metrics_reporting_default_state.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
namespace metrics {
void RegisterMetricsReportingStatePrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(prefs::kMetricsDefaultOptIn,
MetricsServiceClient::DEFAULT_UNKNOWN);
}
void RecordMetricsReportingDefaultOptIn(PrefService* local_state, bool opt_in) {
DCHECK(GetMetricsReportingDefaultOptIn(local_state) ==
MetricsServiceClient::DEFAULT_UNKNOWN);
local_state->SetInteger(
prefs::kMetricsDefaultOptIn,
opt_in ? MetricsServiceClient::OPT_IN : MetricsServiceClient::OPT_OUT);
}
MetricsServiceClient::EnableMetricsDefault GetMetricsReportingDefaultOptIn(
PrefService* local_state) {
return static_cast<MetricsServiceClient::EnableMetricsDefault>(
local_state->GetInteger(prefs::kMetricsDefaultOptIn));
}
} // namespace metrics
\ No newline at end of file
// Copyright 2016 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.
#ifndef COMPONENTS_METRICS_METRICS_REPORTING_DEFAULT_STATE_H_
#define COMPONENTS_METRICS_METRICS_REPORTING_DEFAULT_STATE_H_
#include "components/metrics/metrics_service_client.h"
class PrefRegistrySimple;
class PrefService;
namespace metrics {
// Register prefs relating to metrics reporting state. Currently only registers
// a pref for metrics reporting default opt-in state.
void RegisterMetricsReportingStatePrefs(PrefRegistrySimple* registry);
// Sets whether metrics reporting was opt-in or not. If it was opt-in, then the
// enable checkbox on first-run was default unchecked. If it was opt-out, then
// the checkbox was default checked. This should only be set once, and only
// during first-run.
void RecordMetricsReportingDefaultOptIn(PrefService* local_state, bool opt_in);
// Gets information about the default value for the enable metrics reporting
// checkbox shown during first-run.
MetricsServiceClient::EnableMetricsDefault GetMetricsReportingDefaultOptIn(
PrefService* local_state);
} // namespace metrics
#endif // COMPONENTS_METRICS_METRICS_REPORTING_DEFAULT_STATE_H_
\ No newline at end of file
......@@ -24,6 +24,7 @@
#include "components/metrics/call_stack_profile_metrics_provider.h"
#include "components/metrics/drive_metrics_provider.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/metrics_reporting_default_state.h"
#include "components/metrics/metrics_service.h"
#include "components/metrics/net/cellular_logic_helper.h"
#include "components/metrics/net/net_metrics_log_uploader.h"
......@@ -89,6 +90,7 @@ void IOSChromeMetricsServiceClient::RegisterPrefs(
PrefRegistrySimple* registry) {
metrics::MetricsService::RegisterPrefs(registry);
metrics::StabilityMetricsHelper::RegisterPrefs(registry);
metrics::RegisterMetricsReportingStatePrefs(registry);
}
metrics::MetricsService* IOSChromeMetricsServiceClient::GetMetricsService() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment