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

Side by Side Diff: chrome/browser/download/download_history.h

Issue 3071005: Download code cleanup patch of death: (Closed)
Patch Set: inline the dtor Created 10 years, 4 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
« no previous file with comments | « chrome/browser/dom_ui/filebrowse_ui.cc ('k') | chrome/browser/download/download_history.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "chrome/browser/cancelable_request.h"
13 #include "chrome/browser/history/history.h"
14
15 class DownloadItem;
16 class Profile;
17
18 namespace base {
19 class Time;
20 }
21
22 // Interacts with the HistoryService on behalf of the download subsystem.
23 class DownloadHistory {
24 public:
25 // Converts history database handles to download items.
26 class DownloadItemMapper {
27 public:
28 virtual ~DownloadItemMapper() {}
29
30 // Returns a DownloadItem* corresponding to |db_handle|, or NULL if no such
31 // DownloadItem exists.
32 virtual DownloadItem* GetDownloadItemFromDbHandle(int64 db_handle) = 0;
33 };
34
35 // A fake download table ID which represents a download that has started,
36 // but is not yet in the table.
37 static const int kUninitializedHandle;
38
39 typedef Callback1<std::vector<DownloadItem*> >::Type DownloadSearchCallback;
40
41 DownloadHistory(Profile* profile, DownloadItemMapper* mapper);
42
43 // Retrieves DownloadCreateInfos saved in the history.
44 void Load(HistoryService::DownloadQueryCallback* callback);
45
46 // Starts a history search for downloads and invokes |callback| when done.
47 void Search(const string16& query,
48 DownloadSearchCallback* callback);
49
50 // Adds a new entry for a download to the history database.
51 void AddEntry(const DownloadCreateInfo& info,
52 DownloadItem* download_item,
53 HistoryService::DownloadCreateCallback* callback);
54
55 // Updates the history entry for |download_item|.
56 void UpdateEntry(DownloadItem* download_item);
57
58 // Updates the download path for |download_item| to |new_path|.
59 void UpdateDownloadPath(DownloadItem* download_item,
60 const FilePath& new_path);
61
62 // Removes |download_item| from the history database.
63 void RemoveEntry(DownloadItem* download_item);
64
65 // Removes download-related history entries in the given time range.
66 void RemoveEntriesBetween(const base::Time remove_begin,
67 const base::Time remove_end);
68
69 // Returns a new unique database handle which will not collide with real ones.
70 int64 GetNextFakeDbHandle();
71
72 private:
73 void OnSearchDownloadsComplete(HistoryService::Handle handle,
74 std::vector<int64>* results);
75
76 Profile* profile_;
77
78 // In case we don't have a valid db_handle, we use |fake_db_handle_| instead.
79 // This is useful for incognito mode or when the history database is offline.
80 // Downloads are expected to have unique handles, so we decrement the next
81 // fake handle value on every use.
82 int64 next_fake_db_handle_;
83
84 DownloadItemMapper* download_item_mapper_;
85
86 CancelableRequestConsumerTSimple<DownloadSearchCallback*> history_consumer_;
87
88 DISALLOW_COPY_AND_ASSIGN(DownloadHistory);
89 };
90
91 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/filebrowse_ui.cc ('k') | chrome/browser/download/download_history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698