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

Side by Side Diff: components/user_manager/user_image/default_user_images.cc

Issue 1242023005: Remove legacy StartsWithASCII function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: y Created 5 years, 5 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 "components/user_manager/user_image/default_user_images.h" 5 #include "components/user_manager/user_image/default_user_images.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return base::StringPrintf("%s%d", prefix.c_str(), index); 72 return base::StringPrintf("%s%d", prefix.c_str(), index);
73 } 73 }
74 74
75 // Returns true if the string specified consists of the prefix and one of 75 // Returns true if the string specified consists of the prefix and one of
76 // the default images indices. Returns the index of the image in |image_id| 76 // the default images indices. Returns the index of the image in |image_id|
77 // variable. 77 // variable.
78 bool IsDefaultImageString(const std::string& s, 78 bool IsDefaultImageString(const std::string& s,
79 const std::string& prefix, 79 const std::string& prefix,
80 int* image_id) { 80 int* image_id) {
81 DCHECK(image_id); 81 DCHECK(image_id);
82 if (!base::StartsWithASCII(s, prefix, true)) 82 if (!base::StartsWith(s, prefix, base::CompareCase::SENSITIVE))
83 return false; 83 return false;
84 84
85 int image_index = -1; 85 int image_index = -1;
86 if (base::StringToInt(base::StringPiece(s.begin() + prefix.length(), s.end()), 86 if (base::StringToInt(base::StringPiece(s.begin() + prefix.length(), s.end()),
87 &image_index)) { 87 &image_index)) {
88 if (image_index < 0 || image_index >= kDefaultImagesCount) 88 if (image_index < 0 || image_index >= kDefaultImagesCount)
89 return false; 89 return false;
90 *image_id = image_index; 90 *image_id = image_index;
91 return true; 91 return true;
92 } 92 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 int GetDefaultImageHistogramValue(int index) { 253 int GetDefaultImageHistogramValue(int index) {
254 DCHECK(index >= 0 && index < kDefaultImagesCount); 254 DCHECK(index >= 0 && index < kDefaultImagesCount);
255 // Create a gap in histogram values for 255 // Create a gap in histogram values for
256 // [kHistogramImageFromCamera..kHistogramImageFromProfile] block to fit. 256 // [kHistogramImageFromCamera..kHistogramImageFromProfile] block to fit.
257 if (index < kHistogramImageFromCamera) 257 if (index < kHistogramImageFromCamera)
258 return index; 258 return index;
259 return index + 6; 259 return index + 6;
260 } 260 }
261 261
262 } // namespace user_manager 262 } // namespace user_manager
OLDNEW
« no previous file with comments | « components/url_fixer/url_fixer.cc ('k') | components/variations/net/variations_http_header_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698