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

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

Issue 2705283003: Added last_access_time to DownloadItem and History DB (Closed)
Patch Set: Fix tests Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // DownloadHistory manages persisting DownloadItems to the history service by 5 // DownloadHistory manages persisting DownloadItems to the history service by
6 // observing a single DownloadManager and all its DownloadItems using an 6 // observing a single DownloadManager and all its DownloadItems using an
7 // AllDownloadItemNotifier. 7 // AllDownloadItemNotifier.
8 // 8 //
9 // DownloadHistory decides whether and when to add items to, remove items from, 9 // DownloadHistory decides whether and when to add items to, remove items from,
10 // and update items in the database. DownloadHistory uses DownloadHistoryData to 10 // and update items in the database. DownloadHistory uses DownloadHistoryData to
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 item->GetTabReferrerUrl(), 133 item->GetTabReferrerUrl(),
134 std::string(), // HTTP method (not available yet) 134 std::string(), // HTTP method (not available yet)
135 item->GetMimeType(), item->GetOriginalMimeType(), item->GetStartTime(), 135 item->GetMimeType(), item->GetOriginalMimeType(), item->GetStartTime(),
136 item->GetEndTime(), item->GetETag(), item->GetLastModifiedTime(), 136 item->GetEndTime(), item->GetETag(), item->GetLastModifiedTime(),
137 item->GetReceivedBytes(), item->GetTotalBytes(), 137 item->GetReceivedBytes(), item->GetTotalBytes(),
138 history::ToHistoryDownloadState(item->GetState()), 138 history::ToHistoryDownloadState(item->GetState()),
139 history::ToHistoryDownloadDangerType(item->GetDangerType()), 139 history::ToHistoryDownloadDangerType(item->GetDangerType()),
140 history::ToHistoryDownloadInterruptReason(item->GetLastReason()), 140 history::ToHistoryDownloadInterruptReason(item->GetLastReason()),
141 std::string(), // Hash value (not available yet) 141 std::string(), // Hash value (not available yet)
142 history::ToHistoryDownloadId(item->GetId()), item->GetGuid(), 142 history::ToHistoryDownloadId(item->GetId()), item->GetGuid(),
143 item->GetOpened(), by_ext_id, by_ext_name, 143 item->GetOpened(), item->GetLastAccessTime(), by_ext_id, by_ext_name,
144 // TODO(qinmin): get the slice information. 144 // TODO(qinmin): get the slice information.
145 std::vector<history::DownloadSliceInfo>()); 145 std::vector<history::DownloadSliceInfo>());
146 } 146 }
147 147
148 enum class ShouldUpdateHistoryResult { 148 enum class ShouldUpdateHistoryResult {
149 NO_UPDATE, 149 NO_UPDATE,
150 UPDATE, 150 UPDATE,
151 UPDATE_IMMEDIATELY, 151 UPDATE_IMMEDIATELY,
152 }; 152 };
153 153
(...skipping 17 matching lines...) Expand all
171 (previous->end_time != current.end_time) || 171 (previous->end_time != current.end_time) ||
172 (previous->received_bytes != current.received_bytes) || 172 (previous->received_bytes != current.received_bytes) ||
173 (previous->total_bytes != current.total_bytes) || 173 (previous->total_bytes != current.total_bytes) ||
174 (previous->etag != current.etag) || 174 (previous->etag != current.etag) ||
175 (previous->last_modified != current.last_modified) || 175 (previous->last_modified != current.last_modified) ||
176 (previous->state != current.state) || 176 (previous->state != current.state) ||
177 (previous->danger_type != current.danger_type) || 177 (previous->danger_type != current.danger_type) ||
178 (previous->interrupt_reason != current.interrupt_reason) || 178 (previous->interrupt_reason != current.interrupt_reason) ||
179 (previous->hash != current.hash) || 179 (previous->hash != current.hash) ||
180 (previous->opened != current.opened) || 180 (previous->opened != current.opened) ||
181 (previous->last_access_time != current.last_access_time) ||
181 (previous->by_ext_id != current.by_ext_id) || 182 (previous->by_ext_id != current.by_ext_id) ||
182 (previous->by_ext_name != current.by_ext_name)) { 183 (previous->by_ext_name != current.by_ext_name)) {
183 return ShouldUpdateHistoryResult::UPDATE; 184 return ShouldUpdateHistoryResult::UPDATE;
184 } 185 }
185 186
186 return ShouldUpdateHistoryResult::NO_UPDATE; 187 return ShouldUpdateHistoryResult::NO_UPDATE;
187 } 188 }
188 189
189 typedef std::vector<history::DownloadRow> InfoVector; 190 typedef std::vector<history::DownloadRow> InfoVector;
190 191
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 it->guid, loading_id_, it->current_path, it->target_path, it->url_chain, 291 it->guid, loading_id_, it->current_path, it->target_path, it->url_chain,
291 it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url, 292 it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url,
292 it->mime_type, it->original_mime_type, it->start_time, it->end_time, 293 it->mime_type, it->original_mime_type, it->start_time, it->end_time,
293 it->etag, it->last_modified, it->received_bytes, it->total_bytes, 294 it->etag, it->last_modified, it->received_bytes, it->total_bytes,
294 std::string(), // TODO(asanka): Need to persist and restore hash of 295 std::string(), // TODO(asanka): Need to persist and restore hash of
295 // partial file for an interrupted download. No need to 296 // partial file for an interrupted download. No need to
296 // store hash for a completed file. 297 // store hash for a completed file.
297 history::ToContentDownloadState(it->state), 298 history::ToContentDownloadState(it->state),
298 history::ToContentDownloadDangerType(it->danger_type), 299 history::ToContentDownloadDangerType(it->danger_type),
299 history::ToContentDownloadInterruptReason(it->interrupt_reason), 300 history::ToContentDownloadInterruptReason(it->interrupt_reason),
300 it->opened); 301 it->opened, it->last_access_time);
301 #if BUILDFLAG(ENABLE_EXTENSIONS) 302 #if BUILDFLAG(ENABLE_EXTENSIONS)
302 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { 303 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) {
303 new extensions::DownloadedByExtension( 304 new extensions::DownloadedByExtension(
304 item, it->by_ext_id, it->by_ext_name); 305 item, it->by_ext_id, it->by_ext_name);
305 item->UpdateObservers(); 306 item->UpdateObservers();
306 } 307 }
307 #endif 308 #endif
308 DCHECK_EQ(DownloadHistoryData::PERSISTED, 309 DCHECK_EQ(DownloadHistoryData::PERSISTED,
309 DownloadHistoryData::Get(item)->state()); 310 DownloadHistoryData::Get(item)->state());
310 ++history_size_; 311 ++history_size_;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 } 492 }
492 493
493 void DownloadHistory::RemoveDownloadsBatch() { 494 void DownloadHistory::RemoveDownloadsBatch() {
494 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 495 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
495 IdSet remove_ids; 496 IdSet remove_ids;
496 removing_ids_.swap(remove_ids); 497 removing_ids_.swap(remove_ids);
497 history_->RemoveDownloads(remove_ids); 498 history_->RemoveDownloads(remove_ids);
498 for (Observer& observer : observers_) 499 for (Observer& observer : observers_)
499 observer.OnDownloadsRemoved(remove_ids); 500 observer.OnDownloadsRemoved(remove_ids);
500 } 501 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698