| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS | 48 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS |
| 49 // state are not updated during browser shutdown (particularly when crashing). | 49 // state are not updated during browser shutdown (particularly when crashing). |
| 50 // On the next start such entries are considered canceled. This functions | 50 // On the next start such entries are considered canceled. This functions |
| 51 // fixes such entries. | 51 // fixes such entries. |
| 52 bool CleanUpInProgressEntries(); | 52 bool CleanUpInProgressEntries(); |
| 53 | 53 |
| 54 // Create a new database entry for one download and return its primary db id. | 54 // Create a new database entry for one download and return its primary db id. |
| 55 int64 CreateDownload(const content::DownloadPersistentStoreInfo& info); | 55 int64 CreateDownload(const content::DownloadPersistentStoreInfo& info); |
| 56 | 56 |
| 57 // Remove a download from the database. | 57 // Remove all |handles| from the database. |
| 58 void RemoveDownload(DownloadID db_handle); | 58 void RemoveDownloads(const std::set<int64>& handles); |
| 59 | |
| 60 // Remove all completed downloads that started after |remove_begin| | |
| 61 // (inclusive) and before |remove_end|. You may use null Time values | |
| 62 // to do an unbounded delete in either direction. This function ignores | |
| 63 // all downloads that are in progress or are waiting to be cancelled. | |
| 64 bool RemoveDownloadsBetween(base::Time remove_begin, base::Time remove_end); | |
| 65 | 59 |
| 66 protected: | 60 protected: |
| 67 // Returns the database for the functions in this interface. | 61 // Returns the database for the functions in this interface. |
| 68 virtual sql::Connection& GetDB() = 0; | 62 virtual sql::Connection& GetDB() = 0; |
| 69 | 63 |
| 70 // Returns the meta-table object for the functions in this interface. | 64 // Returns the meta-table object for the functions in this interface. |
| 71 virtual sql::MetaTable& GetMetaTable() = 0; | 65 virtual sql::MetaTable& GetMetaTable() = 0; |
| 72 | 66 |
| 73 // Creates the downloads table if needed. | 67 // Creates the downloads table if needed. |
| 74 bool InitDownloadTable(); | 68 bool InitDownloadTable(); |
| 75 | 69 |
| 76 // Used to quickly clear the downloads. First you would drop it, then you | 70 // Used to quickly clear the downloads. First you would drop it, then you |
| 77 // would re-initialize it. | 71 // would re-initialize it. |
| 78 bool DropDownloadTable(); | 72 bool DropDownloadTable(); |
| 79 | 73 |
| 80 private: | 74 private: |
| 81 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. | |
| 82 void CheckThread(); | |
| 83 | |
| 84 bool EnsureColumnExists(const std::string& name, const std::string& type); | 75 bool EnsureColumnExists(const std::string& name, const std::string& type); |
| 85 | 76 |
| 86 bool owning_thread_set_; | 77 bool owning_thread_set_; |
| 87 base::PlatformThreadId owning_thread_; | 78 base::PlatformThreadId owning_thread_; |
| 88 | 79 |
| 89 int next_id_; | 80 int next_id_; |
| 90 int next_db_handle_; | 81 int next_db_handle_; |
| 91 | 82 |
| 92 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); | 83 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); |
| 93 }; | 84 }; |
| 94 | 85 |
| 95 } // namespace history | 86 } // namespace history |
| 96 | 87 |
| 97 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ | 88 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ |
| OLD | NEW |