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

Side by Side Diff: chrome/browser/history/download_database.cc

Issue 39206: NO CODE CHANGE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/external_tab_container.cc ('k') | chrome/browser/history/history.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return false; 48 return false;
49 } 49 }
50 return true; 50 return true;
51 } 51 }
52 52
53 bool DownloadDatabase::DropDownloadTable() { 53 bool DownloadDatabase::DropDownloadTable() {
54 return sqlite3_exec(GetDB(), "DROP TABLE downloads", NULL, NULL, NULL) == 54 return sqlite3_exec(GetDB(), "DROP TABLE downloads", NULL, NULL, NULL) ==
55 SQLITE_OK; 55 SQLITE_OK;
56 } 56 }
57 57
58 void DownloadDatabase::QueryDownloads(std::vector<DownloadCreateInfo>* results) { 58 void DownloadDatabase::QueryDownloads(
59 std::vector<DownloadCreateInfo>* results) {
59 results->clear(); 60 results->clear();
60 61
61 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(), 62 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(),
62 "SELECT id, full_path, url, start_time, received_bytes, " 63 "SELECT id, full_path, url, start_time, received_bytes, "
63 "total_bytes, state " 64 "total_bytes, state "
64 "FROM downloads " 65 "FROM downloads "
65 "ORDER BY start_time"); 66 "ORDER BY start_time");
66 if (!statement.is_valid()) 67 if (!statement.is_valid())
67 return; 68 return;
68 69
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // downloads where an index by time will give us a lot of benefit. 150 // downloads where an index by time will give us a lot of benefit.
150 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(), 151 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(),
151 "DELETE FROM downloads WHERE start_time >= ? AND start_time < ? " 152 "DELETE FROM downloads WHERE start_time >= ? AND start_time < ? "
152 "AND (State = ? OR State = ?)"); 153 "AND (State = ? OR State = ?)");
153 if (!statement.is_valid()) 154 if (!statement.is_valid())
154 return; 155 return;
155 156
156 time_t start_time = delete_begin.ToTimeT(); 157 time_t start_time = delete_begin.ToTimeT();
157 time_t end_time = delete_end.ToTimeT(); 158 time_t end_time = delete_end.ToTimeT();
158 statement->bind_int64(0, start_time); 159 statement->bind_int64(0, start_time);
159 statement->bind_int64(1, end_time ? end_time : std::numeric_limits<int64>::max ()); 160 statement->bind_int64(
161 1,
162 end_time ? end_time : std::numeric_limits<int64>::max());
160 statement->bind_int(2, DownloadItem::COMPLETE); 163 statement->bind_int(2, DownloadItem::COMPLETE);
161 statement->bind_int(3, DownloadItem::CANCELLED); 164 statement->bind_int(3, DownloadItem::CANCELLED);
162 statement->step(); 165 statement->step();
163 } 166 }
164 167
165 void DownloadDatabase::SearchDownloads(std::vector<int64>* results, 168 void DownloadDatabase::SearchDownloads(std::vector<int64>* results,
166 const std::wstring& search_text) { 169 const std::wstring& search_text) {
167 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(), 170 SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(),
168 "SELECT id FROM downloads WHERE url LIKE ? " 171 "SELECT id FROM downloads WHERE url LIKE ? "
169 "OR full_path LIKE ? ORDER BY id"); 172 "OR full_path LIKE ? ORDER BY id");
170 if (!statement.is_valid()) 173 if (!statement.is_valid())
171 return; 174 return;
172 175
173 std::wstring text(L"%"); 176 std::wstring text(L"%");
174 text.append(search_text); 177 text.append(search_text);
175 text.append(L"%"); 178 text.append(L"%");
176 statement->bind_wstring(0, text); 179 statement->bind_wstring(0, text);
177 statement->bind_wstring(1, text); 180 statement->bind_wstring(1, text);
178 181
179 while (statement->step() == SQLITE_ROW) 182 while (statement->step() == SQLITE_ROW)
180 results->push_back(statement->column_int64(0)); 183 results->push_back(statement->column_int64(0));
181 } 184 }
182 185
183 } // namespace history 186 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/external_tab_container.cc ('k') | chrome/browser/history/history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698