| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 static GCMEnabledState GetGCMEnabledState(Profile* profile); | 67 static GCMEnabledState GetGCMEnabledState(Profile* profile); |
| 68 | 68 |
| 69 // Register profile-specific prefs for GCM. | 69 // Register profile-specific prefs for GCM. |
| 70 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 70 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 71 | 71 |
| 72 explicit GCMProfileService(Profile* profile); | 72 explicit GCMProfileService(Profile* profile); |
| 73 virtual ~GCMProfileService(); | 73 virtual ~GCMProfileService(); |
| 74 | 74 |
| 75 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory); | 75 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory); |
| 76 | 76 |
| 77 void Start(); |
| 78 |
| 79 void Stop(); |
| 80 |
| 77 // Registers |sender_id| for an app. A registration ID will be returned by | 81 // Registers |sender_id| for an app. A registration ID will be returned by |
| 78 // the GCM server. | 82 // the GCM server. |
| 79 // |app_id|: application ID. | 83 // |app_id|: application ID. |
| 80 // |cert|: SHA-1 of public key of the application, in base16 format. | 84 // |cert|: SHA-1 of public key of the application, in base16 format. |
| 81 // |sender_ids|: list of IDs of the servers that are allowed to send the | 85 // |sender_ids|: list of IDs of the servers that are allowed to send the |
| 82 // messages to the application. These IDs are assigned by the | 86 // messages to the application. These IDs are assigned by the |
| 83 // Google API Console. | 87 // Google API Console. |
| 84 // |callback|: to be called once the asynchronous operation is done. | 88 // |callback|: to be called once the asynchronous operation is done. |
| 85 virtual void Register(const std::string& app_id, | 89 virtual void Register(const std::string& app_id, |
| 86 const std::vector<std::string>& sender_ids, | 90 const std::vector<std::string>& sender_ids, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 125 |
| 122 // Overridden from content::NotificationObserver: | 126 // Overridden from content::NotificationObserver: |
| 123 virtual void Observe(int type, | 127 virtual void Observe(int type, |
| 124 const content::NotificationSource& source, | 128 const content::NotificationSource& source, |
| 125 const content::NotificationDetails& details) OVERRIDE; | 129 const content::NotificationDetails& details) OVERRIDE; |
| 126 | 130 |
| 127 // Ensures that the GCMClient is loaded and the GCM check-in is done when | 131 // Ensures that the GCMClient is loaded and the GCM check-in is done when |
| 128 // the profile was signed in. | 132 // the profile was signed in. |
| 129 void EnsureLoaded(); | 133 void EnsureLoaded(); |
| 130 | 134 |
| 135 // Remove cached or persisted data when GCM service is stopped. |
| 136 void RemoveCachedData(); |
| 137 void RemovePersistedData(); |
| 138 |
| 131 // Checks out of GCM when the profile has been signed out. This will erase | 139 // Checks out of GCM when the profile has been signed out. This will erase |
| 132 // all the cached and persisted data. | 140 // all the cached and persisted data. |
| 133 void CheckOut(); | 141 void CheckOut(); |
| 134 | 142 |
| 135 // Resets the GCMClient instance. This is called when the profile is being | 143 // Resets the GCMClient instance. This is called when the profile is being |
| 136 // destroyed. | 144 // destroyed. |
| 137 void ResetGCMClient(); | 145 void ResetGCMClient(); |
| 138 | 146 |
| 139 // Ensures that the app is ready for GCM functions and events. | 147 // Ensures that the app is ready for GCM functions and events. |
| 140 void EnsureAppReady(const std::string& app_id); | 148 void EnsureAppReady(const std::string& app_id); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 228 |
| 221 // Used to pass a weak pointer to the IO worker. | 229 // Used to pass a weak pointer to the IO worker. |
| 222 base::WeakPtrFactory<GCMProfileService> weak_ptr_factory_; | 230 base::WeakPtrFactory<GCMProfileService> weak_ptr_factory_; |
| 223 | 231 |
| 224 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); | 232 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); |
| 225 }; | 233 }; |
| 226 | 234 |
| 227 } // namespace gcm | 235 } // namespace gcm |
| 228 | 236 |
| 229 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 237 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| OLD | NEW |