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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 PushMessagingAppIdentifier app_identifier(app_id, origin, | 69 PushMessagingAppIdentifier app_identifier(app_id, origin, |
70 service_worker_registration_id); | 70 service_worker_registration_id); |
71 app_identifier.DCheckValid(); | 71 app_identifier.DCheckValid(); |
72 return app_identifier; | 72 return app_identifier; |
73 } | 73 } |
74 | 74 |
75 // static | 75 // static |
76 PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByAppId( | 76 PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByAppId( |
77 Profile* profile, const std::string& app_id) { | 77 Profile* profile, const std::string& app_id) { |
78 if (!base::StartsWithASCII(app_id, kPushMessagingAppIdentifierPrefix, | 78 if (!base::StartsWith(app_id, kPushMessagingAppIdentifierPrefix, |
79 false /* case_sensitive */)) { | 79 base::CompareCase::INSENSITIVE_ASCII)) { |
80 return PushMessagingAppIdentifier(); | 80 return PushMessagingAppIdentifier(); |
81 } | 81 } |
82 | 82 |
83 // Since we now know this is a Push Messaging app_id, check the case hasn't | 83 // Since we now know this is a Push Messaging app_id, check the case hasn't |
84 // been mangled (crbug.com/461867). | 84 // been mangled (crbug.com/461867). |
85 DCHECK_EQ(kPushMessagingAppIdentifierPrefix, app_id.substr(0, kPrefixLength)); | 85 DCHECK_EQ(kPushMessagingAppIdentifierPrefix, app_id.substr(0, kPrefixLength)); |
86 DCHECK_GE(app_id.size(), kPrefixLength + kGuidLength); | 86 DCHECK_GE(app_id.size(), kPrefixLength + kGuidLength); |
87 DCHECK_EQ(app_id.substr(app_id.size() - kGuidLength), | 87 DCHECK_EQ(app_id.substr(app_id.size() - kGuidLength), |
88 base::StringToUpperASCII( | 88 base::StringToUpperASCII( |
89 app_id.substr(app_id.size() - kGuidLength))); | 89 app_id.substr(app_id.size() - kGuidLength))); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 const size_t suffix_length = 1 /* kSeparator */ + kGuidLength; | 200 const size_t suffix_length = 1 /* kSeparator */ + kGuidLength; |
201 DCHECK(app_id_.size() > kPrefixLength + suffix_length); | 201 DCHECK(app_id_.size() > kPrefixLength + suffix_length); |
202 DCHECK_EQ(origin_, GURL(app_id_.substr( | 202 DCHECK_EQ(origin_, GURL(app_id_.substr( |
203 kPrefixLength, app_id_.size() - kPrefixLength - suffix_length))); | 203 kPrefixLength, app_id_.size() - kPrefixLength - suffix_length))); |
204 DCHECK_EQ(std::string(1, kSeparator), | 204 DCHECK_EQ(std::string(1, kSeparator), |
205 app_id_.substr(app_id_.size() - suffix_length, 1)); | 205 app_id_.substr(app_id_.size() - suffix_length, 1)); |
206 } | 206 } |
207 // GUID | 207 // GUID |
208 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); | 208 DCHECK(base::IsValidGUID(app_id_.substr(app_id_.size() - kGuidLength))); |
209 } | 209 } |
OLD | NEW |