| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
| 8 #include "chrome/browser/history/text_database.h" | 8 #include "chrome/browser/history/text_database.h" |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // potentially be the wrong thing to do. Instead, we just look for a suffix. | 120 // potentially be the wrong thing to do. Instead, we just look for a suffix. |
| 121 static const size_t kIDStringLength = 7; // Room for "xxxx-xx". | 121 static const size_t kIDStringLength = 7; // Room for "xxxx-xx". |
| 122 if (file_name.length() < kIDStringLength) | 122 if (file_name.length() < kIDStringLength) |
| 123 return 0; | 123 return 0; |
| 124 const std::wstring suffix(&file_name[file_name.length() - kIDStringLength]); | 124 const std::wstring suffix(&file_name[file_name.length() - kIDStringLength]); |
| 125 | 125 |
| 126 if (suffix.length() != kIDStringLength || suffix[4] != L'-') { | 126 if (suffix.length() != kIDStringLength || suffix[4] != L'-') { |
| 127 return 0; | 127 return 0; |
| 128 } | 128 } |
| 129 | 129 |
| 130 int year = StringToInt(suffix.substr(0, 4)); | 130 int year = StringToInt(WideToUTF16Hack(suffix.substr(0, 4))); |
| 131 int month = StringToInt(suffix.substr(5, 2)); | 131 int month = StringToInt(WideToUTF16Hack(suffix.substr(5, 2))); |
| 132 | 132 |
| 133 return year * 100 + month; | 133 return year * 100 + month; |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool TextDatabase::Init() { | 136 bool TextDatabase::Init() { |
| 137 // Make sure, if we're not allowed to create the file, that it exists. | 137 // Make sure, if we're not allowed to create the file, that it exists. |
| 138 if (!allow_create_) { | 138 if (!allow_create_) { |
| 139 if (!file_util::PathExists(file_name_)) | 139 if (!file_util::PathExists(file_name_)) |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } else { | 385 } else { |
| 386 // Since we got the results in order, we know the last item is the last | 386 // Since we got the results in order, we know the last item is the last |
| 387 // time we considered. | 387 // time we considered. |
| 388 *first_time_searched = results->back().time; | 388 *first_time_searched = results->back().time; |
| 389 } | 389 } |
| 390 | 390 |
| 391 statement->reset(); | 391 statement->reset(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 } // namespace history | 394 } // namespace history |
| 395 | |
| OLD | NEW |