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 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 5 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // pref is read from the right profile, as prefs defined in a regular profile | 59 // pref is read from the right profile, as prefs defined in a regular profile |
| 60 // are visible in the corresponding incognito profile unless overridden. | 60 // are visible in the corresponding incognito profile unless overridden. |
| 61 // TODO(johnme): Make sure this pref doesn't get out of sync after crashes. | 61 // TODO(johnme): Make sure this pref doesn't get out of sync after crashes. |
| 62 registry->RegisterDictionaryPref(prefs::kPushMessagingAppIdentifierMap); | 62 registry->RegisterDictionaryPref(prefs::kPushMessagingAppIdentifierMap); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // static | 65 // static |
| 66 PushMessagingAppIdentifier PushMessagingAppIdentifier::Generate( | 66 PushMessagingAppIdentifier PushMessagingAppIdentifier::Generate( |
| 67 const GURL& origin, | 67 const GURL& origin, |
| 68 int64_t service_worker_registration_id) { | 68 int64_t service_worker_registration_id) { |
| 69 std::string guid = base::GenerateGUID(); | 69 // Always use the uppercased GUID to to make the case mangling handling |
|
johnme
2016/04/22 12:02:27
Nit: Keeping these uppercase makes sense, but the
kinuko
2016/04/25 14:24:37
Done.
| |
| 70 // easier (see the code commented with crbug.com/461867). | |
| 71 std::string guid = base::ToUpperASCII(base::GenerateGUID()); | |
| 70 CHECK(!guid.empty()); | 72 CHECK(!guid.empty()); |
| 71 std::string app_id = | 73 std::string app_id = |
| 72 kPushMessagingAppIdentifierPrefix + origin.spec() + kSeparator + guid; | 74 kPushMessagingAppIdentifierPrefix + origin.spec() + kSeparator + guid; |
| 73 | 75 |
| 74 PushMessagingAppIdentifier app_identifier(app_id, origin, | 76 PushMessagingAppIdentifier app_identifier(app_id, origin, |
| 75 service_worker_registration_id); | 77 service_worker_registration_id); |
| 76 app_identifier.DCheckValid(); | 78 app_identifier.DCheckValid(); |
| 77 return app_identifier; | 79 return app_identifier; |
| 78 } | 80 } |
| 79 | 81 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 DCHECK(app_id_.size() > kPrefixLength + suffix_length); | 210 DCHECK(app_id_.size() > kPrefixLength + suffix_length); |
| 209 DCHECK_EQ(origin_, GURL(app_id_.substr( | 211 DCHECK_EQ(origin_, GURL(app_id_.substr( |
| 210 kPrefixLength, | 212 kPrefixLength, |
| 211 app_id_.size() - kPrefixLength - suffix_length))); | 213 app_id_.size() - kPrefixLength - suffix_length))); |
| 212 DCHECK_EQ(std::string(1, kSeparator), | 214 DCHECK_EQ(std::string(1, kSeparator), |
| 213 app_id_.substr(app_id_.size() - suffix_length, 1)); | 215 app_id_.substr(app_id_.size() - suffix_length, 1)); |
| 214 } | 216 } |
| 215 // GUID | 217 // GUID |
| 216 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); | 218 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); |
| 217 } | 219 } |
| OLD | NEW |