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

Side by Side Diff: chrome/browser/download/download_history.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_DOWNLOAD_DOWNLOAD_HISTORY_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "chrome/browser/history/history.h" 12 #include "chrome/browser/history/history.h"
13 #include "content/browser/cancelable_request.h" 13 #include "content/browser/cancelable_request.h"
14 14
15 class DownloadItem; 15 class DownloadItem;
16 class Profile; 16 class Profile;
17 17
18 namespace base { 18 namespace base {
19 class Time; 19 class Time;
20 } 20 }
21 21
22 // Interacts with the HistoryService on behalf of the download subsystem. 22 // Interacts with the HistoryService on behalf of the download subsystem.
23 class DownloadHistory { 23 class DownloadHistory {
24 public: 24 public:
25 typedef Callback2<int32, bool>::Type VisitedBeforeDoneCallback; 25 typedef Callback2<int32, bool>::Type VisitedBeforeDoneCallback;
26 26
27 // A fake download table ID which represents a download that has started,
28 // but is not yet in the table.
29 static const int kUninitializedHandle;
30
31 explicit DownloadHistory(Profile* profile); 27 explicit DownloadHistory(Profile* profile);
32 ~DownloadHistory(); 28 ~DownloadHistory();
33 29
34 // Retrieves DownloadCreateInfos saved in the history. 30 // Retrieves DownloadCreateInfos saved in the history.
35 void Load(HistoryService::DownloadQueryCallback* callback); 31 void Load(HistoryService::DownloadQueryCallback* callback);
36 32
37 // Checks whether |referrer_url| has been visited before today. This takes 33 // Checks whether |referrer_url| has been visited before today. This takes
38 // ownership of |callback|. 34 // ownership of |callback|.
39 void CheckVisitedReferrerBefore(int32 download_id, 35 void CheckVisitedReferrerBefore(int32 download_id,
40 const GURL& referrer_url, 36 const GURL& referrer_url,
(...skipping 10 matching lines...) Expand all
51 void UpdateDownloadPath(DownloadItem* download_item, 47 void UpdateDownloadPath(DownloadItem* download_item,
52 const FilePath& new_path); 48 const FilePath& new_path);
53 49
54 // Removes |download_item| from the history database. 50 // Removes |download_item| from the history database.
55 void RemoveEntry(DownloadItem* download_item); 51 void RemoveEntry(DownloadItem* download_item);
56 52
57 // Removes download-related history entries in the given time range. 53 // Removes download-related history entries in the given time range.
58 void RemoveEntriesBetween(const base::Time remove_begin, 54 void RemoveEntriesBetween(const base::Time remove_begin,
59 const base::Time remove_end); 55 const base::Time remove_end);
60 56
61 // Returns a new unique database handle which will not collide with real ones.
62 int64 GetNextFakeDbHandle();
63
64 private: 57 private:
65 typedef std::map<HistoryService::Handle, 58 typedef std::map<HistoryService::Handle,
66 std::pair<int32, VisitedBeforeDoneCallback*> > 59 std::pair<int32, VisitedBeforeDoneCallback*> >
67 VisitedBeforeRequestsMap; 60 VisitedBeforeRequestsMap;
68 61
69 void OnGotVisitCountToHost(HistoryService::Handle handle, 62 void OnGotVisitCountToHost(HistoryService::Handle handle,
70 bool found_visits, 63 bool found_visits,
71 int count, 64 int count,
72 base::Time first_visit); 65 base::Time first_visit);
73 66
74 Profile* profile_; 67 Profile* profile_;
75 68
76 // In case we don't have a valid db_handle, we use |fake_db_handle_| instead.
77 // This is useful for incognito mode or when the history database is offline.
78 // Downloads are expected to have unique handles, so we decrement the next
79 // fake handle value on every use.
80 int64 next_fake_db_handle_;
81
82 CancelableRequestConsumer history_consumer_; 69 CancelableRequestConsumer history_consumer_;
83 70
84 // The outstanding requests made by CheckVisitedReferrerBefore(). 71 // The outstanding requests made by CheckVisitedReferrerBefore().
85 VisitedBeforeRequestsMap visited_before_requests_; 72 VisitedBeforeRequestsMap visited_before_requests_;
86 73
87 DISALLOW_COPY_AND_ASSIGN(DownloadHistory); 74 DISALLOW_COPY_AND_ASSIGN(DownloadHistory);
88 }; 75 };
89 76
90 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ 77 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file_manager.cc ('k') | chrome/browser/download/download_history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698