summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/url_database.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-30 19:33:53 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-30 19:33:53 +0000
commit9660ddd38561758694488c7110a7edbeacb1b305 (patch)
treea08b6f154d33fa14365addf0681ee0f78b35220e /chrome/browser/history/url_database.cc
parent769d3c1343f9a53a9ade10146c48f022adb099d8 (diff)
downloadchromium_src-9660ddd38561758694488c7110a7edbeacb1b305.zip
chromium_src-9660ddd38561758694488c7110a7edbeacb1b305.tar.gz
chromium_src-9660ddd38561758694488c7110a7edbeacb1b305.tar.bz2
Correct sqlite wrapper behavior on systems where wchar_t is UTF-32,
for example Linux. The problem was that old code assumed wstring is UTF-16, which resulted in string corruption on Linux. I actually tested it on browser/history unit tests, see http://codereview.chromium.org/18758. Review URL: http://codereview.chromium.org/18805 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/url_database.cc')
-rw-r--r--chrome/browser/history/url_database.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/chrome/browser/history/url_database.cc b/chrome/browser/history/url_database.cc
index c824a6e..6db3b10 100644
--- a/chrome/browser/history/url_database.cc
+++ b/chrome/browser/history/url_database.cc
@@ -45,7 +45,7 @@ void URLDatabase::FillURLRow(SQLStatement& s, history::URLRow* i) {
DCHECK(i);
i->id_ = s.column_int64(0);
i->url_ = GURL(s.column_string(1));
- i->title_ = s.column_string16(2);
+ i->title_ = s.column_wstring(2);
i->visit_count_ = s.column_int(3);
i->typed_count_ = s.column_int(4);
i->last_visit_ = Time::FromInternalValue(s.column_int64(5));
@@ -239,12 +239,15 @@ void URLDatabase::AutocompleteForPrefix(const std::wstring& prefix,
return;
// We will find all strings between "prefix" and this string, which is prefix
- // followed by the maximum character size.
- std::wstring end_query(prefix);
- end_query.push_back(std::numeric_limits<wchar_t>::max());
-
- statement->bind_wstring(0, prefix);
- statement->bind_wstring(1, end_query);
+ // followed by the maximum character size. Use 8-bit strings for everything
+ // so we can be sure sqlite is comparing everything in 8-bit mode. Otherwise,
+ // it will have to convert strings either to UTF-8 or UTF-16 for comparison.
+ std::string prefix_utf8(WideToUTF8(prefix));
+ std::string end_query(prefix_utf8);
+ end_query.push_back(std::numeric_limits<unsigned char>::max());
+
+ statement->bind_string(0, prefix_utf8);
+ statement->bind_string(1, end_query);
statement->bind_int(2, static_cast<int>(max_results));
while (statement->step() == SQLITE_ROW) {
@@ -397,7 +400,7 @@ void URLDatabase::GetMostRecentKeywordSearchTerms(
KeywordSearchTermVisit visit;
while (statement->step() == SQLITE_ROW) {
- visit.term = statement->column_string16(0);
+ visit.term = statement->column_wstring(0);
visit.time = Time::FromInternalValue(statement->column_int64(1));
matches->push_back(visit);
}