1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_GCM_MANAGER_H
6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_GCM_MANAGER_H
10 class PrefRegistrySimple
;
12 namespace proximity_auth
{
14 // Interface for the manager controlling GCM registrations and handling GCM push
15 // messages for CryptAuth. CryptAuth sends GCM messages to request the local
16 // device to re-enroll to get the freshest device state, and to notify the
17 // local device to resync the remote device list when this list changes.
18 class CryptAuthGCMManager
{
24 // Called when a gcm registration attempt finishes with the |success| of the
26 virtual void OnGCMRegistrationResult(bool success
);
28 // Called when a GCM message is received to re-enroll the device with
30 virtual void OnReenrollMessage();
32 // Called when a GCM message is received to sync down new devices from
34 virtual void OnResyncMessage();
37 virtual ~CryptAuthGCMManager() {}
39 // Registers the prefs used by the manager to the given |pref_service|.
40 static void RegisterPrefs(PrefRegistrySimple
* registry
);
42 // Starts listening to incoming GCM messages. If GCM registration is completed
43 // after this function is called, then messages will also be handled properly.
44 virtual void StartListening() = 0;
46 // Begins registration with GCM. The Observer::OnGCMRegistrationResult()
47 // observer function will be called when registration completes.
48 virtual void RegisterWithGCM() = 0;
50 // Returns the GCM registration id received from the last successful
51 // registration. If registration has not been performed, then an empty string
53 virtual std::string
GetRegistrationId() = 0;
56 virtual void AddObserver(Observer
* observer
) = 0;
58 // Removes an observer.
59 virtual void RemoveObserver(Observer
* observer
) = 0;
62 } // namespace proximity_auth
64 #endif // COMPONENTS_PROXIMITY_CRYPTAUTH_CRYPTAUTH_GCM_MANAGER_H