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

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

Issue 2526973002: Added retry policy (Closed)
Patch Set: Addressed further comments Created 3 years, 10 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..e7830a215d8b095a70057ef821635ef2bbb685d7 100644
--- a/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
+++ b/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
@@ -52,6 +52,19 @@ const char * const kMetricEnrollmentTimeFailure =
const char * const kMetricEnrollmentTimeSuccess =
"Enterprise.EnrollmentTime.Success";
+// Retry policy constants.
+const int INITIAL_DELAY_MS = 4 * 1000; // 4 seconds
xiyuan 2017/02/03 23:34:14 nit: constant should be name as kTheConstantName,
kumarniranjan 2017/02/06 21:38:24 Done.
+const double MULTIPLY_FACTOR = 1.5;
+const double JITTER_FACTOR = 0.1; // +/- 10% jitter
+const int64_t MAX_DELAY_MS = 8 * 60 * 1000; // 8 minutes
+
+// Helper function. Returns true if we are using Hands Off Enrollment.
+bool UsingHandsOffEnrollment() {
+ return policy::DeviceCloudPolicyManagerChromeOS::
+ GetZeroTouchEnrollmentMode() ==
+ policy::ZeroTouchEnrollmentMode::HANDS_OFF;
+}
+
} // namespace
namespace chromeos {
@@ -66,7 +79,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 +212,22 @@ void EnrollmentScreen::OnLoginDone(const std::string& user,
}
void EnrollmentScreen::OnRetry() {
+ retry_task_.Cancel();
+ 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());
+}
+
+void EnrollmentScreen::ProcessRetry() {
+ num_retries_++;
xiyuan 2017/02/03 23:34:14 nit: use pre-increment, i.e. ++num_retries_;
kumarniranjan 2017/02/06 21:38:24 Done.
+ LOG(WARNING) << "Enrollment retry " << num_retries_;
Show();
}
@@ -243,16 +281,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 +366,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(

Powered by Google App Engine
This is Rietveld 408576698