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 "chrome/browser/history/download_database.h" | 5 #include "chrome/browser/history/download_database.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "chrome/browser/download/download_manager.h" | 10 #include "chrome/browser/download/download_manager.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 "SELECT id, full_path, url, start_time, received_bytes, " | 62 "SELECT id, full_path, url, start_time, received_bytes, " |
63 "total_bytes, state " | 63 "total_bytes, state " |
64 "FROM downloads " | 64 "FROM downloads " |
65 "ORDER BY start_time"); | 65 "ORDER BY start_time"); |
66 if (!statement.is_valid()) | 66 if (!statement.is_valid()) |
67 return; | 67 return; |
68 | 68 |
69 while (statement->step() == SQLITE_ROW) { | 69 while (statement->step() == SQLITE_ROW) { |
70 DownloadCreateInfo info; | 70 DownloadCreateInfo info; |
71 info.db_handle = statement->column_int64(0); | 71 info.db_handle = statement->column_int64(0); |
72 statement->column_string16(1, &info.path); | 72 std::wstring path_str = info.path.ToWStringHack(); |
| 73 statement->column_string16(1, &path_str); |
73 statement->column_string16(2, &info.url); | 74 statement->column_string16(2, &info.url); |
74 info.start_time = Time::FromTimeT(statement->column_int64(3)); | 75 info.start_time = Time::FromTimeT(statement->column_int64(3)); |
75 info.received_bytes = statement->column_int64(4); | 76 info.received_bytes = statement->column_int64(4); |
76 info.total_bytes = statement->column_int64(5); | 77 info.total_bytes = statement->column_int64(5); |
77 info.state = statement->column_int(6); | 78 info.state = statement->column_int(6); |
78 results->push_back(info); | 79 results->push_back(info); |
79 } | 80 } |
80 } | 81 } |
81 | 82 |
82 bool DownloadDatabase::UpdateDownload(int64 received_bytes, | 83 bool DownloadDatabase::UpdateDownload(int64 received_bytes, |
(...skipping 27 matching lines...) Expand all Loading... |
110 } | 111 } |
111 | 112 |
112 int64 DownloadDatabase::CreateDownload(const DownloadCreateInfo& info) { | 113 int64 DownloadDatabase::CreateDownload(const DownloadCreateInfo& info) { |
113 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(), | 114 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(), |
114 "INSERT INTO downloads " | 115 "INSERT INTO downloads " |
115 "(full_path, url, start_time, received_bytes, total_bytes, state) " | 116 "(full_path, url, start_time, received_bytes, total_bytes, state) " |
116 "VALUES (?, ?, ?, ?, ?, ?)"); | 117 "VALUES (?, ?, ?, ?, ?, ?)"); |
117 if (!statement.is_valid()) | 118 if (!statement.is_valid()) |
118 return 0; | 119 return 0; |
119 | 120 |
120 statement->bind_wstring(0, info.path); | 121 statement->bind_wstring(0, info.path.ToWStringHack()); |
121 statement->bind_wstring(1, info.url); | 122 statement->bind_wstring(1, info.url); |
122 statement->bind_int64(2, info.start_time.ToTimeT()); | 123 statement->bind_int64(2, info.start_time.ToTimeT()); |
123 statement->bind_int64(3, info.received_bytes); | 124 statement->bind_int64(3, info.received_bytes); |
124 statement->bind_int64(4, info.total_bytes); | 125 statement->bind_int64(4, info.total_bytes); |
125 statement->bind_int(5, info.state); | 126 statement->bind_int(5, info.state); |
126 if (statement->step() == SQLITE_DONE) | 127 if (statement->step() == SQLITE_DONE) |
127 return sqlite3_last_insert_rowid(GetDB()); | 128 return sqlite3_last_insert_rowid(GetDB()); |
128 | 129 |
129 return 0; | 130 return 0; |
130 } | 131 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 text.append(search_text); | 171 text.append(search_text); |
171 text.append(L"%"); | 172 text.append(L"%"); |
172 statement->bind_wstring(0, text); | 173 statement->bind_wstring(0, text); |
173 statement->bind_wstring(1, text); | 174 statement->bind_wstring(1, text); |
174 | 175 |
175 while (statement->step() == SQLITE_ROW) | 176 while (statement->step() == SQLITE_ROW) |
176 results->push_back(statement->column_int64(0)); | 177 results->push_back(statement->column_int64(0)); |
177 } | 178 } |
178 | 179 |
179 } // namespace history | 180 } // namespace history |
OLD | NEW |