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

Unified Diff: chrome/browser/chromeos/arc/arc_android_management_checker.h

Issue 2446563002: Refactor ArcAndroidManagementChecker. (Closed)
Patch Set: Created 4 years, 2 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/arc/arc_android_management_checker.h
diff --git a/chrome/browser/chromeos/arc/arc_android_management_checker.h b/chrome/browser/chromeos/arc/arc_android_management_checker.h
index 70dd884b2aca095e74297a96308b052703c9899c..5624143bd5af43c01a3294e53aa4526b755ab15e 100644
--- a/chrome/browser/chromeos/arc/arc_android_management_checker.h
+++ b/chrome/browser/chromeos/arc/arc_android_management_checker.h
@@ -7,55 +7,64 @@
#include <string>
+#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/policy/android_management_client.h"
#include "google_apis/gaia/oauth2_token_service.h"
+class Profile;
class ProfileOAuth2TokenService;
namespace arc {
-class ArcAndroidManagementCheckerDelegate;
-
class ArcAndroidManagementChecker : public OAuth2TokenService::Observer {
public:
- ArcAndroidManagementChecker(ArcAndroidManagementCheckerDelegate* delegate,
+ ArcAndroidManagementChecker(Profile* profile,
ProfileOAuth2TokenService* token_service,
const std::string& account_id,
- bool background_mode);
+ bool retry_on_error);
~ArcAndroidManagementChecker() override;
static void StartClient();
- // OAuth2TokenService::Observer:
- void OnRefreshTokenAvailable(const std::string& account_id) override;
- void OnRefreshTokensLoaded() override;
-
- bool background_mode() const { return background_mode_; }
+ // Starts the check. On completion |callback| will be invoked with the
+ // |result|. This cannot be called if there is inflight check.
Luis Héctor Chávez 2016/10/24 22:36:02 nit: s/cannot/must not/
hidehiko 2016/10/25 07:22:42 Done.
+ using CheckCallback =
+ base::Callback<void(policy::AndroidManagementClient::Result result)>;
+ void StartCheck(const CheckCallback& callback);
private:
- void StartCheck();
- void ScheduleCheck();
- void DispatchResult(policy::AndroidManagementClient::Result result);
+ void StartCheckInternal();
void OnAndroidManagementChecked(
policy::AndroidManagementClient::Result result);
+ void ScheduleRetry();
+
+ // Ensures the refresh token is loaded in the |token_service|.
+ void EnsureRefreshTokenLoaded();
+
+ // OAuth2TokenService::Observer:
+ void OnRefreshTokenAvailable(const std::string& account_id) override;
+ void OnRefreshTokensLoaded() override;
// Unowned pointers.
- ArcAndroidManagementCheckerDelegate* const delegate_;
+ Profile* profile_;
ProfileOAuth2TokenService* const token_service_;
const std::string account_id_;
- // In background mode errors are ignored and retry is attempted. There is no
- // retry in foreground mode and result is passed to delegate directly.
- bool background_mode_;
+ // If true, on error, instead of reporting the error to the caller, schedule
+ // the retry with delay.
+ const bool retry_on_error_;
- // Keeps current retry time for background mode.
+ // Keeps current retry time.
int retry_time_ms_;
Luis Héctor Chávez 2016/10/24 22:39:56 This looks like it can be a base::TimeDelta.
hidehiko 2016/10/25 07:22:42 Addressed in https://codereview.chromium.org/24506
policy::AndroidManagementClient android_management_client_;
+ // The callback for the inflight operation.
+ CheckCallback callback_;
+
base::WeakPtrFactory<ArcAndroidManagementChecker> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ArcAndroidManagementChecker);

Powered by Google App Engine
This is Rietveld 408576698