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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 base::hash_map<int64, DownloadItem*>::const_iterator iter_; | 120 base::hash_map<int64, DownloadItem*>::const_iterator iter_; |
121 // Allow copy and assign. | 121 // Allow copy and assign. |
122 }; | 122 }; |
123 | 123 |
124 } // namespace | 124 } // namespace |
125 | 125 |
126 namespace content { | 126 namespace content { |
127 | 127 |
128 // static | 128 // static |
129 DownloadManager* DownloadManager::Create( | 129 DownloadManager* DownloadManager::Create( |
130 content::DownloadManagerDelegate* delegate) { | 130 content::DownloadManagerDelegate* delegate, |
131 return new DownloadManagerImpl(delegate); | 131 net::NetLog* net_log) { |
132 return new DownloadManagerImpl(delegate, net_log); | |
132 } | 133 } |
133 | 134 |
134 } // namespace content | 135 } // namespace content |
135 | 136 |
136 DownloadManagerImpl::DownloadManagerImpl( | 137 DownloadManagerImpl::DownloadManagerImpl( |
137 content::DownloadManagerDelegate* delegate) | 138 content::DownloadManagerDelegate* delegate, |
139 net::NetLog* net_log) | |
138 : shutdown_needed_(false), | 140 : shutdown_needed_(false), |
139 browser_context_(NULL), | 141 browser_context_(NULL), |
140 file_manager_(NULL), | 142 file_manager_(NULL), |
141 delegate_(delegate), | 143 delegate_(delegate), |
142 largest_db_handle_in_history_(DownloadItem::kUninitializedHandle) { | 144 largest_db_handle_in_history_(DownloadItem::kUninitializedHandle), |
145 net_log_(net_log) { | |
143 } | 146 } |
144 | 147 |
145 DownloadManagerImpl::~DownloadManagerImpl() { | 148 DownloadManagerImpl::~DownloadManagerImpl() { |
146 DCHECK(!shutdown_needed_); | 149 DCHECK(!shutdown_needed_); |
147 } | 150 } |
148 | 151 |
149 DownloadId DownloadManagerImpl::GetNextId() { | 152 DownloadId DownloadManagerImpl::GetNextId() { |
150 return delegate_->GetNextId(); | 153 return delegate_->GetNextId(); |
151 } | 154 } |
152 | 155 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 downloads_.insert(download); | 406 downloads_.insert(download); |
404 active_downloads_[download_id] = download; | 407 active_downloads_[download_id] = download; |
405 } | 408 } |
406 | 409 |
407 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( | 410 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( |
408 const FilePath& main_file_path, | 411 const FilePath& main_file_path, |
409 const GURL& page_url, | 412 const GURL& page_url, |
410 bool is_otr, | 413 bool is_otr, |
411 DownloadItem::Observer* observer) { | 414 DownloadItem::Observer* observer) { |
412 DownloadItem* download = new DownloadItemImpl( | 415 DownloadItem* download = new DownloadItemImpl( |
413 this, main_file_path, page_url, is_otr, GetNextId(), NULL); | 416 this, main_file_path, page_url, is_otr, GetNextId(), GetNetLog()); |
414 | 417 |
415 download->AddObserver(observer); | 418 download->AddObserver(observer); |
416 | 419 |
417 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); | 420 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); |
418 downloads_.insert(download); | 421 downloads_.insert(download); |
419 save_page_downloads_[download->GetId()] = download; | 422 save_page_downloads_[download->GetId()] = download; |
420 | 423 |
421 // Will notify the observer in the callback. | 424 // Will notify the observer in the callback. |
422 delegate_->AddItemToPersistentStore(download); | 425 delegate_->AddItemToPersistentStore(download); |
423 | 426 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 // The history service has retrieved all download entries. 'entries' contains | 911 // The history service has retrieved all download entries. 'entries' contains |
909 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). | 912 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). |
910 void DownloadManagerImpl::OnPersistentStoreQueryComplete( | 913 void DownloadManagerImpl::OnPersistentStoreQueryComplete( |
911 std::vector<DownloadPersistentStoreInfo>* entries) { | 914 std::vector<DownloadPersistentStoreInfo>* entries) { |
912 // TODO(rdsmith): Remove this and related logic when | 915 // TODO(rdsmith): Remove this and related logic when |
913 // http://crbug.com/96627 is fixed. | 916 // http://crbug.com/96627 is fixed. |
914 largest_db_handle_in_history_ = 0; | 917 largest_db_handle_in_history_ = 0; |
915 | 918 |
916 for (size_t i = 0; i < entries->size(); ++i) { | 919 for (size_t i = 0; i < entries->size(); ++i) { |
917 DownloadItem* download = new DownloadItemImpl( | 920 DownloadItem* download = new DownloadItemImpl( |
918 this, GetNextId(), entries->at(i), NULL); | 921 this, GetNextId(), entries->at(i), GetNetLog()); |
919 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle())); | 922 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle())); |
920 downloads_.insert(download); | 923 downloads_.insert(download); |
921 history_downloads_[download->GetDbHandle()] = download; | 924 history_downloads_[download->GetDbHandle()] = download; |
922 VLOG(20) << __FUNCTION__ << "()" << i << ">" | 925 VLOG(20) << __FUNCTION__ << "()" << i << ">" |
923 << " download = " << download->DebugString(true); | 926 << " download = " << download->DebugString(true); |
924 | 927 |
925 if (download->GetDbHandle() > largest_db_handle_in_history_) | 928 if (download->GetDbHandle() > largest_db_handle_in_history_) |
926 largest_db_handle_in_history_ = download->GetDbHandle(); | 929 largest_db_handle_in_history_ = download->GetDbHandle(); |
927 } | 930 } |
928 NotifyModelChanged(); | 931 NotifyModelChanged(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1166 it != history_downloads_.end(); ++it) { | 1169 it != history_downloads_.end(); ++it) { |
1167 if (it->second->IsComplete() && !it->second->GetOpened()) | 1170 if (it->second->IsComplete() && !it->second->GetOpened()) |
1168 ++num_unopened; | 1171 ++num_unopened; |
1169 } | 1172 } |
1170 download_stats::RecordOpensOutstanding(num_unopened); | 1173 download_stats::RecordOpensOutstanding(num_unopened); |
1171 } | 1174 } |
1172 | 1175 |
1173 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { | 1176 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { |
1174 file_manager_ = file_manager; | 1177 file_manager_ = file_manager; |
1175 } | 1178 } |
1179 | |
1180 net::NetLog* DownloadManagerImpl::GetNetLog() { | |
1181 return net_log_; | |
Randy Smith (Not in Mondays)
2012/02/07 15:20:39
I'd argue that there's no point to this routine; i
ahendrickson
2012/02/07 17:58:38
Removed.
| |
1182 } | |
OLD | NEW |