| 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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 if (item->IsInProgress()) | 920 if (item->IsInProgress()) |
| 921 ++count; | 921 ++count; |
| 922 } | 922 } |
| 923 return count; | 923 return count; |
| 924 } | 924 } |
| 925 | 925 |
| 926 void DownloadManagerImpl::NotifyModelChanged() { | 926 void DownloadManagerImpl::NotifyModelChanged() { |
| 927 FOR_EACH_OBSERVER(Observer, observers_, ModelChanged(this)); | 927 FOR_EACH_OBSERVER(Observer, observers_, ModelChanged(this)); |
| 928 } | 928 } |
| 929 | 929 |
| 930 DownloadItem* DownloadManagerImpl::GetDownloadItem(int download_id) { | |
| 931 DownloadItem* download = GetDownload(download_id); | |
| 932 return (download && download->IsPersisted()) ? download : NULL; | |
| 933 } | |
| 934 | |
| 935 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) { | 930 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) { |
| 936 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; | 931 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; |
| 937 } | 932 } |
| 938 | 933 |
| 939 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { | 934 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { |
| 940 for (DownloadMap::iterator it = downloads_.begin(); | 935 for (DownloadMap::iterator it = downloads_.begin(); |
| 941 it != downloads_.end(); ++it) { | 936 it != downloads_.end(); ++it) { |
| 942 downloads->push_back(it->second); | 937 downloads->push_back(it->second); |
| 943 } | 938 } |
| 944 } | 939 } |
| 945 | 940 |
| 946 DownloadItem* DownloadManagerImpl::GetActiveDownloadItem(int download_id) { | |
| 947 if (ContainsKey(active_downloads_, download_id)) | |
| 948 return active_downloads_[download_id]; | |
| 949 return NULL; | |
| 950 } | |
| 951 | |
| 952 // Confirm that everything in all maps is also in |downloads_|, and that | 941 // Confirm that everything in all maps is also in |downloads_|, and that |
| 953 // everything in |downloads_| is also in some other map. | 942 // everything in |downloads_| is also in some other map. |
| 954 void DownloadManagerImpl::AssertContainersConsistent() const { | 943 void DownloadManagerImpl::AssertContainersConsistent() const { |
| 955 #if !defined(NDEBUG) | 944 #if !defined(NDEBUG) |
| 956 // Turn everything into sets. | 945 // Turn everything into sets. |
| 957 const DownloadMap* input_maps[] = {&active_downloads_}; | 946 const DownloadMap* input_maps[] = {&active_downloads_}; |
| 958 DownloadSet active_set; | 947 DownloadSet active_set; |
| 959 DownloadSet* all_sets[] = {&active_set}; | 948 DownloadSet* all_sets[] = {&active_set}; |
| 960 DCHECK_EQ(ARRAYSIZE_UNSAFE(input_maps), ARRAYSIZE_UNSAFE(all_sets)); | 949 DCHECK_EQ(ARRAYSIZE_UNSAFE(input_maps), ARRAYSIZE_UNSAFE(all_sets)); |
| 961 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_maps); i++) { | 950 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_maps); i++) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 void DownloadManagerImpl::DownloadRenamedToFinalName( | 1035 void DownloadManagerImpl::DownloadRenamedToFinalName( |
| 1047 DownloadItemImpl* download) { | 1036 DownloadItemImpl* download) { |
| 1048 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1037 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1049 // If the rename failed, we receive an OnDownloadInterrupted() call before we | 1038 // If the rename failed, we receive an OnDownloadInterrupted() call before we |
| 1050 // receive the DownloadRenamedToFinalName() call. | 1039 // receive the DownloadRenamedToFinalName() call. |
| 1051 if (delegate_) { | 1040 if (delegate_) { |
| 1052 delegate_->UpdatePathForItemInPersistentStore( | 1041 delegate_->UpdatePathForItemInPersistentStore( |
| 1053 download, download->GetFullPath()); | 1042 download, download->GetFullPath()); |
| 1054 } | 1043 } |
| 1055 } | 1044 } |
| OLD | NEW |