| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ | 6 #define CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/history/history_types.h" | 9 #include "chrome/browser/history/history_types.h" |
| 10 #include "sql/meta_table.h" |
| 10 | 11 |
| 11 struct DownloadPersistentStoreInfo; | 12 struct DownloadPersistentStoreInfo; |
| 12 class FilePath; | 13 class FilePath; |
| 13 | 14 |
| 14 namespace sql { | 15 namespace sql { |
| 15 class Connection; | 16 class Connection; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace history { | 19 namespace history { |
| 19 | 20 |
| 20 // Maintains a table of downloads. | 21 // Maintains a table of downloads. |
| 21 class DownloadDatabase { | 22 class DownloadDatabase { |
| 22 public: | 23 public: |
| 23 // Must call InitDownloadTable before using any other functions. | 24 // Must call InitDownloadTable before using any other functions. |
| 24 DownloadDatabase(); | 25 DownloadDatabase(); |
| 25 virtual ~DownloadDatabase(); | 26 virtual ~DownloadDatabase(); |
| 26 | 27 |
| 28 int next_download_id() const { return next_id_; } |
| 29 |
| 27 // Get all the downloads from the database. | 30 // Get all the downloads from the database. |
| 28 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results); | 31 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results); |
| 29 | 32 |
| 30 // Update the state of one download. Returns true if successful. | 33 // Update the state of one download. Returns true if successful. |
| 31 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle); | 34 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle); |
| 32 | 35 |
| 33 // Update the path of one download. Returns true if successful. | 36 // Update the path of one download. Returns true if successful. |
| 34 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); | 37 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); |
| 35 | 38 |
| 36 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS | 39 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS |
| (...skipping 19 matching lines...) Expand all Loading... |
| 56 virtual sql::Connection& GetDB() = 0; | 59 virtual sql::Connection& GetDB() = 0; |
| 57 | 60 |
| 58 // Creates the downloads table if needed. | 61 // Creates the downloads table if needed. |
| 59 bool InitDownloadTable(); | 62 bool InitDownloadTable(); |
| 60 | 63 |
| 61 // Used to quickly clear the downloads. First you would drop it, then you | 64 // Used to quickly clear the downloads. First you would drop it, then you |
| 62 // would re-initialize it. | 65 // would re-initialize it. |
| 63 bool DropDownloadTable(); | 66 bool DropDownloadTable(); |
| 64 | 67 |
| 65 private: | 68 private: |
| 69 int next_id_; |
| 70 sql::MetaTable meta_table_; |
| 71 |
| 66 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); | 72 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 } // namespace history | 75 } // namespace history |
| 70 | 76 |
| 71 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ | 77 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ |
| OLD | NEW |