Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 2556273002: [Merge-M56] arc: Fix double provisioning failure reporting. (Closed)
Patch Set: resolve conflicts Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/chromeos/arc/arc_auth_service.h" 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 499
500 void ArcAuthService::OnProvisioningFinished(ProvisioningResult result) { 500 void ArcAuthService::OnProvisioningFinished(ProvisioningResult result) {
501 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 501 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
502 502
503 // Due asynchronous nature of stopping Arc bridge, OnProvisioningFinished may 503 // Due asynchronous nature of stopping Arc bridge, OnProvisioningFinished may
504 // arrive after setting the |State::STOPPED| state and |State::Active| is not 504 // arrive after setting the |State::STOPPED| state and |State::Active| is not
505 // guaranty set here. prefs::kArcDataRemoveRequested is also can be active 505 // guaranty set here. prefs::kArcDataRemoveRequested is also can be active
506 // for now. 506 // for now.
507 507
508 if (provisioning_reported_) {
509 // We don't expect ProvisioningResult::SUCCESS is reported twice or reported
510 // after an error.
511 DCHECK_NE(result, ProvisioningResult::SUCCESS);
512 // TODO (khmel): Consider changing LOG to NOTREACHED once we guaranty that
513 // no double message can happen in production.
514 LOG(WARNING) << " Provisioning result was already reported. Ignoring "
515 << " additional result " << static_cast<int>(result) << ".";
516 return;
517 }
518 provisioning_reported_ = true;
519
508 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { 520 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) {
509 // For backwards compatibility, use NETWORK_ERROR for 521 // For backwards compatibility, use NETWORK_ERROR for
510 // CHROME_SERVER_COMMUNICATION_ERROR case. 522 // CHROME_SERVER_COMMUNICATION_ERROR case.
511 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 523 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
512 } else if (!sign_in_time_.is_null()) { 524 } else if (!sign_in_time_.is_null()) {
513 arc_sign_in_timer_.Stop(); 525 arc_sign_in_timer_.Stop();
514 526
515 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, 527 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_,
516 result == ProvisioningResult::SUCCESS, 528 result == ProvisioningResult::SUCCESS,
517 policy_util::IsAccountManaged(profile_)); 529 policy_util::IsAccountManaged(profile_));
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 reenable_arc_ = true; 863 reenable_arc_ = true;
852 StopArc(); 864 StopArc();
853 } 865 }
854 866
855 void ArcAuthService::StartArc() { 867 void ArcAuthService::StartArc() {
856 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 868 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
857 869
858 // Arc must be started only if no pending data removal request exists. 870 // Arc must be started only if no pending data removal request exists.
859 DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); 871 DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested));
860 872
873 provisioning_reported_ = false;
874
861 arc_bridge_service()->RequestStart(); 875 arc_bridge_service()->RequestStart();
862 SetState(State::ACTIVE); 876 SetState(State::ACTIVE);
863 } 877 }
864 878
865 void ArcAuthService::OnAuthCodeObtained(const std::string& auth_code) { 879 void ArcAuthService::OnAuthCodeObtained(const std::string& auth_code) {
866 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 880 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
867 DCHECK(!auth_code.empty()); 881 DCHECK(!auth_code.empty());
868 882
869 account_info_notifier_->Notify(!IsOptInVerificationDisabled(), auth_code, 883 account_info_notifier_->Notify(!IsOptInVerificationDisabled(), auth_code,
870 GetAccountType(), 884 GetAccountType(),
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 return os << "ACTIVE"; 1149 return os << "ACTIVE";
1136 } 1150 }
1137 1151
1138 // Some compiler reports an error even if all values of an enum-class are 1152 // Some compiler reports an error even if all values of an enum-class are
1139 // covered indivisually in a switch statement. 1153 // covered indivisually in a switch statement.
1140 NOTREACHED(); 1154 NOTREACHED();
1141 return os; 1155 return os;
1142 } 1156 }
1143 1157
1144 } // namespace arc 1158 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | chrome/browser/chromeos/arc/arc_auth_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698