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 #include "chrome/browser/download/download_history.h" | 5 #include "chrome/browser/download/download_history.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/history/download_history_info.h" | 8 #include "chrome/browser/history/download_history_info.h" |
9 #include "chrome/browser/history/history_marshaling.h" | 9 #include "chrome/browser/history/history_marshaling.h" |
10 #include "chrome/browser/download/download_item.h" | 10 #include "chrome/browser/download/download_item.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 const FilePath& new_path) { | 113 const FilePath& new_path) { |
114 // No update necessary if the download was initiated while in incognito mode. | 114 // No update necessary if the download was initiated while in incognito mode. |
115 if (download_item->db_handle() <= kUninitializedHandle) | 115 if (download_item->db_handle() <= kUninitializedHandle) |
116 return; | 116 return; |
117 | 117 |
118 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 118 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
119 if (hs) | 119 if (hs) |
120 hs->UpdateDownloadPath(new_path, download_item->db_handle()); | 120 hs->UpdateDownloadPath(new_path, download_item->db_handle()); |
121 } | 121 } |
122 | 122 |
123 void DownloadHistory::RemoveEntry(DownloadItem* download_item) { | 123 void DownloadHistory::RemoveEntry(int64 db_handle) { |
124 // No update necessary if the download was initiated while in incognito mode. | 124 // No update necessary if the download was initiated while in incognito mode. |
125 if (download_item->db_handle() <= kUninitializedHandle) | 125 if (db_handle <= kUninitializedHandle) |
126 return; | 126 return; |
127 | 127 |
128 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 128 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
129 if (hs) | 129 if (hs) |
130 hs->RemoveDownload(download_item->db_handle()); | 130 hs->RemoveDownload(db_handle); |
131 } | 131 } |
132 | 132 |
133 void DownloadHistory::RemoveEntriesBetween(const base::Time remove_begin, | 133 void DownloadHistory::RemoveEntriesBetween(const base::Time remove_begin, |
134 const base::Time remove_end) { | 134 const base::Time remove_end) { |
135 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 135 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
136 if (hs) | 136 if (hs) |
137 hs->RemoveDownloadsBetween(remove_begin, remove_end); | 137 hs->RemoveDownloadsBetween(remove_begin, remove_end); |
138 } | 138 } |
139 | 139 |
140 int64 DownloadHistory::GetNextFakeDbHandle() { | 140 int64 DownloadHistory::GetNextFakeDbHandle() { |
141 return next_fake_db_handle_--; | 141 return next_fake_db_handle_--; |
142 } | 142 } |
143 | 143 |
144 void DownloadHistory::OnGotVisitCountToHost(HistoryService::Handle handle, | 144 void DownloadHistory::OnGotVisitCountToHost(HistoryService::Handle handle, |
145 bool found_visits, | 145 bool found_visits, |
146 int count, | 146 int count, |
147 base::Time first_visit) { | 147 base::Time first_visit) { |
148 VisitedBeforeRequestsMap::iterator request = | 148 VisitedBeforeRequestsMap::iterator request = |
149 visited_before_requests_.find(handle); | 149 visited_before_requests_.find(handle); |
150 DCHECK(request != visited_before_requests_.end()); | 150 DCHECK(request != visited_before_requests_.end()); |
151 int32 download_id = request->second.first; | 151 int32 download_id = request->second.first; |
152 VisitedBeforeDoneCallback* callback = request->second.second; | 152 VisitedBeforeDoneCallback* callback = request->second.second; |
153 visited_before_requests_.erase(request); | 153 visited_before_requests_.erase(request); |
154 callback->Run(download_id, found_visits && count && | 154 callback->Run(download_id, found_visits && count && |
155 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); | 155 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); |
156 delete callback; | 156 delete callback; |
157 } | 157 } |
OLD | NEW |