| Index: chrome/browser/chromeos/arc/arc_session_manager.cc
|
| diff --git a/chrome/browser/chromeos/arc/arc_session_manager.cc b/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| index 8a38c01ca6be1597837ae7a97d2a0ade72f898c8..f0d45c3e4b13ac708f4b8a32f332c0fa71fe8769 100644
|
| --- a/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| @@ -77,6 +77,62 @@ void MaybeUpdateOptInCancelUMA(const ArcSupportHost* support_host) {
|
|
|
| } // namespace
|
|
|
| +// This class is used to track statuses on OptIn flow. It is created in case ARC
|
| +// is activated, and it needs to OptIn. Once started OptInFlowResult::STARTED is
|
| +// recorded via UMA. If it finishes successfully OptInFlowResult::SUCCEEDED is
|
| +// recorded. Optional OptInFlowResult::SUCCEEDED_AFTER_RETRY is recorded in this
|
| +// case if an error occurred during OptIn flow, and user pressed Retry. In case
|
| +// the user cancels OptIn flow before it was completed then
|
| +// OptInFlowResult::CANCELED is recorded and if an error occurred optional
|
| +// OptInFlowResult::CANCELED_AFTER_ERROR. If a shutdown happens during the OptIn
|
| +// nothing is recorded, except initial OptInFlowResult::STARTED.
|
| +// OptInFlowResult::STARTED = OptInFlowResult::SUCCEEDED +
|
| +// OptInFlowResult::CANCELED + cases happened during the shutdown.
|
| +class ArcSessionManager::ScopedOptInFlowTracker {
|
| + public:
|
| + ScopedOptInFlowTracker() {
|
| + UpdateOptInFlowResultUMA(OptInFlowResult::STARTED);
|
| + }
|
| +
|
| + ~ScopedOptInFlowTracker() {
|
| + if (shutdown_)
|
| + return;
|
| +
|
| + UpdateOptInFlowResultUMA(success_ ? OptInFlowResult::SUCCEEDED
|
| + : OptInFlowResult::CANCELED);
|
| + if (error_) {
|
| + UpdateOptInFlowResultUMA(success_
|
| + ? OptInFlowResult::SUCCEEDED_AFTER_RETRY
|
| + : OptInFlowResult::CANCELED_AFTER_ERROR);
|
| + }
|
| + }
|
| +
|
| + // Tracks error occurred during the OptIn flow.
|
| + void TrackError() {
|
| + DCHECK(!success_ && !shutdown_);
|
| + error_ = true;
|
| + }
|
| +
|
| + // Tracks that OptIn finished successfully.
|
| + void TrackSuccess() {
|
| + DCHECK(!success_ && !shutdown_);
|
| + success_ = true;
|
| + }
|
| +
|
| + // Tracks that OptIn was not completed before shutdown.
|
| + void TrackShutdown() {
|
| + DCHECK(!success_ && !shutdown_);
|
| + shutdown_ = true;
|
| + }
|
| +
|
| + private:
|
| + bool error_ = false;
|
| + bool success_ = false;
|
| + bool shutdown_ = false;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ScopedOptInFlowTracker);
|
| +};
|
| +
|
| ArcSessionManager::ArcSessionManager(
|
| std::unique_ptr<ArcSessionRunner> arc_session_runner)
|
| : arc_session_runner_(std::move(arc_session_runner)),
|
| @@ -211,6 +267,8 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
|
| return;
|
| }
|
| provisioning_reported_ = true;
|
| + if (scoped_opt_in_tracker_ && result != ProvisioningResult::SUCCESS)
|
| + scoped_opt_in_tracker_->TrackError();
|
|
|
| if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) {
|
| if (IsArcKioskMode()) {
|
| @@ -240,6 +298,11 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
|
| if (support_host_)
|
| support_host_->Close();
|
|
|
| + if (scoped_opt_in_tracker_) {
|
| + scoped_opt_in_tracker_->TrackSuccess();
|
| + scoped_opt_in_tracker_.reset();
|
| + }
|
| +
|
| if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn))
|
| return;
|
|
|
| @@ -396,6 +459,10 @@ void ArcSessionManager::Shutdown() {
|
| context_.reset();
|
| profile_ = nullptr;
|
| SetState(State::NOT_INITIALIZED);
|
| + if (scoped_opt_in_tracker_) {
|
| + scoped_opt_in_tracker_->TrackShutdown();
|
| + scoped_opt_in_tracker_.reset();
|
| + }
|
| }
|
|
|
| void ArcSessionManager::ShutdownSession() {
|
| @@ -548,6 +615,7 @@ void ArcSessionManager::RequestDisable() {
|
| return;
|
| }
|
| enable_requested_ = false;
|
| + scoped_opt_in_tracker_.reset();
|
|
|
| // Reset any pending request to re-enable ARC.
|
| reenable_arc_ = false;
|
| @@ -602,6 +670,7 @@ void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() {
|
| support_host_->ShowError(
|
| ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false);
|
| }
|
| + UpdateOptInCancelUMA(OptInCancelReason::SESSION_BUSY);
|
| return;
|
| }
|
|
|
| @@ -609,6 +678,11 @@ void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() {
|
| // is fixed.
|
| SetState(State::NEGOTIATING_TERMS_OF_SERVICE);
|
|
|
| + if (!scoped_opt_in_tracker_ &&
|
| + !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
|
| + scoped_opt_in_tracker_ = base::MakeUnique<ScopedOptInFlowTracker>();
|
| + }
|
| +
|
| if (!IsArcTermsOfServiceNegotiationNeeded()) {
|
| // Moves to next state, Android management check, immediately, as if
|
| // Terms of Service negotiation is done successfully.
|
|
|