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

Unified Diff: chrome/browser/chromeos/login/enrollment/enrollment_screen.cc

Issue 2526973002: Added retry policy (Closed)
Patch Set: Addressed more comments Created 3 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
diff --git a/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc b/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
index 6652c6b9e495a9454085bcefd59c4ebf3dd0325d..ffeb939600f25d880a21a4a39e0693512a29f2f7 100644
--- a/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
+++ b/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
@@ -66,7 +66,16 @@ EnrollmentScreen::EnrollmentScreen(BaseScreenDelegate* base_screen_delegate,
EnrollmentScreenActor* actor)
: BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_ENROLLMENT),
actor_(actor),
- weak_ptr_factory_(this) {}
+ weak_ptr_factory_(this) {
+ retry_policy_.num_errors_to_ignore = 0;
+ retry_policy_.initial_delay_ms = INITIAL_DELAY_MS;
+ retry_policy_.multiply_factor = MULTIPLY_FACTOR;
+ retry_policy_.jitter_factor = JITTER_FACTOR;
+ retry_policy_.maximum_backoff_ms = MAX_DELAY_MS;
+ retry_policy_.entry_lifetime_ms = -1;
+ retry_policy_.always_use_initial_delay = true;
+ retry_backoff_.reset(new net::BackoffEntry(&retry_policy_));
+}
EnrollmentScreen::~EnrollmentScreen() {
DCHECK(!enrollment_helper_ || g_browser_process->IsShuttingDown());
@@ -190,6 +199,24 @@ void EnrollmentScreen::OnLoginDone(const std::string& user,
}
void EnrollmentScreen::OnRetry() {
+ retry_task_.Cancel();
+ LOG(WARNING) << "Enrollment retry " << ++num_retries_
xiyuan 2017/02/01 23:01:51 Use a separate line for the increment instead of i
+ << " initiated by user button press.";
+ ProcessRetry();
+}
+
+void EnrollmentScreen::AutomaticRetry() {
+ retry_backoff_->InformOfRequest(false);
+ retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry,
+ weak_ptr_factory_.GetWeakPtr()));
+
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE, retry_task_.callback(), retry_backoff_->GetTimeUntilRelease());
+ LOG(WARNING) << "Enrollment retry " << ++num_retries_
xiyuan 2017/02/01 23:01:51 smilar here, move ++num_retries_ out of LOG line.
+ << " initiated by timer.";
+}
+
+void EnrollmentScreen::ProcessRetry() {
Show();
}
@@ -243,16 +270,21 @@ void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
// based enrollment and we have a fallback authentication, show it.
if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED &&
status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND &&
- current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth())
+ current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) {
Show();
- else
+ } else {
actor_->ShowEnrollmentStatus(status);
+ if (UsingHandsOffEnrollment())
+ AutomaticRetry();
+ }
}
void EnrollmentScreen::OnOtherError(
EnterpriseEnrollmentHelper::OtherError error) {
RecordEnrollmentErrorMetrics();
actor_->ShowOtherError(error);
+ if (UsingHandsOffEnrollment())
+ AutomaticRetry();
}
void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) {
@@ -323,6 +355,7 @@ void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) {
}
void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() {
+ retry_backoff_->InformOfRequest(true);
if (elapsed_timer_)
UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_);
actor_->ShowEnrollmentStatus(
@@ -345,4 +378,10 @@ void EnrollmentScreen::RecordEnrollmentErrorMetrics() {
UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_);
}
+bool EnrollmentScreen::UsingHandsOffEnrollment() {
+ return policy::DeviceCloudPolicyManagerChromeOS::
+ GetZeroTouchEnrollmentMode() ==
+ policy::ZeroTouchEnrollmentMode::HANDS_OFF;
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698