OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/debug/alias.h" |
11 #include "base/file_path.h" | 12 #include "base/file_path.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "content/browser/download/download_persistent_store_info.h" | 15 #include "content/browser/download/download_persistent_store_info.h" |
15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/download_item.h" | 17 #include "content/public/browser/download_item.h" |
17 #include "sql/statement.h" | 18 #include "sql/statement.h" |
18 | 19 |
19 // TODO(benjhayden): Change this to DCHECK when we have more debugging | 20 // TODO(benjhayden): Change this to DCHECK when we have more debugging |
20 // information from the next dev cycle, before the next stable/beta branch is | 21 // information from the next dev cycle, before the next stable/beta branch is |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 dbg_statement.BindInt64( | 277 dbg_statement.BindInt64( |
277 1, | 278 1, |
278 end_time ? end_time : std::numeric_limits<int64>::max()); | 279 end_time ? end_time : std::numeric_limits<int64>::max()); |
279 dbg_statement.BindInt(2, DownloadItem::COMPLETE); | 280 dbg_statement.BindInt(2, DownloadItem::COMPLETE); |
280 dbg_statement.BindInt(3, DownloadItem::CANCELLED); | 281 dbg_statement.BindInt(3, DownloadItem::CANCELLED); |
281 dbg_statement.BindInt(4, DownloadItem::INTERRUPTED); | 282 dbg_statement.BindInt(4, DownloadItem::INTERRUPTED); |
282 while (dbg_statement.Step()) { | 283 while (dbg_statement.Step()) { |
283 int64 id_to_delete = dbg_statement.ColumnInt64(0); | 284 int64 id_to_delete = dbg_statement.ColumnInt64(0); |
284 returned_ids_.erase(id_to_delete); | 285 returned_ids_.erase(id_to_delete); |
285 } | 286 } |
| 287 int last_error_code = GetDB().GetErrorCode(); |
| 288 base::debug::Alias(&last_error_code); |
286 CHECK_96627(dbg_statement.Succeeded()); | 289 CHECK_96627(dbg_statement.Succeeded()); |
287 } | 290 } |
288 | 291 |
289 // This does not use an index. We currently aren't likely to have enough | 292 // This does not use an index. We currently aren't likely to have enough |
290 // downloads where an index by time will give us a lot of benefit. | 293 // downloads where an index by time will give us a lot of benefit. |
291 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | 294 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, |
292 "DELETE FROM downloads WHERE start_time >= ? AND start_time < ? " | 295 "DELETE FROM downloads WHERE start_time >= ? AND start_time < ? " |
293 "AND (State = ? OR State = ? OR State = ?)")); | 296 "AND (State = ? OR State = ? OR State = ?)")); |
294 if (!statement) | 297 if (!statement) |
295 return; | 298 return; |
296 | 299 |
297 statement.BindInt64(0, start_time); | 300 statement.BindInt64(0, start_time); |
298 statement.BindInt64( | 301 statement.BindInt64( |
299 1, | 302 1, |
300 end_time ? end_time : std::numeric_limits<int64>::max()); | 303 end_time ? end_time : std::numeric_limits<int64>::max()); |
301 statement.BindInt(2, DownloadItem::COMPLETE); | 304 statement.BindInt(2, DownloadItem::COMPLETE); |
302 statement.BindInt(3, DownloadItem::CANCELLED); | 305 statement.BindInt(3, DownloadItem::CANCELLED); |
303 statement.BindInt(4, DownloadItem::INTERRUPTED); | 306 statement.BindInt(4, DownloadItem::INTERRUPTED); |
304 statement.Run(); | 307 statement.Run(); |
305 } | 308 } |
306 | 309 |
307 } // namespace history | 310 } // namespace history |
OLD | NEW |