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