| 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 CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 12 | 13 |
| 13 class Profile; | 14 class Profile; |
| 14 | 15 |
| 15 namespace user_prefs { | 16 namespace user_prefs { |
| 16 class PrefRegistrySyncable; | 17 class PrefRegistrySyncable; |
| 17 } | 18 } |
| 18 | 19 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 // Looks up an application id by app_id_guid. Will be invalid if not found. | 38 // Looks up an application id by app_id_guid. Will be invalid if not found. |
| 38 static PushMessagingApplicationId Get(Profile* profile, | 39 static PushMessagingApplicationId Get(Profile* profile, |
| 39 const std::string& app_id_guid); | 40 const std::string& app_id_guid); |
| 40 | 41 |
| 41 // Looks up an application id by origin & service worker registration id. | 42 // Looks up an application id by origin & service worker registration id. |
| 42 // Will be invalid if not found. | 43 // Will be invalid if not found. |
| 43 static PushMessagingApplicationId Get(Profile* profile, | 44 static PushMessagingApplicationId Get(Profile* profile, |
| 44 const GURL& origin, | 45 const GURL& origin, |
| 45 int64 service_worker_registration_id); | 46 int64 service_worker_registration_id); |
| 46 | 47 |
| 48 // Returns all the PushMessagingApplicationId currently registered for the |
| 49 // given |profile|. |
| 50 static std::vector<PushMessagingApplicationId> GetAll(Profile* profile); |
| 51 |
| 52 PushMessagingApplicationId(const PushMessagingApplicationId& other); |
| 47 ~PushMessagingApplicationId(); | 53 ~PushMessagingApplicationId(); |
| 48 | 54 |
| 49 // Persist this application id to disk. | 55 // Persist this application id to disk. |
| 50 void PersistToDisk(Profile* profile) const; | 56 void PersistToDisk(Profile* profile) const; |
| 51 | 57 |
| 52 // Delete this application id from disk. | 58 // Delete this application id from disk. |
| 53 void DeleteFromDisk(Profile* profile) const; // TODO: Does const make sense? | 59 void DeleteFromDisk(Profile* profile) const; // TODO: Does const make sense? |
| 54 | 60 |
| 55 bool IsValid() const; | 61 bool IsValid() const; |
| 56 | 62 |
| 57 const std::string app_id_guid; | 63 const std::string app_id_guid; |
| 58 const GURL origin; | 64 const GURL origin; |
| 59 const int64 service_worker_registration_id; | 65 const int64 service_worker_registration_id; |
| 60 | 66 |
| 61 private: | 67 private: |
| 62 friend class PushMessagingApplicationIdTest; | 68 friend class PushMessagingApplicationIdTest; |
| 63 | 69 |
| 64 // Constructs an invalid app id. | 70 // Constructs an invalid app id. |
| 65 PushMessagingApplicationId(); | 71 PushMessagingApplicationId(); |
| 66 // Constructs a valid app id. | 72 // Constructs a valid app id. |
| 67 PushMessagingApplicationId(const std::string& app_id_guid, | 73 PushMessagingApplicationId(const std::string& app_id_guid, |
| 68 const GURL& origin, | 74 const GURL& origin, |
| 69 int64 service_worker_registration_id); | 75 int64 service_worker_registration_id); |
| 70 }; | 76 }; |
| 71 | 77 |
| 72 } // namespace gcm | 78 } // namespace gcm |
| 73 | 79 |
| 74 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_ | 80 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_ |
| OLD | NEW |