| 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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 CHECK(download->IsCancelled()) | 1038 CHECK(download->IsCancelled()) |
| 1039 << " download = " << download->DebugString(true); | 1039 << " download = " << download->DebugString(true); |
| 1040 in_progress_.erase(download_id); | 1040 in_progress_.erase(download_id); |
| 1041 active_downloads_.erase(download_id); | 1041 active_downloads_.erase(download_id); |
| 1042 delegate_->UpdateItemInPersistentStore(download); | 1042 delegate_->UpdateItemInPersistentStore(download); |
| 1043 download->UpdateObservers(); | 1043 download->UpdateObservers(); |
| 1044 } | 1044 } |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 void DownloadManagerImpl::ShowDownloadInBrowser(DownloadItem* download) { | 1047 void DownloadManagerImpl::ShowDownloadInBrowser(DownloadItem* download) { |
| 1048 // The 'contents' may no longer exist if the user closed the tab before we | 1048 // The 'contents' may no longer exist if the user closed the contents before |
| 1049 // get this start completion event. | 1049 // we get this start completion event. |
| 1050 WebContents* content = download->GetWebContents(); | 1050 WebContents* content = download->GetWebContents(); |
| 1051 | 1051 |
| 1052 // If the contents no longer exists, we ask the embedder to suggest another | 1052 // If the contents no longer exists, we ask the embedder to suggest another |
| 1053 // tab. | 1053 // contents. |
| 1054 if (!content) | 1054 if (!content) |
| 1055 content = delegate_->GetAlternativeWebContentsToNotifyForDownload(); | 1055 content = delegate_->GetAlternativeWebContentsToNotifyForDownload(); |
| 1056 | 1056 |
| 1057 if (content && content->GetDelegate()) | 1057 if (content && content->GetDelegate()) |
| 1058 content->GetDelegate()->OnStartDownload(content, download); | 1058 content->GetDelegate()->OnStartDownload(content, download); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 int DownloadManagerImpl::InProgressCount() const { | 1061 int DownloadManagerImpl::InProgressCount() const { |
| 1062 // Don't use in_progress_.count() because Cancel() leaves items in | 1062 // Don't use in_progress_.count() because Cancel() leaves items in |
| 1063 // in_progress_ if they haven't made it into the persistent store yet. | 1063 // in_progress_ if they haven't made it into the persistent store yet. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 if (it->second->IsComplete() && !it->second->GetOpened()) | 1208 if (it->second->IsComplete() && !it->second->GetOpened()) |
| 1209 ++num_unopened; | 1209 ++num_unopened; |
| 1210 } | 1210 } |
| 1211 download_stats::RecordOpensOutstanding(num_unopened); | 1211 download_stats::RecordOpensOutstanding(num_unopened); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 void DownloadManagerImpl::SetFileManagerForTesting( | 1214 void DownloadManagerImpl::SetFileManagerForTesting( |
| 1215 DownloadFileManager* file_manager) { | 1215 DownloadFileManager* file_manager) { |
| 1216 file_manager_ = file_manager; | 1216 file_manager_ = file_manager; |
| 1217 } | 1217 } |
| OLD | NEW |