OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_GCM_MANAGER_H | |
6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_GCM_MANAGER_H | |
7 | |
8 #include <string> | |
9 | |
10 class PrefRegistrySimple; | |
11 | |
12 namespace proximity_auth { | |
13 | |
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(); | |
23 | |
24 // Called when a gcm registration attempt finishes with the |success| of the | |
25 // attempt. | |
26 virtual void OnGCMRegistrationResult(bool success); | |
27 | |
28 // Called when a GCM message is received to re-enroll the device with | |
29 // CryptAuth. | |
30 virtual void OnReenrollMessage(); | |
31 | |
32 // Called when a GCM message is received to sync down new devices from | |
33 // CryptAuth. | |
34 virtual void OnResyncMessage(); | |
35 }; | |
36 | |
37 virtual ~CryptAuthGCMManager() {} | |
38 | |
39 // Registers the prefs used by the manager to the given |pref_service|. | |
40 static void RegisterPrefs(PrefRegistrySimple* registry); | |
41 | |
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; | |
45 | |
46 // Begins registration with GCM. The Observer::OnGCMRegistrationResult() | |
47 // observer function will be called when registration completes. | |
48 virtual void RegisterWithGCM() = 0; | |
49 | |
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; | |
54 | |
55 // Adds an observer. | |
56 virtual void AddObserver(Observer* observer) = 0; | |
57 | |
58 // Removes an observer. | |
59 virtual void RemoveObserver(Observer* observer) = 0; | |
60 }; | |
61 | |
62 } // namespace proximity_auth | |
63 | |
64 #endif // COMPONENTS_PROXIMITY_CRYPTAUTH_CRYPTAUTH_GCM_MANAGER_H | |
OLD | NEW |