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

Side by Side Diff: chrome/browser/history/download_database.h

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merged db_handle, id; onCreated, onErased Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include "base/callback.h"
9 #include "chrome/browser/history/history_types.h" 10 #include "chrome/browser/history/history_types.h"
10 11
11 struct DownloadHistoryInfo; 12 struct DownloadHistoryInfo;
12 class FilePath; 13 class FilePath;
13 14
14 namespace sql { 15 namespace sql {
15 class Connection; 16 class Connection;
16 } 17 }
17 18
18 namespace history { 19 namespace history {
19 20
20 // Maintains a table of downloads. 21 // Maintains a table of downloads.
21 class DownloadDatabase { 22 class DownloadDatabase {
22 public: 23 public:
23 // Must call InitDownloadTable before using any other functions. 24 // Must call InitDownloadTable before using any other functions.
24 DownloadDatabase(); 25 DownloadDatabase();
25 virtual ~DownloadDatabase(); 26 virtual ~DownloadDatabase();
26 27
27 // Get all the downloads from the database. 28 // Get all the downloads from the database.
28 void QueryDownloads(std::vector<DownloadHistoryInfo>* results); 29 void QueryDownloads(DownloadQueryParameters* params);
29 30
30 // Update the state of one download. Returns true if successful. 31 // Update the state of one download. Returns true if successful.
31 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle); 32 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID id);
32 33
33 // Update the path of one download. Returns true if successful. 34 // Update the path of one download. Returns true if successful.
34 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); 35 bool UpdateDownloadPath(const FilePath& path, DownloadID id);
35 36
36 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS 37 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS
37 // state are not updated during browser shutdown (particularly when crashing). 38 // state are not updated during browser shutdown (particularly when crashing).
38 // On the next start such entries are considered canceled. This functions 39 // On the next start such entries are considered canceled. This functions
39 // fixes such entries. 40 // fixes such entries.
40 bool CleanUpInProgressEntries(); 41 bool CleanUpInProgressEntries();
41 42
42 // Create a new database entry for one download and return its primary db id. 43 // Create a new database entry for one download and return its primary db id.
43 int64 CreateDownload(const DownloadHistoryInfo& info); 44 bool CreateDownload(const DownloadHistoryInfo& info);
44 45
45 // Remove a download from the database. 46 // Remove a download from the database.
46 void RemoveDownload(DownloadID db_handle); 47 void RemoveDownload(DownloadID id);
47 48
48 // Remove all completed downloads that started after |remove_begin| 49 // Remove all completed downloads that started after |remove_begin|
49 // (inclusive) and before |remove_end|. You may use null Time values 50 // (inclusive) and before |remove_end|. You may use null Time values
50 // to do an unbounded delete in either direction. This function ignores 51 // to do an unbounded delete in either direction. This function ignores
51 // all downloads that are in progress or are waiting to be cancelled. 52 // all downloads that are in progress or are waiting to be cancelled.
52 void RemoveDownloadsBetween(base::Time remove_begin, base::Time remove_end); 53 void RemoveDownloadsBetween(base::Time remove_begin, base::Time remove_end);
53 54
54 protected: 55 protected:
55 // Returns the database for the functions in this interface. 56 // Returns the database for the functions in this interface.
56 virtual sql::Connection& GetDB() = 0; 57 virtual sql::Connection& GetDB() = 0;
57 58
58 // Creates the downloads table if needed. 59 // Creates the downloads table if needed.
59 bool InitDownloadTable(); 60 bool InitDownloadTable();
60 61
61 // Used to quickly clear the downloads. First you would drop it, then you 62 // Used to quickly clear the downloads. First you would drop it, then you
62 // would re-initialize it. 63 // would re-initialize it.
63 bool DropDownloadTable(); 64 bool DropDownloadTable();
64 65
65 private: 66 private:
67 bool MaybeUpgradeTable(DownloadQueryParameters::GetNextIdThunk get_next_id);
68
66 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); 69 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
67 }; 70 };
68 71
69 } // namespace history 72 } // namespace history
70 73
71 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ 74 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.cc ('k') | chrome/browser/history/download_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698