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

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

Issue 1875033005: [Downloads/History] Add tab-url and tab-referrer-url to DownloadRow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guid-fix
Patch Set: Update expectations for DownloadUIController test. Created 4 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/download/download_history_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 #if defined(ENABLE_EXTENSIONS) 120 #if defined(ENABLE_EXTENSIONS)
121 extensions::DownloadedByExtension* by_ext = 121 extensions::DownloadedByExtension* by_ext =
122 extensions::DownloadedByExtension::Get(item); 122 extensions::DownloadedByExtension::Get(item);
123 if (by_ext) { 123 if (by_ext) {
124 by_ext_id = by_ext->id(); 124 by_ext_id = by_ext->id();
125 by_ext_name = by_ext->name(); 125 by_ext_name = by_ext->name();
126 } 126 }
127 #endif 127 #endif
128 128
129 return history::DownloadRow( 129 return history::DownloadRow(
130 item->GetFullPath(), 130 item->GetFullPath(), item->GetTargetFilePath(), item->GetUrlChain(),
131 item->GetTargetFilePath(), 131 item->GetReferrerUrl(), item->GetTabUrl(), item->GetTabReferrerUrl(),
132 item->GetUrlChain(),
133 item->GetReferrerUrl(),
134 std::string(), // HTTP method (not available yet) 132 std::string(), // HTTP method (not available yet)
135 item->GetMimeType(), 133 item->GetMimeType(), item->GetOriginalMimeType(), item->GetStartTime(),
136 item->GetOriginalMimeType(), 134 item->GetEndTime(), item->GetETag(), item->GetLastModifiedTime(),
137 item->GetStartTime(), 135 item->GetReceivedBytes(), item->GetTotalBytes(),
138 item->GetEndTime(),
139 item->GetETag(),
140 item->GetLastModifiedTime(),
141 item->GetReceivedBytes(),
142 item->GetTotalBytes(),
143 history::ToHistoryDownloadState(item->GetState()), 136 history::ToHistoryDownloadState(item->GetState()),
144 history::ToHistoryDownloadDangerType(item->GetDangerType()), 137 history::ToHistoryDownloadDangerType(item->GetDangerType()),
145 history::ToHistoryDownloadInterruptReason(item->GetLastReason()), 138 history::ToHistoryDownloadInterruptReason(item->GetLastReason()),
146 std::string(), // Hash value (not available yet) 139 std::string(), // Hash value (not available yet)
147 history::ToHistoryDownloadId(item->GetId()), 140 history::ToHistoryDownloadId(item->GetId()), item->GetGuid(),
148 item->GetGuid(), 141 item->GetOpened(), by_ext_id, by_ext_name);
149 item->GetOpened(),
150 by_ext_id,
151 by_ext_name);
152 } 142 }
153 143
154 bool ShouldUpdateHistory(const history::DownloadRow* previous, 144 bool ShouldUpdateHistory(const history::DownloadRow* previous,
155 const history::DownloadRow& current) { 145 const history::DownloadRow& current) {
156 // Ignore url_chain, referrer, http_method, mime_type, original_mime_type, 146 // Ignore url_chain, referrer, http_method, mime_type, original_mime_type,
157 // start_time, id, guid, which don't change. 147 // start_time, id, guid, which don't change.
158 return ((previous == NULL) || 148 return ((previous == NULL) ||
159 (previous->current_path != current.current_path) || 149 (previous->current_path != current.current_path) ||
160 (previous->target_path != current.target_path) || 150 (previous->target_path != current.target_path) ||
161 (previous->end_time != current.end_time) || 151 (previous->end_time != current.end_time) ||
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 255
266 void DownloadHistory::QueryCallback(std::unique_ptr<InfoVector> infos) { 256 void DownloadHistory::QueryCallback(std::unique_ptr<InfoVector> infos) {
267 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 257 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
268 // ManagerGoingDown() may have happened before the history loaded. 258 // ManagerGoingDown() may have happened before the history loaded.
269 if (!notifier_.GetManager()) 259 if (!notifier_.GetManager())
270 return; 260 return;
271 for (InfoVector::const_iterator it = infos->begin(); 261 for (InfoVector::const_iterator it = infos->begin();
272 it != infos->end(); ++it) { 262 it != infos->end(); ++it) {
273 loading_id_ = history::ToContentDownloadId(it->id); 263 loading_id_ = history::ToContentDownloadId(it->id);
274 content::DownloadItem* item = notifier_.GetManager()->CreateDownloadItem( 264 content::DownloadItem* item = notifier_.GetManager()->CreateDownloadItem(
275 it->guid, 265 it->guid, loading_id_, it->current_path, it->target_path, it->url_chain,
276 loading_id_, 266 it->referrer_url, it->tab_url, it->tab_referrer_url, it->mime_type,
277 it->current_path, 267 it->original_mime_type, it->start_time, it->end_time, it->etag,
278 it->target_path, 268 it->last_modified, it->received_bytes, it->total_bytes,
279 it->url_chain,
280 it->referrer_url,
281 it->mime_type,
282 it->original_mime_type,
283 it->start_time,
284 it->end_time,
285 it->etag,
286 it->last_modified,
287 it->received_bytes,
288 it->total_bytes,
289 std::string(), // TODO(asanka): Need to persist and restore hash of 269 std::string(), // TODO(asanka): Need to persist and restore hash of
290 // partial file for an interrupted download. No need to 270 // partial file for an interrupted download. No need to
291 // store hash for a completed file. 271 // store hash for a completed file.
292 history::ToContentDownloadState(it->state), 272 history::ToContentDownloadState(it->state),
293 history::ToContentDownloadDangerType(it->danger_type), 273 history::ToContentDownloadDangerType(it->danger_type),
294 history::ToContentDownloadInterruptReason(it->interrupt_reason), 274 history::ToContentDownloadInterruptReason(it->interrupt_reason),
295 it->opened); 275 it->opened);
296 #if defined(ENABLE_EXTENSIONS) 276 #if defined(ENABLE_EXTENSIONS)
297 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { 277 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) {
298 new extensions::DownloadedByExtension( 278 new extensions::DownloadedByExtension(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 removing_ids_.insert(download_id); 455 removing_ids_.insert(download_id);
476 } 456 }
477 457
478 void DownloadHistory::RemoveDownloadsBatch() { 458 void DownloadHistory::RemoveDownloadsBatch() {
479 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 459 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
480 IdSet remove_ids; 460 IdSet remove_ids;
481 removing_ids_.swap(remove_ids); 461 removing_ids_.swap(remove_ids);
482 history_->RemoveDownloads(remove_ids); 462 history_->RemoveDownloads(remove_ids);
483 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); 463 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids));
484 } 464 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698