OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 int year, month; | 114 int year, month; |
115 base::StringToInt(suffix.substr(0, 4), &year); | 115 base::StringToInt(suffix.begin(), suffix.begin() + 4, &year); |
116 base::StringToInt(suffix.substr(5, 2), &month); | 116 base::StringToInt(suffix.begin() + 5, suffix.begin() + 7, &month); |
117 | 117 |
118 return year * 100 + month; | 118 return year * 100 + month; |
119 } | 119 } |
120 | 120 |
121 bool TextDatabase::Init() { | 121 bool TextDatabase::Init() { |
122 // 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. |
123 if (!allow_create_) { | 123 if (!allow_create_) { |
124 if (!file_util::PathExists(file_name_)) | 124 if (!file_util::PathExists(file_name_)) |
125 return false; | 125 return false; |
126 } | 126 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } else { | 374 } else { |
375 // Since we got the results in order, we know the last item is the last | 375 // Since we got the results in order, we know the last item is the last |
376 // time we considered. | 376 // time we considered. |
377 *first_time_searched = results->back().time; | 377 *first_time_searched = results->back().time; |
378 } | 378 } |
379 | 379 |
380 statement.Reset(); | 380 statement.Reset(); |
381 } | 381 } |
382 | 382 |
383 } // namespace history | 383 } // namespace history |
OLD | NEW |