Update mojo sdk to rev c02a28868825edfa57ab77947b8cb15e741c5598
[chromium-blink-merge.git] / components / proximity_auth / cryptauth / cryptauth_gcm_manager.h
blob014ecf2a60459ac89dc6a30fb43f2f287bec191a
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
8 #include <string>
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 {
19 public:
20 class Observer {
21 public:
22 virtual ~Observer();
24 // Called when a gcm registration attempt finishes with the |success| of the
25 // attempt.
26 virtual void OnGCMRegistrationResult(bool success);
28 // Called when a GCM message is received to re-enroll the device with
29 // CryptAuth.
30 virtual void OnReenrollMessage();
32 // Called when a GCM message is received to sync down new devices from
33 // CryptAuth.
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
52 // will be returned.
53 virtual std::string GetRegistrationId() = 0;
55 // Adds an observer.
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