OLD | NEW |
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 #include "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 const std::string& mime_type, | 165 const std::string& mime_type, |
166 std::unique_ptr<DownloadRequestHandleInterface> request_handle, | 166 std::unique_ptr<DownloadRequestHandleInterface> request_handle, |
167 const net::NetLogWithSource& net_log) override { | 167 const net::NetLogWithSource& net_log) override { |
168 return new DownloadItemImpl(delegate, download_id, path, url, mime_type, | 168 return new DownloadItemImpl(delegate, download_id, path, url, mime_type, |
169 std::move(request_handle), net_log); | 169 std::move(request_handle), net_log); |
170 } | 170 } |
171 }; | 171 }; |
172 | 172 |
173 } // namespace | 173 } // namespace |
174 | 174 |
175 DownloadManagerImpl::DownloadManagerImpl( | 175 DownloadManagerImpl::DownloadManagerImpl(net::NetLog* net_log, |
176 net::NetLog* net_log, | 176 BrowserContext* browser_context) |
177 BrowserContext* browser_context) | |
178 : item_factory_(new DownloadItemFactoryImpl()), | 177 : item_factory_(new DownloadItemFactoryImpl()), |
179 file_factory_(new DownloadFileFactory()), | 178 file_factory_(new DownloadFileFactory()), |
180 shutdown_needed_(true), | 179 shutdown_needed_(true), |
181 browser_context_(browser_context), | 180 browser_context_(browser_context), |
182 delegate_(NULL), | 181 delegate_(nullptr), |
183 net_log_(net_log), | 182 net_log_(net_log), |
184 weak_factory_(this) { | 183 weak_factory_(this) { |
185 DCHECK(browser_context); | 184 DCHECK(browser_context); |
186 } | 185 } |
187 | 186 |
188 DownloadManagerImpl::~DownloadManagerImpl() { | 187 DownloadManagerImpl::~DownloadManagerImpl() { |
189 DCHECK(!shutdown_needed_); | 188 DCHECK(!shutdown_needed_); |
190 } | 189 } |
191 | 190 |
192 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( | 191 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( |
193 uint32_t id, | 192 uint32_t id, |
194 const DownloadCreateInfo& info) { | 193 const DownloadCreateInfo& info) { |
195 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 194 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
196 DCHECK(!base::ContainsKey(downloads_, id)); | 195 DCHECK(!base::ContainsKey(downloads_, id)); |
197 net::NetLogWithSource net_log = | 196 net::NetLogWithSource net_log = |
198 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD); | 197 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD); |
199 DownloadItemImpl* download = | 198 DownloadItemImpl* download = |
200 item_factory_->CreateActiveItem(this, id, info, net_log); | 199 item_factory_->CreateActiveItem(this, id, info, net_log); |
201 downloads_[id] = download; | 200 downloads_[id] = base::WrapUnique(download); |
202 downloads_by_guid_[download->GetGuid()] = download; | 201 downloads_by_guid_[download->GetGuid()] = download; |
203 return download; | 202 return download; |
204 } | 203 } |
205 | 204 |
206 void DownloadManagerImpl::GetNextId(const DownloadIdCallback& callback) { | 205 void DownloadManagerImpl::GetNextId(const DownloadIdCallback& callback) { |
207 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 206 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
208 if (delegate_) { | 207 if (delegate_) { |
209 delegate_->GetNextId(callback); | 208 delegate_->GetNextId(callback); |
210 return; | 209 return; |
211 } | 210 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 275 |
277 for (auto& observer : observers_) | 276 for (auto& observer : observers_) |
278 observer.ManagerGoingDown(this); | 277 observer.ManagerGoingDown(this); |
279 // TODO(benjhayden): Consider clearing observers_. | 278 // TODO(benjhayden): Consider clearing observers_. |
280 | 279 |
281 // If there are in-progress downloads, cancel them. This also goes for | 280 // If there are in-progress downloads, cancel them. This also goes for |
282 // dangerous downloads which will remain in history if they aren't explicitly | 281 // dangerous downloads which will remain in history if they aren't explicitly |
283 // accepted or discarded. Canceling will remove the intermediate download | 282 // accepted or discarded. Canceling will remove the intermediate download |
284 // file. | 283 // file. |
285 for (const auto& it : downloads_) { | 284 for (const auto& it : downloads_) { |
286 DownloadItemImpl* download = it.second; | 285 DownloadItemImpl* download = it.second.get(); |
287 if (download->GetState() == DownloadItem::IN_PROGRESS) | 286 if (download->GetState() == DownloadItem::IN_PROGRESS) |
288 download->Cancel(false); | 287 download->Cancel(false); |
289 } | 288 } |
290 base::STLDeleteValues(&downloads_); | 289 downloads_.clear(); |
291 downloads_by_guid_.clear(); | 290 downloads_by_guid_.clear(); |
292 url_downloaders_.clear(); | 291 url_downloaders_.clear(); |
293 | 292 |
294 // We'll have nothing more to report to the observers after this point. | 293 // We'll have nothing more to report to the observers after this point. |
295 observers_.Clear(); | 294 observers_.Clear(); |
296 | 295 |
297 if (delegate_) | 296 if (delegate_) |
298 delegate_->Shutdown(); | 297 delegate_->Shutdown(); |
299 delegate_ = NULL; | 298 delegate_ = nullptr; |
300 } | 299 } |
301 | 300 |
302 void DownloadManagerImpl::StartDownload( | 301 void DownloadManagerImpl::StartDownload( |
303 std::unique_ptr<DownloadCreateInfo> info, | 302 std::unique_ptr<DownloadCreateInfo> info, |
304 std::unique_ptr<ByteStreamReader> stream, | 303 std::unique_ptr<ByteStreamReader> stream, |
305 const DownloadUrlParameters::OnStartedCallback& on_started) { | 304 const DownloadUrlParameters::OnStartedCallback& on_started) { |
306 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 305 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
307 DCHECK(info); | 306 DCHECK(info); |
308 // |stream| is only non-nil if the download request was successful. | 307 // |stream| is only non-nil if the download request was successful. |
309 DCHECK((info->result == DOWNLOAD_INTERRUPT_REASON_NONE && stream.get()) || | 308 DCHECK((info->result == DOWNLOAD_INTERRUPT_REASON_NONE && stream.get()) || |
(...skipping 15 matching lines...) Expand all Loading... |
325 } | 324 } |
326 | 325 |
327 void DownloadManagerImpl::StartDownloadWithId( | 326 void DownloadManagerImpl::StartDownloadWithId( |
328 std::unique_ptr<DownloadCreateInfo> info, | 327 std::unique_ptr<DownloadCreateInfo> info, |
329 std::unique_ptr<ByteStreamReader> stream, | 328 std::unique_ptr<ByteStreamReader> stream, |
330 const DownloadUrlParameters::OnStartedCallback& on_started, | 329 const DownloadUrlParameters::OnStartedCallback& on_started, |
331 bool new_download, | 330 bool new_download, |
332 uint32_t id) { | 331 uint32_t id) { |
333 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 332 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
334 DCHECK_NE(content::DownloadItem::kInvalidId, id); | 333 DCHECK_NE(content::DownloadItem::kInvalidId, id); |
335 DownloadItemImpl* download = NULL; | 334 DownloadItemImpl* download = nullptr; |
336 if (new_download) { | 335 if (new_download) { |
337 download = CreateActiveItem(id, *info); | 336 download = CreateActiveItem(id, *info); |
338 } else { | 337 } else { |
339 DownloadMap::iterator item_iterator = downloads_.find(id); | 338 auto item_iterator = downloads_.find(id); |
340 // Trying to resume an interrupted download. | 339 // Trying to resume an interrupted download. |
341 if (item_iterator == downloads_.end() || | 340 if (item_iterator == downloads_.end() || |
342 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { | 341 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { |
343 // If the download is no longer known to the DownloadManager, then it was | 342 // If the download is no longer known to the DownloadManager, then it was |
344 // removed after it was resumed. Ignore. If the download is cancelled | 343 // removed after it was resumed. Ignore. If the download is cancelled |
345 // while resuming, then also ignore the request. | 344 // while resuming, then also ignore the request. |
346 info->request_handle->CancelRequest(); | 345 info->request_handle->CancelRequest(); |
347 if (!on_started.is_null()) | 346 if (!on_started.is_null()) |
348 on_started.Run(NULL, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); | 347 on_started.Run(nullptr, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); |
349 // The ByteStreamReader lives and dies on the FILE thread. | 348 // The ByteStreamReader lives and dies on the FILE thread. |
350 if (info->result == DOWNLOAD_INTERRUPT_REASON_NONE) | 349 if (info->result == DOWNLOAD_INTERRUPT_REASON_NONE) |
351 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, | 350 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, |
352 stream.release()); | 351 stream.release()); |
353 return; | 352 return; |
354 } | 353 } |
355 download = item_iterator->second; | 354 download = item_iterator->second.get(); |
356 } | 355 } |
357 | 356 |
358 base::FilePath default_download_directory; | 357 base::FilePath default_download_directory; |
359 if (delegate_) { | 358 if (delegate_) { |
360 base::FilePath website_save_directory; // Unused | 359 base::FilePath website_save_directory; // Unused |
361 bool skip_dir_check = false; // Unused | 360 bool skip_dir_check = false; // Unused |
362 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory, | 361 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory, |
363 &default_download_directory, &skip_dir_check); | 362 &default_download_directory, &skip_dir_check); |
364 } | 363 } |
365 | 364 |
(...skipping 23 matching lines...) Expand all Loading... |
389 observer.OnDownloadCreated(this, download); | 388 observer.OnDownloadCreated(this, download); |
390 } | 389 } |
391 | 390 |
392 if (!on_started.is_null()) | 391 if (!on_started.is_null()) |
393 on_started.Run(download, DOWNLOAD_INTERRUPT_REASON_NONE); | 392 on_started.Run(download, DOWNLOAD_INTERRUPT_REASON_NONE); |
394 } | 393 } |
395 | 394 |
396 void DownloadManagerImpl::CheckForHistoryFilesRemoval() { | 395 void DownloadManagerImpl::CheckForHistoryFilesRemoval() { |
397 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 396 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
398 for (const auto& it : downloads_) { | 397 for (const auto& it : downloads_) { |
399 DownloadItemImpl* item = it.second; | 398 DownloadItemImpl* item = it.second.get(); |
400 CheckForFileRemoval(item); | 399 CheckForFileRemoval(item); |
401 } | 400 } |
402 } | 401 } |
403 | 402 |
404 void DownloadManagerImpl::CheckForFileRemoval(DownloadItemImpl* download_item) { | 403 void DownloadManagerImpl::CheckForFileRemoval(DownloadItemImpl* download_item) { |
405 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 404 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
406 if ((download_item->GetState() == DownloadItem::COMPLETE) && | 405 if ((download_item->GetState() == DownloadItem::COMPLETE) && |
407 !download_item->GetFileExternallyRemoved() && | 406 !download_item->GetFileExternallyRemoved() && |
408 delegate_) { | 407 delegate_) { |
409 delegate_->CheckForFileExistence( | 408 delegate_->CheckForFileExistence( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 const DownloadItemImplCreated& item_created, | 452 const DownloadItemImplCreated& item_created, |
454 uint32_t id) { | 453 uint32_t id) { |
455 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 454 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
456 DCHECK_NE(content::DownloadItem::kInvalidId, id); | 455 DCHECK_NE(content::DownloadItem::kInvalidId, id); |
457 DCHECK(!base::ContainsKey(downloads_, id)); | 456 DCHECK(!base::ContainsKey(downloads_, id)); |
458 net::NetLogWithSource net_log = | 457 net::NetLogWithSource net_log = |
459 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD); | 458 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD); |
460 DownloadItemImpl* download_item = item_factory_->CreateSavePageItem( | 459 DownloadItemImpl* download_item = item_factory_->CreateSavePageItem( |
461 this, id, main_file_path, page_url, mime_type, std::move(request_handle), | 460 this, id, main_file_path, page_url, mime_type, std::move(request_handle), |
462 net_log); | 461 net_log); |
463 downloads_[download_item->GetId()] = download_item; | 462 downloads_[download_item->GetId()] = base::WrapUnique(download_item); |
464 DCHECK(!base::ContainsKey(downloads_by_guid_, download_item->GetGuid())); | 463 DCHECK(!base::ContainsKey(downloads_by_guid_, download_item->GetGuid())); |
465 downloads_by_guid_[download_item->GetGuid()] = download_item; | 464 downloads_by_guid_[download_item->GetGuid()] = download_item; |
466 for (auto& observer : observers_) | 465 for (auto& observer : observers_) |
467 observer.OnDownloadCreated(this, download_item); | 466 observer.OnDownloadCreated(this, download_item); |
468 if (!item_created.is_null()) | 467 if (!item_created.is_null()) |
469 item_created.Run(download_item); | 468 item_created.Run(download_item); |
470 } | 469 } |
471 | 470 |
472 void DownloadManagerImpl::OnSavePackageSuccessfullyFinished( | 471 void DownloadManagerImpl::OnSavePackageSuccessfullyFinished( |
473 DownloadItem* download_item) { | 472 DownloadItem* download_item) { |
(...skipping 28 matching lines...) Expand all Loading... |
502 | 501 |
503 DownloadFileFactory* DownloadManagerImpl::GetDownloadFileFactoryForTesting() { | 502 DownloadFileFactory* DownloadManagerImpl::GetDownloadFileFactoryForTesting() { |
504 return file_factory_.get(); | 503 return file_factory_.get(); |
505 } | 504 } |
506 | 505 |
507 void DownloadManagerImpl::DownloadRemoved(DownloadItemImpl* download) { | 506 void DownloadManagerImpl::DownloadRemoved(DownloadItemImpl* download) { |
508 if (!download) | 507 if (!download) |
509 return; | 508 return; |
510 | 509 |
511 downloads_by_guid_.erase(download->GetGuid()); | 510 downloads_by_guid_.erase(download->GetGuid()); |
512 | 511 downloads_.erase(download->GetId()); |
513 uint32_t download_id = download->GetId(); | |
514 if (downloads_.erase(download_id) == 0) | |
515 return; | |
516 delete download; | |
517 } | 512 } |
518 | 513 |
519 void DownloadManagerImpl::AddUrlDownloader( | 514 void DownloadManagerImpl::AddUrlDownloader( |
520 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> | 515 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> |
521 downloader) { | 516 downloader) { |
522 if (downloader) | 517 if (downloader) |
523 url_downloaders_.push_back(std::move(downloader)); | 518 url_downloaders_.push_back(std::move(downloader)); |
524 } | 519 } |
525 | 520 |
526 void DownloadManagerImpl::RemoveUrlDownloader(UrlDownloader* downloader) { | 521 void DownloadManagerImpl::RemoveUrlDownloader(UrlDownloader* downloader) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 const DownloadItemImpl* download_item) { | 601 const DownloadItemImpl* download_item) { |
607 return url_filter.Run(download_item->GetURL()) && | 602 return url_filter.Run(download_item->GetURL()) && |
608 download_item->GetStartTime() >= remove_begin && | 603 download_item->GetStartTime() >= remove_begin && |
609 (remove_end.is_null() || download_item->GetStartTime() < remove_end); | 604 (remove_end.is_null() || download_item->GetStartTime() < remove_end); |
610 } | 605 } |
611 | 606 |
612 } // namespace | 607 } // namespace |
613 | 608 |
614 int DownloadManagerImpl::RemoveDownloads(const DownloadRemover& remover) { | 609 int DownloadManagerImpl::RemoveDownloads(const DownloadRemover& remover) { |
615 int count = 0; | 610 int count = 0; |
616 DownloadMap::const_iterator it = downloads_.begin(); | 611 auto it = downloads_.begin(); |
617 while (it != downloads_.end()) { | 612 while (it != downloads_.end()) { |
618 DownloadItemImpl* download = it->second; | 613 DownloadItemImpl* download = it->second.get(); |
619 | 614 |
620 // Increment done here to protect against invalidation below. | 615 // Increment done here to protect against invalidation below. |
621 ++it; | 616 ++it; |
622 | 617 |
623 if (download->GetState() != DownloadItem::IN_PROGRESS && | 618 if (download->GetState() != DownloadItem::IN_PROGRESS && |
624 remover.Run(download)) { | 619 remover.Run(download)) { |
625 download->Remove(); | 620 download->Remove(); |
626 count++; | 621 count++; |
627 } | 622 } |
628 } | 623 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 const std::string& last_modified, | 685 const std::string& last_modified, |
691 int64_t received_bytes, | 686 int64_t received_bytes, |
692 int64_t total_bytes, | 687 int64_t total_bytes, |
693 const std::string& hash, | 688 const std::string& hash, |
694 DownloadItem::DownloadState state, | 689 DownloadItem::DownloadState state, |
695 DownloadDangerType danger_type, | 690 DownloadDangerType danger_type, |
696 DownloadInterruptReason interrupt_reason, | 691 DownloadInterruptReason interrupt_reason, |
697 bool opened) { | 692 bool opened) { |
698 if (base::ContainsKey(downloads_, id)) { | 693 if (base::ContainsKey(downloads_, id)) { |
699 NOTREACHED(); | 694 NOTREACHED(); |
700 return NULL; | 695 return nullptr; |
701 } | 696 } |
702 DCHECK(!base::ContainsKey(downloads_by_guid_, guid)); | 697 DCHECK(!base::ContainsKey(downloads_by_guid_, guid)); |
703 DownloadItemImpl* item = item_factory_->CreatePersistedItem( | 698 DownloadItemImpl* item = item_factory_->CreatePersistedItem( |
704 this, guid, id, current_path, target_path, url_chain, referrer_url, | 699 this, guid, id, current_path, target_path, url_chain, referrer_url, |
705 site_url, tab_url, tab_refererr_url, mime_type, original_mime_type, | 700 site_url, tab_url, tab_refererr_url, mime_type, original_mime_type, |
706 start_time, end_time, etag, last_modified, received_bytes, total_bytes, | 701 start_time, end_time, etag, last_modified, received_bytes, total_bytes, |
707 hash, state, danger_type, interrupt_reason, opened, | 702 hash, state, danger_type, interrupt_reason, opened, |
708 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD)); | 703 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD)); |
709 downloads_[id] = item; | 704 downloads_[id] = base::WrapUnique(item); |
710 downloads_by_guid_[guid] = item; | 705 downloads_by_guid_[guid] = item; |
711 for (auto& observer : observers_) | 706 for (auto& observer : observers_) |
712 observer.OnDownloadCreated(this, item); | 707 observer.OnDownloadCreated(this, item); |
713 DVLOG(20) << __func__ << "() download = " << item->DebugString(true); | 708 DVLOG(20) << __func__ << "() download = " << item->DebugString(true); |
714 return item; | 709 return item; |
715 } | 710 } |
716 | 711 |
717 int DownloadManagerImpl::InProgressCount() const { | 712 int DownloadManagerImpl::InProgressCount() const { |
718 int count = 0; | 713 int count = 0; |
719 for (const auto& it : downloads_) { | 714 for (const auto& it : downloads_) { |
(...skipping 12 matching lines...) Expand all Loading... |
732 it.second->GetDangerType() != DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST && | 727 it.second->GetDangerType() != DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST && |
733 it.second->GetDangerType() != | 728 it.second->GetDangerType() != |
734 DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED) { | 729 DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED) { |
735 ++count; | 730 ++count; |
736 } | 731 } |
737 } | 732 } |
738 return count; | 733 return count; |
739 } | 734 } |
740 | 735 |
741 DownloadItem* DownloadManagerImpl::GetDownload(uint32_t download_id) { | 736 DownloadItem* DownloadManagerImpl::GetDownload(uint32_t download_id) { |
742 return base::ContainsKey(downloads_, download_id) ? downloads_[download_id] | 737 return base::ContainsKey(downloads_, download_id) |
743 : nullptr; | 738 ? downloads_[download_id].get() |
| 739 : nullptr; |
744 } | 740 } |
745 | 741 |
746 DownloadItem* DownloadManagerImpl::GetDownloadByGuid(const std::string& guid) { | 742 DownloadItem* DownloadManagerImpl::GetDownloadByGuid(const std::string& guid) { |
747 DCHECK(guid == base::ToUpperASCII(guid)); | 743 DCHECK(guid == base::ToUpperASCII(guid)); |
748 return base::ContainsKey(downloads_by_guid_, guid) ? downloads_by_guid_[guid] | 744 return base::ContainsKey(downloads_by_guid_, guid) ? downloads_by_guid_[guid] |
749 : nullptr; | 745 : nullptr; |
750 } | 746 } |
751 | 747 |
752 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { | 748 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { |
753 for (const auto& it : downloads_) { | 749 for (const auto& it : downloads_) { |
754 downloads->push_back(it.second); | 750 downloads->push_back(it.second.get()); |
755 } | 751 } |
756 } | 752 } |
757 | 753 |
758 void DownloadManagerImpl::OpenDownload(DownloadItemImpl* download) { | 754 void DownloadManagerImpl::OpenDownload(DownloadItemImpl* download) { |
759 int num_unopened = 0; | 755 int num_unopened = 0; |
760 for (const auto& it : downloads_) { | 756 for (const auto& it : downloads_) { |
761 DownloadItemImpl* item = it.second; | 757 DownloadItemImpl* item = it.second.get(); |
762 if ((item->GetState() == DownloadItem::COMPLETE) && | 758 if ((item->GetState() == DownloadItem::COMPLETE) && |
763 !item->GetOpened()) | 759 !item->GetOpened()) |
764 ++num_unopened; | 760 ++num_unopened; |
765 } | 761 } |
766 RecordOpensOutstanding(num_unopened); | 762 RecordOpensOutstanding(num_unopened); |
767 | 763 |
768 if (delegate_) | 764 if (delegate_) |
769 delegate_->OpenDownload(download); | 765 delegate_->OpenDownload(download); |
770 } | 766 } |
771 | 767 |
772 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 768 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
773 if (delegate_) | 769 if (delegate_) |
774 delegate_->ShowDownloadInShell(download); | 770 delegate_->ShowDownloadInShell(download); |
775 } | 771 } |
776 | 772 |
777 } // namespace content | 773 } // namespace content |
OLD | NEW |