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 COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ |
6 #define COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
17 #include "components/history/core/browser/download_job_info.h" | |
sky
2017/02/03 16:02:33
Forward declare DownloadJobInfo?
qinmin
2017/02/04 00:06:56
Done.
| |
17 #include "components/history/core/browser/download_types.h" | 18 #include "components/history/core/browser/download_types.h" |
18 | 19 |
19 namespace sql { | 20 namespace sql { |
20 class Connection; | 21 class Connection; |
21 } | 22 } |
22 | 23 |
23 namespace history { | 24 namespace history { |
24 | 25 |
25 struct DownloadRow; | 26 struct DownloadRow; |
26 | 27 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 // state are not updated during browser shutdown (particularly when crashing). | 107 // state are not updated during browser shutdown (particularly when crashing). |
107 // On the next start such entries are considered interrupted with | 108 // On the next start such entries are considered interrupted with |
108 // interrupt reason |DOWNLOAD_INTERRUPT_REASON_CRASH|. This function | 109 // interrupt reason |DOWNLOAD_INTERRUPT_REASON_CRASH|. This function |
109 // fixes such entries. | 110 // fixes such entries. |
110 void EnsureInProgressEntriesCleanedUp(); | 111 void EnsureInProgressEntriesCleanedUp(); |
111 | 112 |
112 bool EnsureColumnExists(const std::string& name, const std::string& type); | 113 bool EnsureColumnExists(const std::string& name, const std::string& type); |
113 | 114 |
114 void RemoveDownloadURLs(uint32_t id); | 115 void RemoveDownloadURLs(uint32_t id); |
115 | 116 |
117 // Creates a new download job. Returns true on success, or false otherwise. | |
118 bool CreateDownloadJob(const DownloadJobInfo& info); | |
119 | |
120 // Updates the state of a download job. Returns true on success, or false | |
121 // if the job doesn't exists.. | |
122 bool UpdateDownloadJob(const DownloadJobInfo& info); | |
123 | |
124 // Delete all the download jobs associated with one DownloadRow. | |
125 void RemoveDownloadJobs(uint32_t id); | |
126 | |
116 bool owning_thread_set_; | 127 bool owning_thread_set_; |
117 base::PlatformThreadId owning_thread_; | 128 base::PlatformThreadId owning_thread_; |
118 | 129 |
119 // Initialized to false on construction, and checked in all functional | 130 // Initialized to false on construction, and checked in all functional |
120 // routines post-migration in the database for a possible call to | 131 // routines post-migration in the database for a possible call to |
121 // CleanUpInProgressEntries(). This allows us to avoid | 132 // CleanUpInProgressEntries(). This allows us to avoid |
122 // doing the cleanup until after any DB migration and unless we are | 133 // doing the cleanup until after any DB migration and unless we are |
123 // actually use the downloads database. | 134 // actually use the downloads database. |
124 bool in_progress_entry_cleanup_completed_; | 135 bool in_progress_entry_cleanup_completed_; |
125 | 136 |
126 // Those constants are defined in the embedder and injected into the | 137 // Those constants are defined in the embedder and injected into the |
127 // database in the constructor. They represent the interrupt reason | 138 // database in the constructor. They represent the interrupt reason |
128 // to use for respectively an undefined value and in case of a crash. | 139 // to use for respectively an undefined value and in case of a crash. |
129 DownloadInterruptReason download_interrupt_reason_none_; | 140 DownloadInterruptReason download_interrupt_reason_none_; |
130 DownloadInterruptReason download_interrupt_reason_crash_; | 141 DownloadInterruptReason download_interrupt_reason_crash_; |
131 | 142 |
132 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); | 143 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); |
133 }; | 144 }; |
134 | 145 |
135 } // namespace history | 146 } // namespace history |
136 | 147 |
137 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ | 148 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ |
OLD | NEW |