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 | |
35 // Retrieves DownloadCreateInfos saved in the history. | 30 // Retrieves DownloadCreateInfos saved in the history. |
36 void Load(HistoryService::DownloadQueryCallback* callback); | 31 void Load(HistoryService::DownloadQueryCallback* callback); |
37 | 32 |
38 // Checks whether |referrer_url| has been visited before today. This takes | 33 // Checks whether |referrer_url| has been visited before today. This takes |
39 // ownership of |callback|. | 34 // ownership of |callback|. |
40 void CheckVisitedReferrerBefore(int32 download_id, | 35 void CheckVisitedReferrerBefore(int32 download_id, |
41 const GURL& referrer_url, | 36 const GURL& referrer_url, |
42 VisitedBeforeDoneCallback* callback); | 37 VisitedBeforeDoneCallback* callback); |
43 | 38 |
44 // Adds a new entry for a download to the history database. | 39 // Adds a new entry for a download to the history database. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 77 |
83 CancelableRequestConsumer history_consumer_; | 78 CancelableRequestConsumer history_consumer_; |
84 | 79 |
85 // The outstanding requests made by CheckVisitedReferrerBefore(). | 80 // The outstanding requests made by CheckVisitedReferrerBefore(). |
86 VisitedBeforeRequestsMap visited_before_requests_; | 81 VisitedBeforeRequestsMap visited_before_requests_; |
87 | 82 |
88 DISALLOW_COPY_AND_ASSIGN(DownloadHistory); | 83 DISALLOW_COPY_AND_ASSIGN(DownloadHistory); |
89 }; | 84 }; |
90 | 85 |
91 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ | 86 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ |
OLD | NEW |