Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: components/history/core/browser/download_database.h

Issue 2665243003: add a download slices table into history download db (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
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
27 // Maintains a table of downloads. 28 // Maintains a table of downloads.
28 class DownloadDatabase { 29 class DownloadDatabase {
29 public: 30 public:
31 // Check if Parallel downloading feature is enabled.
32 static bool IsParallelDownloadingEnabled();
33
30 // Must call InitDownloadTable before using any other functions. 34 // Must call InitDownloadTable before using any other functions.
31 DownloadDatabase(DownloadInterruptReason download_interrupt_reason_none, 35 DownloadDatabase(DownloadInterruptReason download_interrupt_reason_none,
32 DownloadInterruptReason download_interrupt_reason_crash); 36 DownloadInterruptReason download_interrupt_reason_crash);
33 virtual ~DownloadDatabase(); 37 virtual ~DownloadDatabase();
34 38
35 uint32_t GetNextDownloadId(); 39 uint32_t GetNextDownloadId();
36 40
37 // Get all the downloads from the database. 41 // Get all the downloads from the database.
38 void QueryDownloads(std::vector<DownloadRow>* results); 42 void QueryDownloads(std::vector<DownloadRow>* results);
39 43
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // state are not updated during browser shutdown (particularly when crashing). 110 // state are not updated during browser shutdown (particularly when crashing).
107 // On the next start such entries are considered interrupted with 111 // On the next start such entries are considered interrupted with
108 // interrupt reason |DOWNLOAD_INTERRUPT_REASON_CRASH|. This function 112 // interrupt reason |DOWNLOAD_INTERRUPT_REASON_CRASH|. This function
109 // fixes such entries. 113 // fixes such entries.
110 void EnsureInProgressEntriesCleanedUp(); 114 void EnsureInProgressEntriesCleanedUp();
111 115
112 bool EnsureColumnExists(const std::string& name, const std::string& type); 116 bool EnsureColumnExists(const std::string& name, const std::string& type);
113 117
114 void RemoveDownloadURLs(uint32_t id); 118 void RemoveDownloadURLs(uint32_t id);
115 119
120 bool EnsureDownloadJobsTableExists();
121
122 // Updates the state of a download job. Returns true on success, or false
123 // otherwise. If the job doesn't exist, a new job will be created. If
124 // |is_new_download| is true, should always insert a new job into the db.
125 bool UpdateDownloadJob(const DownloadJobInfo& info, bool is_new_download);
126
127 // Delete all the download jobs associated with one DownloadRow.
128 void RemoveDownloadJobs(uint32_t id);
129
116 bool owning_thread_set_; 130 bool owning_thread_set_;
117 base::PlatformThreadId owning_thread_; 131 base::PlatformThreadId owning_thread_;
118 132
119 // Initialized to false on construction, and checked in all functional 133 // Initialized to false on construction, and checked in all functional
120 // routines post-migration in the database for a possible call to 134 // routines post-migration in the database for a possible call to
121 // CleanUpInProgressEntries(). This allows us to avoid 135 // CleanUpInProgressEntries(). This allows us to avoid
122 // doing the cleanup until after any DB migration and unless we are 136 // doing the cleanup until after any DB migration and unless we are
123 // actually use the downloads database. 137 // actually use the downloads database.
124 bool in_progress_entry_cleanup_completed_; 138 bool in_progress_entry_cleanup_completed_;
125 139
126 // Those constants are defined in the embedder and injected into the 140 // Those constants are defined in the embedder and injected into the
127 // database in the constructor. They represent the interrupt reason 141 // database in the constructor. They represent the interrupt reason
128 // to use for respectively an undefined value and in case of a crash. 142 // to use for respectively an undefined value and in case of a crash.
129 DownloadInterruptReason download_interrupt_reason_none_; 143 DownloadInterruptReason download_interrupt_reason_none_;
130 DownloadInterruptReason download_interrupt_reason_crash_; 144 DownloadInterruptReason download_interrupt_reason_crash_;
131 145
132 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); 146 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
133 }; 147 };
134 148
135 } // namespace history 149 } // namespace history
136 150
137 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ 151 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698