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 when the sign-in occurs. | |
bartfab (slow)
2014/06/13 11:27:21
Nit: Could you reword this to make it more explici
jianli
2014/06/13 18:04:49
Done.
| |
71 // TODO(jianli): to be removed when sign-in enforcement is dropped. | |
72 virtual void SignIn() = 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 |
80 // For testing purpose. Always NULL on Android. | 88 // For testing purpose. Always NULL on Android. |
81 virtual GCMClient* GetGCMClientForTesting() const = 0; | 89 virtual GCMClient* GetGCMClientForTesting() const = 0; |
82 | 90 |
83 // Returns true if the service was started. | 91 // Returns true if the service was started. |
84 virtual bool IsStarted() const = 0; | 92 virtual bool IsStarted() const = 0; |
85 | 93 |
86 // Returns true if the gcm client is ready. | 94 // Returns true if the gcm client is ready. |
87 virtual bool IsGCMClientReady() const = 0; | 95 virtual bool IsGCMClientReady() const = 0; |
88 | 96 |
89 // Get GCM client internal states and statistics. | 97 // Get GCM client internal states and statistics. |
90 // If clear_logs is true then activity logs will be cleared before the stats | 98 // If clear_logs is true then activity logs will be cleared before the stats |
91 // are returned. | 99 // are returned. |
92 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, | 100 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
93 bool clear_logs) = 0; | 101 bool clear_logs) = 0; |
94 | 102 |
95 // Enables/disables GCM activity recording, and then returns the stats. | 103 // Enables/disables GCM activity recording, and then returns the stats. |
96 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, | 104 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
97 bool recording) = 0; | 105 bool recording) = 0; |
98 | 106 |
99 // Returns the user name if the profile is signed in. Empty string otherwise. | |
100 virtual std::string SignedInUserName() const = 0; | |
101 | |
102 protected: | 107 protected: |
103 // Ensures that the GCM service starts (if necessary conditions are met). | 108 // Ensures that the GCM service starts (if necessary conditions are met). |
104 virtual GCMClient::Result EnsureStarted() = 0; | 109 virtual GCMClient::Result EnsureStarted() = 0; |
105 | 110 |
106 // Platform-specific implementation of Register. | 111 // Platform-specific implementation of Register. |
107 virtual void RegisterImpl(const std::string& app_id, | 112 virtual void RegisterImpl(const std::string& app_id, |
108 const std::vector<std::string>& sender_ids) = 0; | 113 const std::vector<std::string>& sender_ids) = 0; |
109 | 114 |
110 // Platform-specific implementation of Unregister. | 115 // Platform-specific implementation of Unregister. |
111 virtual void UnregisterImpl(const std::string& app_id) = 0; | 116 virtual void UnregisterImpl(const std::string& app_id) = 0; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 | 161 |
157 // The default handler when no app handler can be found in the map. | 162 // The default handler when no app handler can be found in the map. |
158 DefaultGCMAppHandler default_app_handler_; | 163 DefaultGCMAppHandler default_app_handler_; |
159 | 164 |
160 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 165 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
161 }; | 166 }; |
162 | 167 |
163 } // namespace gcm | 168 } // namespace gcm |
164 | 169 |
165 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 170 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
OLD | NEW |