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

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

Issue 7294013: Modified cancel and interrupt processing to avoid race with history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void AddEntry(DownloadItem* download_item, 44 void AddEntry(DownloadItem* download_item,
45 HistoryService::DownloadCreateCallback* callback); 45 HistoryService::DownloadCreateCallback* callback);
46 46
47 // Updates the history entry for |download_item|. 47 // Updates the history entry for |download_item|.
48 void UpdateEntry(DownloadItem* download_item); 48 void UpdateEntry(DownloadItem* download_item);
49 49
50 // Updates the download path for |download_item| to |new_path|. 50 // Updates the download path for |download_item| to |new_path|.
51 void UpdateDownloadPath(DownloadItem* download_item, 51 void UpdateDownloadPath(DownloadItem* download_item,
52 const FilePath& new_path); 52 const FilePath& new_path);
53 53
54 // Removes |download_item| from the history database. 54 // Removes the download identified by |db_handle| from the history database.
55 void RemoveEntry(DownloadItem* download_item); 55 // |db_handle| is used instead of the DownloadItem pointer to allow
56 // removal after deletion of the download item.
57 void RemoveEntry(int64 db_handle);
Randy Smith (Not in Mondays) 2011/06/30 23:05:13 Go over DownloadHistory interface; how "strange" i
Randy Smith (Not in Mondays) 2011/07/05 20:28:44 Hmmm. AddEntry and UpdateEntry sorta need the dow
56 58
57 // Removes download-related history entries in the given time range. 59 // Removes download-related history entries in the given time range.
58 void RemoveEntriesBetween(const base::Time remove_begin, 60 void RemoveEntriesBetween(const base::Time remove_begin,
59 const base::Time remove_end); 61 const base::Time remove_end);
60 62
61 // Returns a new unique database handle which will not collide with real ones. 63 // Returns a new unique database handle which will not collide with real ones.
62 int64 GetNextFakeDbHandle(); 64 int64 GetNextFakeDbHandle();
63 65
66 // Returns whether a given handle is fake. True for
67 // kUninitializedHandle and all returns from GetNextFakeDbHandle().
68 static bool IsFakeHandle(int64 db_handle);
69
64 private: 70 private:
65 typedef std::map<HistoryService::Handle, 71 typedef std::map<HistoryService::Handle,
66 std::pair<int32, VisitedBeforeDoneCallback*> > 72 std::pair<int32, VisitedBeforeDoneCallback*> >
67 VisitedBeforeRequestsMap; 73 VisitedBeforeRequestsMap;
68 74
69 void OnGotVisitCountToHost(HistoryService::Handle handle, 75 void OnGotVisitCountToHost(HistoryService::Handle handle,
70 bool found_visits, 76 bool found_visits,
71 int count, 77 int count,
72 base::Time first_visit); 78 base::Time first_visit);
73 79
74 Profile* profile_; 80 Profile* profile_;
75 81
76 // In case we don't have a valid db_handle, we use |fake_db_handle_| instead. 82 // 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. 83 // 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 84 // Downloads are expected to have unique handles, so we decrement the next
79 // fake handle value on every use. 85 // fake handle value on every use.
80 int64 next_fake_db_handle_; 86 int64 next_fake_db_handle_;
81 87
82 CancelableRequestConsumer history_consumer_; 88 CancelableRequestConsumer history_consumer_;
83 89
84 // The outstanding requests made by CheckVisitedReferrerBefore(). 90 // The outstanding requests made by CheckVisitedReferrerBefore().
85 VisitedBeforeRequestsMap visited_before_requests_; 91 VisitedBeforeRequestsMap visited_before_requests_;
86 92
87 DISALLOW_COPY_AND_ASSIGN(DownloadHistory); 93 DISALLOW_COPY_AND_ASSIGN(DownloadHistory);
88 }; 94 };
89 95
90 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_ 96 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_HISTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698