Chromium Code Reviews| 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_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ | 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ |
| 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ | 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 | 36 |
| 37 // Returns whether the modern InstanceID API should be used with this app_id | 37 // Returns whether the modern InstanceID API should be used with this app_id |
| 38 // (rather than legacy GCM registration). | 38 // (rather than legacy GCM registration). |
| 39 static bool UseInstanceID(const std::string& app_id); | 39 static bool UseInstanceID(const std::string& app_id); |
| 40 | 40 |
| 41 // Generates a new app identifier, with partially random app_id. | 41 // Generates a new app identifier, with partially random app_id. |
| 42 static PushMessagingAppIdentifier Generate( | 42 static PushMessagingAppIdentifier Generate( |
| 43 const GURL& origin, | 43 const GURL& origin, |
| 44 int64_t service_worker_registration_id); | 44 int64_t service_worker_registration_id); |
| 45 | 45 |
| 46 // Generates a new app identifier for legacy GCM (not modern InstanceID). | |
| 47 static PushMessagingAppIdentifier LegacyGenerateForTesting( | |
|
Peter Beverloo
2017/03/20 23:50:13
It's unfortunate that this has to be public. Can w
johnme
2017/03/30 18:36:37
Done.
| |
| 48 const GURL& origin, | |
| 49 int64_t service_worker_registration_id); | |
| 50 | |
| 46 // Looks up an app identifier by app_id. If not found, is_null() will be true. | 51 // Looks up an app identifier by app_id. If not found, is_null() will be true. |
| 47 static PushMessagingAppIdentifier FindByAppId(Profile* profile, | 52 static PushMessagingAppIdentifier FindByAppId(Profile* profile, |
| 48 const std::string& app_id); | 53 const std::string& app_id); |
| 49 | 54 |
| 50 // Looks up an app identifier by origin & service worker registration id. | 55 // Looks up an app identifier by origin & service worker registration id. |
| 51 // If not found, is_null() will be true. | 56 // If not found, is_null() will be true. |
| 52 static PushMessagingAppIdentifier FindByServiceWorker( | 57 static PushMessagingAppIdentifier FindByServiceWorker( |
| 53 Profile* profile, | 58 Profile* profile, |
| 54 const GURL& origin, | 59 const GURL& origin, |
| 55 int64_t service_worker_registration_id); | 60 int64_t service_worker_registration_id); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 99 |
| 95 int64_t service_worker_registration_id() const { | 100 int64_t service_worker_registration_id() const { |
| 96 DCHECK(!is_null()); | 101 DCHECK(!is_null()); |
| 97 return service_worker_registration_id_; | 102 return service_worker_registration_id_; |
| 98 } | 103 } |
| 99 | 104 |
| 100 private: | 105 private: |
| 101 friend class PushMessagingAppIdentifierTest; | 106 friend class PushMessagingAppIdentifierTest; |
| 102 FRIEND_TEST_ALL_PREFIXES(PushMessagingAppIdentifierTest, FindLegacy); | 107 FRIEND_TEST_ALL_PREFIXES(PushMessagingAppIdentifierTest, FindLegacy); |
| 103 | 108 |
| 109 static PushMessagingAppIdentifier GenerateInternal( | |
| 110 const GURL& origin, | |
| 111 int64_t service_worker_registration_id, | |
| 112 bool use_instance_id); | |
| 113 | |
| 104 // Constructs an invalid app identifier. | 114 // Constructs an invalid app identifier. |
| 105 PushMessagingAppIdentifier(); | 115 PushMessagingAppIdentifier(); |
| 106 // Constructs a valid app identifier. | 116 // Constructs a valid app identifier. |
| 107 PushMessagingAppIdentifier(const std::string& app_id, | 117 PushMessagingAppIdentifier(const std::string& app_id, |
| 108 const GURL& origin, | 118 const GURL& origin, |
| 109 int64_t service_worker_registration_id); | 119 int64_t service_worker_registration_id); |
| 110 | 120 |
| 111 // Validates that all the fields contain valid values. | 121 // Validates that all the fields contain valid values. |
| 112 void DCheckValid() const; | 122 void DCheckValid() const; |
| 113 | 123 |
| 114 std::string app_id_; | 124 std::string app_id_; |
| 115 GURL origin_; | 125 GURL origin_; |
| 116 int64_t service_worker_registration_id_; | 126 int64_t service_worker_registration_id_; |
| 117 }; | 127 }; |
| 118 | 128 |
| 119 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ | 129 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ |
| OLD | NEW |