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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_app_identifier.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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
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 (!StartsWithASCII(app_id, kPushMessagingAppIdentifierPrefix, 78 if (!base::StartsWithASCII(app_id, kPushMessagingAppIdentifierPrefix,
79 false /* case_sensitive */)) { 79 false /* case_sensitive */)) {
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698