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 <set> | 9 #include <set> |
10 | 10 |
| 11 #include "base/threading/platform_thread.h" |
11 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
12 #include "base/threading/platform_thread.h" | 13 #include "sql/meta_table.h" |
13 | 14 |
14 struct DownloadPersistentStoreInfo; | 15 struct DownloadPersistentStoreInfo; |
15 class FilePath; | 16 class FilePath; |
16 | 17 |
17 namespace sql { | 18 namespace sql { |
18 class Connection; | 19 class Connection; |
19 } | 20 } |
20 | 21 |
21 namespace history { | 22 namespace history { |
22 | 23 |
23 // Maintains a table of downloads. | 24 // Maintains a table of downloads. |
24 class DownloadDatabase { | 25 class DownloadDatabase { |
25 public: | 26 public: |
26 // Must call InitDownloadTable before using any other functions. | 27 // Must call InitDownloadTable before using any other functions. |
27 DownloadDatabase(); | 28 DownloadDatabase(); |
28 virtual ~DownloadDatabase(); | 29 virtual ~DownloadDatabase(); |
29 | 30 |
| 31 int next_download_id() const { return next_id_; } |
| 32 |
30 // Get all the downloads from the database. | 33 // Get all the downloads from the database. |
31 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results); | 34 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results); |
32 | 35 |
33 // Update the state of one download. Returns true if successful. | 36 // Update the state of one download. Returns true if successful. |
34 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle); | 37 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle); |
35 | 38 |
36 // Update the path of one download. Returns true if successful. | 39 // Update the path of one download. Returns true if successful. |
37 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); | 40 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); |
38 | 41 |
39 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS | 42 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS |
(...skipping 24 matching lines...) Expand all Loading... |
64 // Used to quickly clear the downloads. First you would drop it, then you | 67 // Used to quickly clear the downloads. First you would drop it, then you |
65 // would re-initialize it. | 68 // would re-initialize it. |
66 bool DropDownloadTable(); | 69 bool DropDownloadTable(); |
67 | 70 |
68 private: | 71 private: |
69 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. | 72 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. |
70 std::set<int64> returned_ids_; | 73 std::set<int64> returned_ids_; |
71 bool owning_thread_set_; | 74 bool owning_thread_set_; |
72 base::PlatformThreadId owning_thread_; | 75 base::PlatformThreadId owning_thread_; |
73 | 76 |
| 77 int next_id_; |
| 78 sql::MetaTable meta_table_; |
| 79 |
74 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); | 80 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); |
75 }; | 81 }; |
76 | 82 |
77 } // namespace history | 83 } // namespace history |
78 | 84 |
79 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ | 85 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ |
OLD | NEW |