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

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

Powered by Google App Engine
This is Rietveld 408576698