| 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 15 matching lines...) Expand all Loading... |
| 26 DownloadHistory::~DownloadHistory() { | 26 DownloadHistory::~DownloadHistory() { |
| 27 // For any outstanding requests to | 27 // For any outstanding requests to |
| 28 // HistoryService::GetVisibleVisitCountToHost(), since they'll be cancelled | 28 // HistoryService::GetVisibleVisitCountToHost(), since they'll be cancelled |
| 29 // and thus not call back to OnGotVisitCountToHost(), we need to delete the | 29 // and thus not call back to OnGotVisitCountToHost(), we need to delete the |
| 30 // associated VisitedBeforeDoneCallbacks. | 30 // associated VisitedBeforeDoneCallbacks. |
| 31 for (VisitedBeforeRequestsMap::iterator i(visited_before_requests_.begin()); | 31 for (VisitedBeforeRequestsMap::iterator i(visited_before_requests_.begin()); |
| 32 i != visited_before_requests_.end(); ++i) | 32 i != visited_before_requests_.end(); ++i) |
| 33 delete i->second.second; | 33 delete i->second.second; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void DownloadHistory::GetNextId( |
| 37 HistoryService::DownloadNextIdCallback* callback) { |
| 38 DCHECK(callback); |
| 39 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
| 40 if (!hs) { |
| 41 delete callback; |
| 42 return; |
| 43 } |
| 44 hs->GetNextDownloadId(&history_consumer_, callback); |
| 45 } |
| 46 |
| 36 void DownloadHistory::Load(HistoryService::DownloadQueryCallback* callback) { | 47 void DownloadHistory::Load(HistoryService::DownloadQueryCallback* callback) { |
| 37 DCHECK(callback); | 48 DCHECK(callback); |
| 38 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 49 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
| 39 if (!hs) { | 50 if (!hs) { |
| 40 delete callback; | 51 delete callback; |
| 41 return; | 52 return; |
| 42 } | 53 } |
| 43 hs->QueryDownloads(&history_consumer_, callback); | 54 hs->QueryDownloads(&history_consumer_, callback); |
| 44 | 55 |
| 45 // This is the initial load, so do a cleanup of corrupt in-progress entries. | 56 // This is the initial load, so do a cleanup of corrupt in-progress entries. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 VisitedBeforeRequestsMap::iterator request = | 159 VisitedBeforeRequestsMap::iterator request = |
| 149 visited_before_requests_.find(handle); | 160 visited_before_requests_.find(handle); |
| 150 DCHECK(request != visited_before_requests_.end()); | 161 DCHECK(request != visited_before_requests_.end()); |
| 151 int32 download_id = request->second.first; | 162 int32 download_id = request->second.first; |
| 152 VisitedBeforeDoneCallback* callback = request->second.second; | 163 VisitedBeforeDoneCallback* callback = request->second.second; |
| 153 visited_before_requests_.erase(request); | 164 visited_before_requests_.erase(request); |
| 154 callback->Run(download_id, found_visits && count && | 165 callback->Run(download_id, found_visits && count && |
| 155 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); | 166 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); |
| 156 delete callback; | 167 delete callback; |
| 157 } | 168 } |
| OLD | NEW |