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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 base::hash_map<int64, DownloadItem*>::const_iterator iter_; | 107 base::hash_map<int64, DownloadItem*>::const_iterator iter_; |
108 // Allow copy and assign. | 108 // Allow copy and assign. |
109 }; | 109 }; |
110 | 110 |
111 } // namespace | 111 } // namespace |
112 | 112 |
113 namespace content { | 113 namespace content { |
114 | 114 |
115 // static | 115 // static |
116 DownloadManager* DownloadManager::Create( | 116 DownloadManager* DownloadManager::Create( |
117 content::DownloadManagerDelegate* delegate) { | 117 content::DownloadManagerDelegate* delegate, |
118 return new DownloadManagerImpl(delegate); | 118 net::NetLog* net_log) { |
| 119 return new DownloadManagerImpl(delegate, net_log); |
119 } | 120 } |
120 | 121 |
121 } // namespace content | 122 } // namespace content |
122 | 123 |
123 DownloadManagerImpl::DownloadManagerImpl( | 124 DownloadManagerImpl::DownloadManagerImpl( |
124 content::DownloadManagerDelegate* delegate) | 125 content::DownloadManagerDelegate* delegate, |
| 126 net::NetLog* net_log) |
125 : shutdown_needed_(false), | 127 : shutdown_needed_(false), |
126 browser_context_(NULL), | 128 browser_context_(NULL), |
127 file_manager_(NULL), | 129 file_manager_(NULL), |
128 delegate_(delegate), | 130 delegate_(delegate), |
129 largest_db_handle_in_history_(DownloadItem::kUninitializedHandle) { | 131 largest_db_handle_in_history_(DownloadItem::kUninitializedHandle), |
| 132 net_log_(net_log) { |
130 } | 133 } |
131 | 134 |
132 DownloadManagerImpl::~DownloadManagerImpl() { | 135 DownloadManagerImpl::~DownloadManagerImpl() { |
133 DCHECK(!shutdown_needed_); | 136 DCHECK(!shutdown_needed_); |
134 } | 137 } |
135 | 138 |
136 DownloadId DownloadManagerImpl::GetNextId() { | 139 DownloadId DownloadManagerImpl::GetNextId() { |
137 return delegate_->GetNextId(); | 140 return delegate_->GetNextId(); |
138 } | 141 } |
139 | 142 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 CHECK_96627(!ContainsKey(active_downloads_, download_id)); | 392 CHECK_96627(!ContainsKey(active_downloads_, download_id)); |
390 downloads_.insert(download); | 393 downloads_.insert(download); |
391 active_downloads_[download_id] = download; | 394 active_downloads_[download_id] = download; |
392 } | 395 } |
393 | 396 |
394 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( | 397 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( |
395 const FilePath& main_file_path, | 398 const FilePath& main_file_path, |
396 const GURL& page_url, | 399 const GURL& page_url, |
397 bool is_otr, | 400 bool is_otr, |
398 DownloadItem::Observer* observer) { | 401 DownloadItem::Observer* observer) { |
| 402 net::BoundNetLog bound_net_log = |
| 403 net::BoundNetLog::Make(GetNetLog(), net::NetLog::SOURCE_DOWNLOAD); |
399 DownloadItem* download = new DownloadItemImpl( | 404 DownloadItem* download = new DownloadItemImpl( |
400 this, main_file_path, page_url, is_otr, GetNextId(), net::BoundNetLog()); | 405 this, main_file_path, page_url, is_otr, GetNextId(), bound_net_log); |
401 | 406 |
402 download->AddObserver(observer); | 407 download->AddObserver(observer); |
403 | 408 |
404 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); | 409 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); |
405 downloads_.insert(download); | 410 downloads_.insert(download); |
406 save_page_downloads_[download->GetId()] = download; | 411 save_page_downloads_[download->GetId()] = download; |
407 | 412 |
408 // Will notify the observer in the callback. | 413 // Will notify the observer in the callback. |
409 delegate_->AddItemToPersistentStore(download); | 414 delegate_->AddItemToPersistentStore(download); |
410 | 415 |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 | 898 |
894 // The history service has retrieved all download entries. 'entries' contains | 899 // The history service has retrieved all download entries. 'entries' contains |
895 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). | 900 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). |
896 void DownloadManagerImpl::OnPersistentStoreQueryComplete( | 901 void DownloadManagerImpl::OnPersistentStoreQueryComplete( |
897 std::vector<DownloadPersistentStoreInfo>* entries) { | 902 std::vector<DownloadPersistentStoreInfo>* entries) { |
898 // TODO(rdsmith): Remove this and related logic when | 903 // TODO(rdsmith): Remove this and related logic when |
899 // http://crbug.com/96627 is fixed. | 904 // http://crbug.com/96627 is fixed. |
900 largest_db_handle_in_history_ = 0; | 905 largest_db_handle_in_history_ = 0; |
901 | 906 |
902 for (size_t i = 0; i < entries->size(); ++i) { | 907 for (size_t i = 0; i < entries->size(); ++i) { |
| 908 net::BoundNetLog bound_net_log = |
| 909 net::BoundNetLog::Make(GetNetLog(), net::NetLog::SOURCE_DOWNLOAD); |
903 DownloadItem* download = new DownloadItemImpl( | 910 DownloadItem* download = new DownloadItemImpl( |
904 this, GetNextId(), entries->at(i), net::BoundNetLog()); | 911 this, GetNextId(), entries->at(i), bound_net_log); |
905 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle())); | 912 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle())); |
906 downloads_.insert(download); | 913 downloads_.insert(download); |
907 history_downloads_[download->GetDbHandle()] = download; | 914 history_downloads_[download->GetDbHandle()] = download; |
908 VLOG(20) << __FUNCTION__ << "()" << i << ">" | 915 VLOG(20) << __FUNCTION__ << "()" << i << ">" |
909 << " download = " << download->DebugString(true); | 916 << " download = " << download->DebugString(true); |
910 | 917 |
911 if (download->GetDbHandle() > largest_db_handle_in_history_) | 918 if (download->GetDbHandle() > largest_db_handle_in_history_) |
912 largest_db_handle_in_history_ = download->GetDbHandle(); | 919 largest_db_handle_in_history_ = download->GetDbHandle(); |
913 } | 920 } |
914 NotifyModelChanged(); | 921 NotifyModelChanged(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 it != history_downloads_.end(); ++it) { | 1159 it != history_downloads_.end(); ++it) { |
1153 if (it->second->IsComplete() && !it->second->GetOpened()) | 1160 if (it->second->IsComplete() && !it->second->GetOpened()) |
1154 ++num_unopened; | 1161 ++num_unopened; |
1155 } | 1162 } |
1156 download_stats::RecordOpensOutstanding(num_unopened); | 1163 download_stats::RecordOpensOutstanding(num_unopened); |
1157 } | 1164 } |
1158 | 1165 |
1159 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { | 1166 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { |
1160 file_manager_ = file_manager; | 1167 file_manager_ = file_manager; |
1161 } | 1168 } |
| 1169 |
| 1170 net::NetLog* DownloadManagerImpl::GetNetLog() { |
| 1171 return net_log_; |
| 1172 } |
OLD | NEW |