Chromium Code Reviews| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 | 632 |
| 633 // Confirm we're in the proper set of states to be here; | 633 // Confirm we're in the proper set of states to be here; |
| 634 // in in_progress_, have all data, have a history handle, (validated or safe). | 634 // in in_progress_, have all data, have a history handle, (validated or safe). |
| 635 DCHECK_NE(DownloadItem::DANGEROUS, download->GetSafetyState()); | 635 DCHECK_NE(DownloadItem::DANGEROUS, download->GetSafetyState()); |
| 636 DCHECK_EQ(1u, in_progress_.count(download->GetId())); | 636 DCHECK_EQ(1u, in_progress_.count(download->GetId())); |
| 637 DCHECK(download->AllDataSaved()); | 637 DCHECK(download->AllDataSaved()); |
| 638 DCHECK(download->IsPersisted()); | 638 DCHECK(download->IsPersisted()); |
| 639 DCHECK_EQ(1u, history_downloads_.count(download->GetDbHandle())); | 639 DCHECK_EQ(1u, history_downloads_.count(download->GetDbHandle())); |
| 640 | 640 |
| 641 // Give the delegate a chance to override. | 641 // Give the delegate a chance to override. |
| 642 if (!delegate_->ShouldCompleteDownload(download)) | 642 // It's ok to keep re-setting the delegate's |maybe_complete_download| cb as |
| 643 // long as there isn't another call-point trying to set it to a different cb. | |
| 644 // TODO(benjhayden): Change the callback to point directly to the item instead | |
| 645 // of |this| when DownloadItem supports weak-ptrs. | |
| 646 if (!delegate_->ShouldCompleteDownload(download, base::Bind( | |
| 647 &DownloadManagerImpl::MaybeCompleteDownload, this, download))) | |
|
asanka
2012/05/01 15:54:10
The download item could go away before the callbac
benjhayden
2012/05/01 18:02:52
Done.
| |
| 643 return; | 648 return; |
| 644 | 649 |
| 645 VLOG(20) << __FUNCTION__ << "()" << " executing: download = " | 650 VLOG(20) << __FUNCTION__ << "()" << " executing: download = " |
| 646 << download->DebugString(false); | 651 << download->DebugString(false); |
| 647 | 652 |
| 648 // Remove the id from in_progress | 653 // Remove the id from in_progress |
| 649 in_progress_.erase(download->GetId()); | 654 in_progress_.erase(download->GetId()); |
| 650 | 655 |
| 651 delegate_->UpdateItemInPersistentStore(download); | 656 delegate_->UpdateItemInPersistentStore(download); |
| 652 | 657 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1208 if (it->second->IsComplete() && !it->second->GetOpened()) | 1213 if (it->second->IsComplete() && !it->second->GetOpened()) |
| 1209 ++num_unopened; | 1214 ++num_unopened; |
| 1210 } | 1215 } |
| 1211 download_stats::RecordOpensOutstanding(num_unopened); | 1216 download_stats::RecordOpensOutstanding(num_unopened); |
| 1212 } | 1217 } |
| 1213 | 1218 |
| 1214 void DownloadManagerImpl::SetFileManagerForTesting( | 1219 void DownloadManagerImpl::SetFileManagerForTesting( |
| 1215 DownloadFileManager* file_manager) { | 1220 DownloadFileManager* file_manager) { |
| 1216 file_manager_ = file_manager; | 1221 file_manager_ = file_manager; |
| 1217 } | 1222 } |
| OLD | NEW |