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 #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 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // Get all the downloads from the database. | 36 // Get all the downloads from the database. |
37 void QueryDownloads( | 37 void QueryDownloads( |
38 std::vector<content::DownloadPersistentStoreInfo>* results); | 38 std::vector<content::DownloadPersistentStoreInfo>* results); |
39 | 39 |
40 // Update the state of one download. Returns true if successful. | 40 // Update the state of one download. Returns true if successful. |
41 // Does not update |url|, |start_time|, |total_bytes|; uses |db_handle| only | 41 // Does not update |url|, |start_time|, |total_bytes|; uses |db_handle| only |
42 // to select the row in the database table to update. | 42 // to select the row in the database table to update. |
43 bool UpdateDownload(const content::DownloadPersistentStoreInfo& data); | 43 bool UpdateDownload(const content::DownloadPersistentStoreInfo& data); |
44 | 44 |
45 // Update the path of one download. Returns true if successful. | 45 // Update the paths of one download. Returns true if successful. |
46 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); | 46 bool UpdateDownloadPath(const FilePath& target_path, |
| 47 const FilePath& current_path, |
| 48 DownloadID db_handle); |
47 | 49 |
48 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS | 50 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS |
49 // state are not updated during browser shutdown (particularly when crashing). | 51 // state are not updated during browser shutdown (particularly when crashing). |
50 // On the next start such entries are considered canceled. This functions | 52 // On the next start such entries are considered canceled. This functions |
51 // fixes such entries. | 53 // fixes such entries. |
52 bool CleanUpInProgressEntries(); | 54 bool CleanUpInProgressEntries(); |
53 | 55 |
54 // Create a new database entry for one download and return its primary db id. | 56 // Create a new database entry for one download and return its primary db id. |
55 int64 CreateDownload(const content::DownloadPersistentStoreInfo& info); | 57 int64 CreateDownload(const content::DownloadPersistentStoreInfo& info); |
56 | 58 |
(...skipping 11 matching lines...) Expand all Loading... |
68 virtual sql::Connection& GetDB() = 0; | 70 virtual sql::Connection& GetDB() = 0; |
69 | 71 |
70 // Returns the meta-table object for the functions in this interface. | 72 // Returns the meta-table object for the functions in this interface. |
71 virtual sql::MetaTable& GetMetaTable() = 0; | 73 virtual sql::MetaTable& GetMetaTable() = 0; |
72 | 74 |
73 // Returns true if able to successfully rewrite the invalid values for the | 75 // Returns true if able to successfully rewrite the invalid values for the |
74 // |state| field from 3 to 4. Returns false if there was an error fixing the | 76 // |state| field from 3 to 4. Returns false if there was an error fixing the |
75 // database. See http://crbug.com/140687 | 77 // database. See http://crbug.com/140687 |
76 bool MigrateDownloadsState(); | 78 bool MigrateDownloadsState(); |
77 | 79 |
| 80 // Returns true if able to successfully add the last interrupt reason and the |
| 81 // two target paths to downloads. |
| 82 bool MigrateDownloadsReasonAndPaths(); |
| 83 |
78 // Creates the downloads table if needed. | 84 // Creates the downloads table if needed. |
79 bool InitDownloadTable(); | 85 bool InitDownloadTable(); |
80 | 86 |
81 // Used to quickly clear the downloads. First you would drop it, then you | 87 // Used to quickly clear the downloads. First you would drop it, then you |
82 // would re-initialize it. | 88 // would re-initialize it. |
83 bool DropDownloadTable(); | 89 bool DropDownloadTable(); |
84 | 90 |
85 private: | 91 private: |
86 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. | 92 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. |
87 void CheckThread(); | 93 void CheckThread(); |
88 | 94 |
89 bool EnsureColumnExists(const std::string& name, const std::string& type); | 95 bool EnsureColumnExists(const std::string& name, const std::string& type); |
90 | 96 |
91 bool owning_thread_set_; | 97 bool owning_thread_set_; |
92 base::PlatformThreadId owning_thread_; | 98 base::PlatformThreadId owning_thread_; |
93 | 99 |
94 int next_id_; | 100 int next_id_; |
95 int next_db_handle_; | 101 int next_db_handle_; |
96 | 102 |
97 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); | 103 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); |
98 }; | 104 }; |
99 | 105 |
100 } // namespace history | 106 } // namespace history |
101 | 107 |
102 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ | 108 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ |
OLD | NEW |