Commit b2f1afee authored by Michael Matena's avatar Michael Matena Committed by Commit Bot

Refactored get histogram name to arc utils.

Bug: b:139752841
Change-Id: Ibaeed64fa47adde6e6b374e2771bd697a9715bcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1793252Reviewed-by: default avatarShao-Chuan Lee <shaochuan@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Shao-Chuan Lee <shaochuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699179}
parent c9039aa0
...@@ -21,25 +21,6 @@ namespace arc { ...@@ -21,25 +21,6 @@ namespace arc {
namespace { namespace {
// Adds a suffix to the name based on the account type.
std::string GetHistogramName(const std::string& base_name,
const Profile* profile) {
if (IsRobotOrOfflineDemoAccountMode()) {
chromeos::DemoSession* demo_session = chromeos::DemoSession::Get();
if (demo_session && demo_session->started()) {
return demo_session->offline_enrolled() ? base_name + "OfflineDemoMode"
: base_name + "DemoMode";
}
return base_name + "RobotAccount";
}
if (profile->IsChild())
return base_name + "Child";
if (IsActiveDirectoryUserForProfile(profile))
return base_name + "ActiveDirectory";
return base_name +
(policy_util::IsAccountManaged(profile) ? "Managed" : "Unmanaged");
}
ArcEnabledState ComputeEnabledState(bool enabled, const Profile* profile) { ArcEnabledState ComputeEnabledState(bool enabled, const Profile* profile) {
if (!IsArcAllowedForProfile(profile)) { if (!IsArcAllowedForProfile(profile)) {
return enabled ? ArcEnabledState::ENABLED_NOT_ALLOWED return enabled ? ArcEnabledState::ENABLED_NOT_ALLOWED
...@@ -75,7 +56,7 @@ void UpdateEnabledStateByUserTypeUMA() { ...@@ -75,7 +56,7 @@ void UpdateEnabledStateByUserTypeUMA() {
enabled_state = stability_metrics_manager->GetArcEnabledState(); enabled_state = stability_metrics_manager->GetArcEnabledState();
base::UmaHistogramEnumeration( base::UmaHistogramEnumeration(
GetHistogramName("Arc.StateByUserType.", profile), GetHistogramNameByUserType("Arc.StateByUserType", profile),
ComputeEnabledState(enabled_state.value_or(false), profile)); ComputeEnabledState(enabled_state.value_or(false), profile));
} }
...@@ -95,7 +76,7 @@ void UpdateProvisioningResultUMA(ProvisioningResult result, ...@@ -95,7 +76,7 @@ void UpdateProvisioningResultUMA(ProvisioningResult result,
const Profile* profile) { const Profile* profile) {
DCHECK_NE(result, ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); DCHECK_NE(result, ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
base::UmaHistogramEnumeration( base::UmaHistogramEnumeration(
GetHistogramName("Arc.Provisioning.Result.", profile), result); GetHistogramNameByUserType("Arc.Provisioning.Result", profile), result);
} }
void UpdateSecondarySigninResultUMA(ProvisioningResult result) { void UpdateSecondarySigninResultUMA(ProvisioningResult result) {
...@@ -105,32 +86,35 @@ void UpdateSecondarySigninResultUMA(ProvisioningResult result) { ...@@ -105,32 +86,35 @@ void UpdateSecondarySigninResultUMA(ProvisioningResult result) {
void UpdateProvisioningTiming(const base::TimeDelta& elapsed_time, void UpdateProvisioningTiming(const base::TimeDelta& elapsed_time,
bool success, bool success,
const Profile* profile) { const Profile* profile) {
std::string histogram_name = "Arc.Provisioning.TimeDelta."; std::string histogram_name = "Arc.Provisioning.TimeDelta";
histogram_name += success ? "Success." : "Failure."; histogram_name += success ? ".Success" : ".Failure";
// The macro UMA_HISTOGRAM_CUSTOM_TIMES expects a constant string, but since // The macro UMA_HISTOGRAM_CUSTOM_TIMES expects a constant string, but since
// this measurement happens very infrequently, we do not need to use a macro // this measurement happens very infrequently, we do not need to use a macro
// here. // here.
base::UmaHistogramCustomTimes(GetHistogramName(histogram_name, profile), base::UmaHistogramCustomTimes(
elapsed_time, base::TimeDelta::FromSeconds(1), GetHistogramNameByUserType(histogram_name, profile), elapsed_time,
base::TimeDelta::FromMinutes(6), 50); base::TimeDelta::FromSeconds(1), base::TimeDelta::FromMinutes(6), 50);
} }
void UpdateReauthorizationResultUMA(ProvisioningResult result, void UpdateReauthorizationResultUMA(ProvisioningResult result,
const Profile* profile) { const Profile* profile) {
base::UmaHistogramEnumeration( base::UmaHistogramEnumeration(
GetHistogramName("Arc.Reauthorization.Result.", profile), result); GetHistogramNameByUserType("Arc.Reauthorization.Result", profile),
result);
} }
void UpdatePlayAutoInstallRequestState(mojom::PaiFlowState state, void UpdatePlayAutoInstallRequestState(mojom::PaiFlowState state,
const Profile* profile) { const Profile* profile) {
base::UmaHistogramEnumeration( base::UmaHistogramEnumeration(
GetHistogramName("Arc.PlayAutoInstallRequest.State.", profile), state); GetHistogramNameByUserType("Arc.PlayAutoInstallRequest.State", profile),
state);
} }
void UpdatePlayAutoInstallRequestTime(const base::TimeDelta& elapsed_time, void UpdatePlayAutoInstallRequestTime(const base::TimeDelta& elapsed_time,
const Profile* profile) { const Profile* profile) {
base::UmaHistogramCustomTimes( base::UmaHistogramCustomTimes(
GetHistogramName("Arc.PlayAutoInstallRequest.TimeDelta.", profile), GetHistogramNameByUserType("Arc.PlayAutoInstallRequest.TimeDelta",
profile),
elapsed_time, base::TimeDelta::FromSeconds(1), elapsed_time, base::TimeDelta::FromSeconds(1),
base::TimeDelta::FromMinutes(10), 50); base::TimeDelta::FromMinutes(10), 50);
} }
...@@ -138,8 +122,9 @@ void UpdatePlayAutoInstallRequestTime(const base::TimeDelta& elapsed_time, ...@@ -138,8 +122,9 @@ void UpdatePlayAutoInstallRequestTime(const base::TimeDelta& elapsed_time,
void UpdatePlayStoreShowTime(const base::TimeDelta& elapsed_time, void UpdatePlayStoreShowTime(const base::TimeDelta& elapsed_time,
const Profile* profile) { const Profile* profile) {
base::UmaHistogramCustomTimes( base::UmaHistogramCustomTimes(
GetHistogramName("Arc.PlayStoreShown.TimeDelta.", profile), elapsed_time, GetHistogramNameByUserType("Arc.PlayStoreShown.TimeDelta", profile),
base::TimeDelta::FromSeconds(1), base::TimeDelta::FromMinutes(10), 50); elapsed_time, base::TimeDelta::FromSeconds(1),
base::TimeDelta::FromMinutes(10), 50);
} }
void UpdateAuthTiming(const char* histogram_name, void UpdateAuthTiming(const char* histogram_name,
......
...@@ -663,4 +663,25 @@ std::unique_ptr<content::WebContents> CreateArcCustomTabWebContents( ...@@ -663,4 +663,25 @@ std::unique_ptr<content::WebContents> CreateArcCustomTabWebContents(
return web_contents; return web_contents;
} }
std::string GetHistogramNameByUserType(const std::string& base_name,
const Profile* profile) {
if (profile == nullptr) {
profile = ProfileManager::GetPrimaryUserProfile();
}
if (IsRobotOrOfflineDemoAccountMode()) {
chromeos::DemoSession* demo_session = chromeos::DemoSession::Get();
if (demo_session && demo_session->started()) {
return demo_session->offline_enrolled() ? base_name + ".OfflineDemoMode"
: base_name + ".DemoMode";
}
return base_name + ".RobotAccount";
}
if (profile->IsChild())
return base_name + ".Child";
if (IsActiveDirectoryUserForProfile(profile))
return base_name + ".ActiveDirectory";
return base_name +
(policy_util::IsAccountManaged(profile) ? ".Managed" : ".Unmanaged");
}
} // namespace arc } // namespace arc
...@@ -194,6 +194,11 @@ std::unique_ptr<content::WebContents> CreateArcCustomTabWebContents( ...@@ -194,6 +194,11 @@ std::unique_ptr<content::WebContents> CreateArcCustomTabWebContents(
Profile* profile, Profile* profile,
const GURL& url); const GURL& url);
// Adds a suffix to the name based on the account type. If profile is not
// provided, then defaults to the primary user profile.
std::string GetHistogramNameByUserType(const std::string& base_name,
const Profile* profile = nullptr);
} // namespace arc } // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_UTIL_H_ #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_UTIL_H_
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