| 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/download/chrome_download_manager_delegate.h" | 8 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 9 #include "chrome/browser/history/history_marshaling.h" | 9 #include "chrome/browser/history/history_marshaling.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void DownloadHistory::UpdateEntry(DownloadItem* download_item) { | 104 void DownloadHistory::UpdateEntry(DownloadItem* download_item) { |
| 105 // Don't store info in the database if the download was initiated while in | 105 // Don't store info in the database if the download was initiated while in |
| 106 // incognito mode or if it hasn't been initialized in our database table. | 106 // incognito mode or if it hasn't been initialized in our database table. |
| 107 if (download_item->db_handle() <= DownloadItem::kUninitializedHandle) | 107 if (download_item->db_handle() <= DownloadItem::kUninitializedHandle) |
| 108 return; | 108 return; |
| 109 | 109 |
| 110 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 110 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
| 111 if (!hs) | 111 if (!hs) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 hs->UpdateDownload(download_item->received_bytes(), | 114 history::DownloadItemData data; |
| 115 download_item->state(), | 115 data.received_bytes = download_item->received_bytes(); |
| 116 download_item->db_handle()); | 116 data.state = download_item->state(); |
| 117 data.end_time = download_item->end_time(); |
| 118 data.opened = download_item->opened(); |
| 119 data.db_handle = download_item->db_handle(); |
| 120 |
| 121 hs->UpdateDownload(data); |
| 117 } | 122 } |
| 118 | 123 |
| 119 void DownloadHistory::UpdateDownloadPath(DownloadItem* download_item, | 124 void DownloadHistory::UpdateDownloadPath(DownloadItem* download_item, |
| 120 const FilePath& new_path) { | 125 const FilePath& new_path) { |
| 121 // No update necessary if the download was initiated while in incognito mode. | 126 // No update necessary if the download was initiated while in incognito mode. |
| 122 if (download_item->db_handle() <= DownloadItem::kUninitializedHandle) | 127 if (download_item->db_handle() <= DownloadItem::kUninitializedHandle) |
| 123 return; | 128 return; |
| 124 | 129 |
| 125 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 130 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
| 126 if (hs) | 131 if (hs) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 155 VisitedBeforeRequestsMap::iterator request = | 160 VisitedBeforeRequestsMap::iterator request = |
| 156 visited_before_requests_.find(handle); | 161 visited_before_requests_.find(handle); |
| 157 DCHECK(request != visited_before_requests_.end()); | 162 DCHECK(request != visited_before_requests_.end()); |
| 158 int32 download_id = request->second.first; | 163 int32 download_id = request->second.first; |
| 159 VisitedBeforeDoneCallback* callback = request->second.second; | 164 VisitedBeforeDoneCallback* callback = request->second.second; |
| 160 visited_before_requests_.erase(request); | 165 visited_before_requests_.erase(request); |
| 161 callback->Run(download_id, found_visits && count && | 166 callback->Run(download_id, found_visits && count && |
| 162 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); | 167 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); |
| 163 delete callback; | 168 delete callback; |
| 164 } | 169 } |
| OLD | NEW |