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

Unified Diff: components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h

Issue 1248533003: Hook up CryptAuthGCMManager to the enrollment and device sync managers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix webui Created 5 years, 5 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: components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h
diff --git a/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h b/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h
index f5558bcbd842c5f627de1870d95dc4a36e7d5ca9..4dd8d1743405d579effc72f59f2292a8cf3e43b0 100644
--- a/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h
+++ b/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h
@@ -9,6 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
+#include "components/proximity_auth/cryptauth/cryptauth_gcm_manager.h"
#include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h"
#include "components/proximity_auth/cryptauth/sync_scheduler.h"
@@ -29,7 +30,8 @@ class CryptAuthEnrollerFactory;
// re-enrolling to keep the state on the server fresh. If an enrollment fails,
// the manager will schedule the next enrollment more aggressively to recover
// from the failure.
-class CryptAuthEnrollmentManager : public SyncScheduler::Delegate {
+class CryptAuthEnrollmentManager : public SyncScheduler::Delegate,
+ public CryptAuthGCMManager::Observer {
public:
class Observer {
public:
@@ -51,6 +53,9 @@ class CryptAuthEnrollmentManager : public SyncScheduler::Delegate {
// |user_private_key|: The corresponding private key to |user_public_key|.
// |device_info|: Contains information about the local device that will be
// uploaded to CryptAuth with each enrollment request.
+ // |gcm_manager|: Used to perform GCM registrations and also notifies when GCM
+ // push messages trigger re-enrollments.
+ // Not owned and must outlive this instance.
// |pref_service|: Contains preferences across browser restarts, and should
// have been registered through RegisterPrefs().
CryptAuthEnrollmentManager(
@@ -59,6 +64,7 @@ class CryptAuthEnrollmentManager : public SyncScheduler::Delegate {
const std::string& user_public_key,
const std::string& user_private_key,
const cryptauth::GcmDeviceInfo& device_info,
+ CryptAuthGCMManager* gcm_manager,
PrefService* pref_service);
~CryptAuthEnrollmentManager() override;
@@ -105,10 +111,17 @@ class CryptAuthEnrollmentManager : public SyncScheduler::Delegate {
virtual scoped_ptr<SyncScheduler> CreateSyncScheduler();
private:
+ // CryptAuthGCMManager::Observer:
+ void OnGCMRegistrationResult(bool success) override;
+ void OnReenrollMessage() override;
+
// SyncScheduler::Delegate:
void OnSyncRequested(
scoped_ptr<SyncScheduler::SyncRequest> sync_request) override;
+ // Starts a CryptAuth enrollment attempt.
+ void DoCryptAuthEnrollment();
+
// Callback when |cryptauth_enroller_| completes.
void OnEnrollmentFinished(bool success);
@@ -125,6 +138,10 @@ class CryptAuthEnrollmentManager : public SyncScheduler::Delegate {
// The local device information to upload to CryptAuth.
const cryptauth::GcmDeviceInfo device_info_;
+ // Used to perform GCM registrations and also notifies when GCM push messages
+ // trigger re-enrollments. Not owned and must outlive this instance.
+ CryptAuthGCMManager* gcm_manager_;
+
// Contains perferences that outlive the lifetime of this object and across
// process restarts.
// Not owned and must outlive this instance.

Powered by Google App Engine
This is Rietveld 408576698