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

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: addressing comments 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 <map>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.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
26 struct DownloadJobInfo;
25 struct DownloadRow; 27 struct DownloadRow;
26 28
27 // Maintains a table of downloads. 29 // Maintains a table of downloads.
28 class DownloadDatabase { 30 class DownloadDatabase {
29 public: 31 public:
30 // Must call InitDownloadTable before using any other functions. 32 // Must call InitDownloadTable before using any other functions.
31 DownloadDatabase(DownloadInterruptReason download_interrupt_reason_none, 33 DownloadDatabase(DownloadInterruptReason download_interrupt_reason_none,
32 DownloadInterruptReason download_interrupt_reason_crash); 34 DownloadInterruptReason download_interrupt_reason_crash);
33 virtual ~DownloadDatabase(); 35 virtual ~DownloadDatabase();
34 36
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // state are not updated during browser shutdown (particularly when crashing). 108 // state are not updated during browser shutdown (particularly when crashing).
107 // On the next start such entries are considered interrupted with 109 // On the next start such entries are considered interrupted with
108 // interrupt reason |DOWNLOAD_INTERRUPT_REASON_CRASH|. This function 110 // interrupt reason |DOWNLOAD_INTERRUPT_REASON_CRASH|. This function
109 // fixes such entries. 111 // fixes such entries.
110 void EnsureInProgressEntriesCleanedUp(); 112 void EnsureInProgressEntriesCleanedUp();
111 113
112 bool EnsureColumnExists(const std::string& name, const std::string& type); 114 bool EnsureColumnExists(const std::string& name, const std::string& type);
113 115
114 void RemoveDownloadURLs(uint32_t id); 116 void RemoveDownloadURLs(uint32_t id);
115 117
118 // Creates a new download job if it doesn't exist, or updates an existing one.
119 // Returns true on success, or false otherwise.
120 bool CreateOrUpdateDownloadJob(const DownloadJobInfo& info);
121
122 // Delete all the download jobs associated with one DownloadRow.
123 void RemoveDownloadJobs(DownloadId id);
124
125 // Helper method to query the download jobs for all the records in
126 // |download_row_map|.
127 void QueryDownloadJobs(std::map<uint32_t, DownloadRow*>* download_row_map);
Scott Hess - ex-Googler 2017/02/08 22:01:39 I still want this key to be a DownloadId, but I ca
qinmin 2017/02/09 01:01:42 Done. Changed all member functions that using uint
128
116 bool owning_thread_set_; 129 bool owning_thread_set_;
117 base::PlatformThreadId owning_thread_; 130 base::PlatformThreadId owning_thread_;
118 131
119 // Initialized to false on construction, and checked in all functional 132 // Initialized to false on construction, and checked in all functional
120 // routines post-migration in the database for a possible call to 133 // routines post-migration in the database for a possible call to
121 // CleanUpInProgressEntries(). This allows us to avoid 134 // CleanUpInProgressEntries(). This allows us to avoid
122 // doing the cleanup until after any DB migration and unless we are 135 // doing the cleanup until after any DB migration and unless we are
123 // actually use the downloads database. 136 // actually use the downloads database.
124 bool in_progress_entry_cleanup_completed_; 137 bool in_progress_entry_cleanup_completed_;
125 138
126 // Those constants are defined in the embedder and injected into the 139 // Those constants are defined in the embedder and injected into the
127 // database in the constructor. They represent the interrupt reason 140 // database in the constructor. They represent the interrupt reason
128 // to use for respectively an undefined value and in case of a crash. 141 // to use for respectively an undefined value and in case of a crash.
129 DownloadInterruptReason download_interrupt_reason_none_; 142 DownloadInterruptReason download_interrupt_reason_none_;
130 DownloadInterruptReason download_interrupt_reason_crash_; 143 DownloadInterruptReason download_interrupt_reason_crash_;
131 144
132 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); 145 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
133 }; 146 };
134 147
135 } // namespace history 148 } // namespace history
136 149
137 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ 150 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698