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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return origin_; | 92 return origin_; |
93 } | 93 } |
94 | 94 |
95 int64_t service_worker_registration_id() const { | 95 int64_t service_worker_registration_id() const { |
96 DCHECK(!is_null()); | 96 DCHECK(!is_null()); |
97 return service_worker_registration_id_; | 97 return service_worker_registration_id_; |
98 } | 98 } |
99 | 99 |
100 private: | 100 private: |
101 friend class PushMessagingAppIdentifierTest; | 101 friend class PushMessagingAppIdentifierTest; |
| 102 friend class PushMessagingBrowserTest; |
102 FRIEND_TEST_ALL_PREFIXES(PushMessagingAppIdentifierTest, FindLegacy); | 103 FRIEND_TEST_ALL_PREFIXES(PushMessagingAppIdentifierTest, FindLegacy); |
103 | 104 |
| 105 // Generates a new app identifier for legacy GCM (not modern InstanceID). |
| 106 static PushMessagingAppIdentifier LegacyGenerateForTesting( |
| 107 const GURL& origin, |
| 108 int64_t service_worker_registration_id); |
| 109 |
| 110 static PushMessagingAppIdentifier GenerateInternal( |
| 111 const GURL& origin, |
| 112 int64_t service_worker_registration_id, |
| 113 bool use_instance_id); |
| 114 |
104 // Constructs an invalid app identifier. | 115 // Constructs an invalid app identifier. |
105 PushMessagingAppIdentifier(); | 116 PushMessagingAppIdentifier(); |
106 // Constructs a valid app identifier. | 117 // Constructs a valid app identifier. |
107 PushMessagingAppIdentifier(const std::string& app_id, | 118 PushMessagingAppIdentifier(const std::string& app_id, |
108 const GURL& origin, | 119 const GURL& origin, |
109 int64_t service_worker_registration_id); | 120 int64_t service_worker_registration_id); |
110 | 121 |
111 // Validates that all the fields contain valid values. | 122 // Validates that all the fields contain valid values. |
112 void DCheckValid() const; | 123 void DCheckValid() const; |
113 | 124 |
114 std::string app_id_; | 125 std::string app_id_; |
115 GURL origin_; | 126 GURL origin_; |
116 int64_t service_worker_registration_id_; | 127 int64_t service_worker_registration_id_; |
117 }; | 128 }; |
118 | 129 |
119 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ | 130 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APP_IDENTIFIER_H_ |
OLD | NEW |