Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3913)

Unified Diff: chrome/browser/push_messaging/push_messaging_app_identifier.cc

Issue 1140873005: Push API: Avoid false positive DCHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_app_identifier_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/push_messaging/push_messaging_app_identifier.cc
diff --git a/chrome/browser/push_messaging/push_messaging_app_identifier.cc b/chrome/browser/push_messaging/push_messaging_app_identifier.cc
index 0c431e17a6fc8ca549f1f8474ac196f53d30a4bc..8d84fa293b659165d162ed933ecb6e25a5ce7b52 100644
--- a/chrome/browser/push_messaging/push_messaging_app_identifier.cc
+++ b/chrome/browser/push_messaging/push_messaging_app_identifier.cc
@@ -75,9 +75,15 @@ PushMessagingAppIdentifier PushMessagingAppIdentifier::Generate(
// static
PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByAppId(
Profile* profile, const std::string& app_id) {
- // Check case of app_id hasn't been mangled (crbug.com/461867).
- DCHECK_GE(app_id.size(), kPrefixLength + kGuidLength);
+ if (!StartsWithASCII(app_id, kPushMessagingAppIdentifierPrefix,
+ false /* case_sensitive */)) {
+ return PushMessagingAppIdentifier();
+ }
+
+ // Since we now know this is a Push Messaging app_id, check the case hasn't
+ // been mangled (crbug.com/461867).
DCHECK_EQ(kPushMessagingAppIdentifierPrefix, app_id.substr(0, kPrefixLength));
+ DCHECK_GE(app_id.size(), kPrefixLength + kGuidLength);
DCHECK_EQ(app_id.substr(app_id.size() - kGuidLength),
StringToUpperASCII(app_id.substr(app_id.size() - kGuidLength)));
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_app_identifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698