OLD | NEW |
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 explicit DownloadHistory(Profile* profile); | 27 explicit DownloadHistory(Profile* profile); |
28 ~DownloadHistory(); | 28 ~DownloadHistory(); |
29 | 29 |
| 30 // Retrieves the next_id counter from the sql meta_table. |
| 31 // Should be much faster than Load so that we may delay downloads until after |
| 32 // this call with minimal performance penalty. |
| 33 void GetNextId(HistoryService::DownloadNextIdCallback* callback); |
| 34 |
30 // Retrieves DownloadCreateInfos saved in the history. | 35 // Retrieves DownloadCreateInfos saved in the history. |
31 void Load(HistoryService::DownloadQueryCallback* callback); | 36 void Load(HistoryService::DownloadQueryCallback* callback); |
32 | 37 |
33 // Checks whether |referrer_url| has been visited before today. This takes | 38 // Checks whether |referrer_url| has been visited before today. This takes |
34 // ownership of |callback|. | 39 // ownership of |callback|. |
35 void CheckVisitedReferrerBefore(int32 download_id, | 40 void CheckVisitedReferrerBefore(int32 download_id, |
36 const GURL& referrer_url, | 41 const GURL& referrer_url, |
37 VisitedBeforeDoneCallback* callback); | 42 VisitedBeforeDoneCallback* callback); |
38 | 43 |
39 // Adds a new entry for a download to the history database. | 44 // Adds a new entry for a download to the history database. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 82 |
78 CancelableRequestConsumer history_consumer_; | 83 CancelableRequestConsumer history_consumer_; |
79 | 84 |
80 // The outstanding requests made by CheckVisitedReferrerBefore(). | 85 // The outstanding requests made by CheckVisitedReferrerBefore(). |
81 VisitedBeforeRequestsMap visited_before_requests_; | 86 VisitedBeforeRequestsMap visited_before_requests_; |
82 | 87 |
83 DISALLOW_COPY_AND_ASSIGN(DownloadHistory); | 88 DISALLOW_COPY_AND_ASSIGN(DownloadHistory); |
84 }; | 89 }; |
85 | 90 |
86 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ | 91 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ |
OLD | NEW |