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

Side by Side Diff: chrome/common/string_ordinal.cc

Issue 8198003: Convert app_launch_index and page_index from int to StringOrdinal. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressing review comments Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/string_ordinal.h" 5 #include "chrome/common/string_ordinal.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstddef> 8 #include <cstddef>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 StringOrdinal::StringOrdinal(const std::string& string_ordinal) 168 StringOrdinal::StringOrdinal(const std::string& string_ordinal)
169 : string_ordinal_(string_ordinal), 169 : string_ordinal_(string_ordinal),
170 is_valid_(IsValidStringOrdinal(string_ordinal_)) { 170 is_valid_(IsValidStringOrdinal(string_ordinal_)) {
171 } 171 }
172 172
173 StringOrdinal::StringOrdinal() : string_ordinal_(""), 173 StringOrdinal::StringOrdinal() : string_ordinal_(""),
174 is_valid_(false) { 174 is_valid_(false) {
175 } 175 }
176 176
177 StringOrdinal StringOrdinal::CreateInitialOrdinal() {
178 return StringOrdinal(std::string(1, kMidDigit));
179 }
180
177 bool StringOrdinal::IsValid() const { 181 bool StringOrdinal::IsValid() const {
178 return is_valid_; 182 return is_valid_;
179 } 183 }
180 184
181 bool StringOrdinal::LessThan(const StringOrdinal& other) const { 185 bool StringOrdinal::LessThan(const StringOrdinal& other) const {
182 CHECK(IsValid()); 186 CHECK(IsValid());
183 CHECK(other.IsValid()); 187 CHECK(other.IsValid());
184 return string_ordinal_ < other.string_ordinal_; 188 return string_ordinal_ < other.string_ordinal_;
185 } 189 }
186 190
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Even though |end| is already a valid StringOrdinal that is greater than 235 // Even though |end| is already a valid StringOrdinal that is greater than
232 // |*this|, we don't return it because we wouldn't have much space after 236 // |*this|, we don't return it because we wouldn't have much space after
233 // it to insert potential future values. 237 // it to insert potential future values.
234 return CreateBetween(StringOrdinal(end)); 238 return CreateBetween(StringOrdinal(end));
235 } 239 }
236 240
237 std::string StringOrdinal::ToString() const { 241 std::string StringOrdinal::ToString() const {
238 CHECK(IsValid()); 242 CHECK(IsValid());
239 return string_ordinal_; 243 return string_ordinal_;
240 } 244 }
245
246 bool StringOrdinalLessThan::operator() (const StringOrdinal& lhs,
247 const StringOrdinal& rhs) const {
248 return lhs.LessThan(rhs);
249 }
OLDNEW
« chrome/browser/ui/webui/ntp/app_launcher_handler.cc ('K') | « chrome/common/string_ordinal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698