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

Unified Diff: chrome/browser/history/text_database.cc

Issue 4247: Port some things in browser/{download,history}, minor things in common.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/snippet.h ('k') | chrome/browser/history/text_database_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/text_database.cc
===================================================================
--- chrome/browser/history/text_database.cc (revision 2786)
+++ chrome/browser/history/text_database.cc (working copy)
@@ -115,16 +115,18 @@
// We don't actually check the prefix here. Since the file system could
// be case insensitive in ways we can't predict (NTFS), checking could
// potentially be the wrong thing to do. Instead, we just look for a suffix.
- static const int kIDStringLength = 7; // Room for "xxxx-xx".
+ static const size_t kIDStringLength = 7; // Room for "xxxx-xx".
if (file_name.length() < kIDStringLength)
return 0;
- const wchar_t* number_begin =
- &file_name[file_name.length() - kIDStringLength];
+ const std::wstring suffix(&file_name[file_name.length() - kIDStringLength]);
- int year, month;
- if (swscanf_s(number_begin, L"%d-%d", &year, &month) != 2)
- return 0; // Unable to get both numbers.
+ if (suffix.length() != kIDStringLength || suffix[4] != L'-') {
+ return 0;
+ }
+ int year = StringToInt(suffix.substr(0, 4));
+ int month = StringToInt(suffix.substr(5, 2));
+
return year * 100 + month;
}
@@ -348,7 +350,7 @@
Match& match = results->at(results->size() - 1);
match.url.Swap(&url);
- match.title = statement->column_string16(1);
+ match.title = UTF8ToWide(statement->column_string(1));
match.time = Time::FromInternalValue(statement->column_int64(2));
// Extract any matches in the title.
« no previous file with comments | « chrome/browser/history/snippet.h ('k') | chrome/browser/history/text_database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698