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

Side by Side Diff: chrome/browser/history/text_database.cc

Issue 8984007: Revert 114929 - Standardize StringToInt{,64} interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 <limits> 5 #include <limits>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/history/text_database.h" 9 #include "chrome/browser/history/text_database.h"
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (file_name.length() < kIDStringLength) 104 if (file_name.length() < kIDStringLength)
105 return 0; 105 return 0;
106 const FilePath::StringType suffix( 106 const FilePath::StringType suffix(
107 &file_name[file_name.length() - kIDStringLength]); 107 &file_name[file_name.length() - kIDStringLength]);
108 108
109 if (suffix.length() != kIDStringLength || 109 if (suffix.length() != kIDStringLength ||
110 suffix[4] != FILE_PATH_LITERAL('-')) { 110 suffix[4] != FILE_PATH_LITERAL('-')) {
111 return 0; 111 return 0;
112 } 112 }
113 113
114 // TODO: Once StringPiece supports a templated interface over the
115 // underlying string type, use it here instead of substr, since that
116 // will avoid needless string copies. StringPiece cannot be used
117 // right now because FilePath::StringType could use either 8 or 16 bit
118 // characters, depending on the OS.
119 int year, month; 114 int year, month;
120 base::StringToInt(suffix.substr(0, 4), &year); 115 base::StringToInt(suffix.begin(), suffix.begin() + 4, &year);
121 base::StringToInt(suffix.substr(5, 2), &month); 116 base::StringToInt(suffix.begin() + 5, suffix.begin() + 7, &month);
122 117
123 return year * 100 + month; 118 return year * 100 + month;
124 } 119 }
125 120
126 bool TextDatabase::Init() { 121 bool TextDatabase::Init() {
127 // Make sure, if we're not allowed to create the file, that it exists. 122 // Make sure, if we're not allowed to create the file, that it exists.
128 if (!allow_create_) { 123 if (!allow_create_) {
129 if (!file_util::PathExists(file_name_)) 124 if (!file_util::PathExists(file_name_))
130 return false; 125 return false;
131 } 126 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } else { 375 } else {
381 // Since we got the results in order, we know the last item is the last 376 // Since we got the results in order, we know the last item is the last
382 // time we considered. 377 // time we considered.
383 *first_time_searched = results->back().time; 378 *first_time_searched = results->back().time;
384 } 379 }
385 380
386 statement.Reset(); 381 statement.Reset();
387 } 382 }
388 383
389 } // namespace history 384 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/component_updater_service.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698