OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const std::string& receiver_id, | 60 const std::string& receiver_id, |
61 const GCMClient::OutgoingMessage& message, | 61 const GCMClient::OutgoingMessage& message, |
62 const SendCallback& callback); | 62 const SendCallback& callback); |
63 | 63 |
64 const GCMAppHandlerMap& app_handlers() const { return app_handlers_; } | 64 const GCMAppHandlerMap& app_handlers() const { return app_handlers_; } |
65 | 65 |
66 // This method must be called before destroying the GCMDriver. Once it has | 66 // This method must be called before destroying the GCMDriver. Once it has |
67 // been called, no other GCMDriver methods may be used. | 67 // been called, no other GCMDriver methods may be used. |
68 virtual void Shutdown(); | 68 virtual void Shutdown(); |
69 | 69 |
| 70 // Call this method when the user signs in to a GAIA account. |
| 71 // TODO(jianli): To be removed when sign-in enforcement is dropped. |
| 72 virtual void OnSignedIn() = 0; |
| 73 |
| 74 // Removes all the cached and persisted GCM data. If the GCM service is |
| 75 // restarted after the purge, a new Android ID will be obtained. |
| 76 virtual void Purge() = 0; |
| 77 |
70 // Adds a handler for a given app. | 78 // Adds a handler for a given app. |
71 virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler); | 79 virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler); |
72 | 80 |
73 // Remove the handler for a given app. | 81 // Remove the handler for a given app. |
74 virtual void RemoveAppHandler(const std::string& app_id); | 82 virtual void RemoveAppHandler(const std::string& app_id); |
75 | 83 |
76 // Enables/disables GCM service. | 84 // Enables/disables GCM service. |
77 virtual void Enable() = 0; | 85 virtual void Enable() = 0; |
78 virtual void Disable() = 0; | 86 virtual void Disable() = 0; |
79 | 87 |
(...skipping 12 matching lines...) Expand all Loading... |
92 // Get GCM client internal states and statistics. | 100 // Get GCM client internal states and statistics. |
93 // If clear_logs is true then activity logs will be cleared before the stats | 101 // If clear_logs is true then activity logs will be cleared before the stats |
94 // are returned. | 102 // are returned. |
95 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, | 103 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
96 bool clear_logs) = 0; | 104 bool clear_logs) = 0; |
97 | 105 |
98 // Enables/disables GCM activity recording, and then returns the stats. | 106 // Enables/disables GCM activity recording, and then returns the stats. |
99 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, | 107 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
100 bool recording) = 0; | 108 bool recording) = 0; |
101 | 109 |
102 // Returns the user name if the profile is signed in. Empty string otherwise. | |
103 virtual std::string SignedInUserName() const = 0; | |
104 | |
105 protected: | 110 protected: |
106 // Ensures that the GCM service starts (if necessary conditions are met). | 111 // Ensures that the GCM service starts (if necessary conditions are met). |
107 virtual GCMClient::Result EnsureStarted() = 0; | 112 virtual GCMClient::Result EnsureStarted() = 0; |
108 | 113 |
109 // Platform-specific implementation of Register. | 114 // Platform-specific implementation of Register. |
110 virtual void RegisterImpl(const std::string& app_id, | 115 virtual void RegisterImpl(const std::string& app_id, |
111 const std::vector<std::string>& sender_ids) = 0; | 116 const std::vector<std::string>& sender_ids) = 0; |
112 | 117 |
113 // Platform-specific implementation of Unregister. | 118 // Platform-specific implementation of Unregister. |
114 virtual void UnregisterImpl(const std::string& app_id) = 0; | 119 virtual void UnregisterImpl(const std::string& app_id) = 0; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 164 |
160 // The default handler when no app handler can be found in the map. | 165 // The default handler when no app handler can be found in the map. |
161 DefaultGCMAppHandler default_app_handler_; | 166 DefaultGCMAppHandler default_app_handler_; |
162 | 167 |
163 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 168 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
164 }; | 169 }; |
165 | 170 |
166 } // namespace gcm | 171 } // namespace gcm |
167 | 172 |
168 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 173 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
OLD | NEW |