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

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

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.h
diff --git a/chrome/browser/chromeos/login/enrollment/enrollment_screen.h b/chrome/browser/chromeos/login/enrollment/enrollment_screen.h
index 6ccefec99d23346a24fbbc348a6d843afc5ca77c..82ef3481b1fae4dbe8a318db54c581d8592aad23 100644
--- a/chrome/browser/chromeos/login/enrollment/enrollment_screen.h
+++ b/chrome/browser/chromeos/login/enrollment/enrollment_screen.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/callback_forward.h"
+#include "base/cancelable_callback.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
@@ -19,6 +20,7 @@
#include "chrome/browser/chromeos/policy/enrollment_config.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/enterprise_metrics.h"
+#include "net/base/backoff_entry.h"
namespace base {
class ElapsedTimer;
@@ -81,6 +83,7 @@ class EnrollmentScreen
}
private:
+ friend class EnterpriseEnrollmentHelperMock;
FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestSuccess);
FRIEND_TEST_ALL_PREFIXES(AttestationAuthEnrollmentScreenTest, TestCancel);
FRIEND_TEST_ALL_PREFIXES(ForcedAttestationAuthEnrollmentScreenTest,
@@ -93,6 +96,9 @@ class EnrollmentScreen
FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest,
TestAuthCodeGetsProperlyReceivedFromGaia);
FRIEND_TEST_ALL_PREFIXES(HandsOffNetworkScreenTest, RequiresNoInput);
+ FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenUnitTest, Retries);
+ FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenUnitTest, DoesNotRetryOnTopOfUser);
+ FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenUnitTest, DoesNotRetryAfterSuccess);
// The authentication mechanisms that this class can use.
enum Auth {
@@ -144,6 +150,18 @@ class EnrollmentScreen
// Advance to the next authentication mechanism if possible.
bool AdvanceToNextAuth();
+ // Similar to OnRetry(), but responds to a timer instead of the user
+ // pressing the Retry button.
+ void AutomaticRetry();
+
+ // Processes a request to retry enrollment.
+ // Called by OnRetry() and AutomaticRetry().
+ void ProcessRetry();
+
+ // True if we are using Hands-Off Zero-Touch Attestation-Based Enterprise
+ // Enrollment.
+ bool UsingHandsOffEnrollment();
xiyuan 2017/02/01 23:01:51 nit: This can be moved to cc file as a helper func
+
pairing_chromeos::ControllerPairingController* shark_controller_ = nullptr;
EnrollmentScreenActor* actor_;
@@ -155,9 +173,19 @@ class EnrollmentScreen
std::string enrolling_user_domain_;
std::string auth_code_;
std::unique_ptr<base::ElapsedTimer> elapsed_timer_;
+ net::BackoffEntry::Policy retry_policy_;
+ std::unique_ptr<net::BackoffEntry> retry_backoff_;
+ base::CancelableClosure retry_task_;
+ int num_retries_ = 0;
std::unique_ptr<EnterpriseEnrollmentHelper> enrollment_helper_;
base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_;
+ // Retry policy constants.
+ static const int INITIAL_DELAY_MS = 4 * 1000; // 4 seconds
+ static constexpr double MULTIPLY_FACTOR = 1.5;
+ static constexpr double JITTER_FACTOR = 0.1; // +/- 10% jitter
+ static const int64_t MAX_DELAY_MS = 8 * 60 * 1000; // 8 minutes
xiyuan 2017/02/01 23:01:51 If those constants are not used outside the impl,
+
DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen);
};

Powered by Google App Engine
This is Rietveld 408576698