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

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

Issue 7065015: For downloads requiring a user gesture, also require... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
11 #include "content/browser/cancelable_request.h" 11 #include "content/browser/cancelable_request.h"
12 12
13 class DownloadItem; 13 class DownloadItem;
14 class Profile; 14 class Profile;
15 15
16 namespace base { 16 namespace base {
17 class Time; 17 class Time;
18 } 18 }
19 19
20 // Interacts with the HistoryService on behalf of the download subsystem. 20 // Interacts with the HistoryService on behalf of the download subsystem.
21 class DownloadHistory { 21 class DownloadHistory {
22 public: 22 public:
23 typedef Callback2<int32, bool>::Type VisitedBeforeDoneCallback;
24
23 // A fake download table ID which represents a download that has started, 25 // A fake download table ID which represents a download that has started,
24 // but is not yet in the table. 26 // but is not yet in the table.
25 static const int kUninitializedHandle; 27 static const int kUninitializedHandle;
26 28
27 explicit DownloadHistory(Profile* profile); 29 explicit DownloadHistory(Profile* profile);
28 ~DownloadHistory(); 30 ~DownloadHistory();
29 31
30 // Retrieves DownloadCreateInfos saved in the history. 32 // Retrieves DownloadCreateInfos saved in the history.
31 void Load(HistoryService::DownloadQueryCallback* callback); 33 void Load(HistoryService::DownloadQueryCallback* callback);
32 34
35 // Checks whether |info|'s referrer has been visited before today.
Randy Smith (Not in Mondays) 2011/05/24 18:28:25 |info| looks like a typo/left over from previous C
36 void CheckVisitedReferrerBefore(int32 download_id,
37 const GURL& referrer_url,
38 VisitedBeforeDoneCallback* callback);
39
33 // Adds a new entry for a download to the history database. 40 // Adds a new entry for a download to the history database.
34 void AddEntry(DownloadItem* download_item, 41 void AddEntry(DownloadItem* download_item,
35 HistoryService::DownloadCreateCallback* callback); 42 HistoryService::DownloadCreateCallback* callback);
36 43
37 // Updates the history entry for |download_item|. 44 // Updates the history entry for |download_item|.
38 void UpdateEntry(DownloadItem* download_item); 45 void UpdateEntry(DownloadItem* download_item);
39 46
40 // Updates the download path for |download_item| to |new_path|. 47 // Updates the download path for |download_item| to |new_path|.
41 void UpdateDownloadPath(DownloadItem* download_item, 48 void UpdateDownloadPath(DownloadItem* download_item,
42 const FilePath& new_path); 49 const FilePath& new_path);
43 50
44 // Removes |download_item| from the history database. 51 // Removes |download_item| from the history database.
45 void RemoveEntry(DownloadItem* download_item); 52 void RemoveEntry(DownloadItem* download_item);
46 53
47 // Removes download-related history entries in the given time range. 54 // Removes download-related history entries in the given time range.
48 void RemoveEntriesBetween(const base::Time remove_begin, 55 void RemoveEntriesBetween(const base::Time remove_begin,
49 const base::Time remove_end); 56 const base::Time remove_end);
50 57
51 // Returns a new unique database handle which will not collide with real ones. 58 // Returns a new unique database handle which will not collide with real ones.
52 int64 GetNextFakeDbHandle(); 59 int64 GetNextFakeDbHandle();
53 60
54 private: 61 private:
62 typedef std::map<HistoryService::Handle,
63 std::pair<int32, VisitedBeforeDoneCallback*> >
64 VisitedBeforeRequestsMap;
65
66 void OnGotVisitCountToHost(HistoryService::Handle handle,
67 bool found_visits,
68 int count,
69 base::Time first_visit);
70
55 Profile* profile_; 71 Profile* profile_;
56 72
57 // In case we don't have a valid db_handle, we use |fake_db_handle_| instead. 73 // In case we don't have a valid db_handle, we use |fake_db_handle_| instead.
58 // This is useful for incognito mode or when the history database is offline. 74 // This is useful for incognito mode or when the history database is offline.
59 // Downloads are expected to have unique handles, so we decrement the next 75 // Downloads are expected to have unique handles, so we decrement the next
60 // fake handle value on every use. 76 // fake handle value on every use.
61 int64 next_fake_db_handle_; 77 int64 next_fake_db_handle_;
62 78
63 CancelableRequestConsumer history_consumer_; 79 CancelableRequestConsumer history_consumer_;
64 80
81 // The outstanding requests made by CheckVisitedReferrerBefore().
82 VisitedBeforeRequestsMap visited_before_requests_;
83
65 DISALLOW_COPY_AND_ASSIGN(DownloadHistory); 84 DISALLOW_COPY_AND_ASSIGN(DownloadHistory);
66 }; 85 };
67 86
68 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ 87 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698