| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 FilePath DownloadManagerImpl::LastDownloadPath() { | 388 FilePath DownloadManagerImpl::LastDownloadPath() { |
| 389 return last_download_path_; | 389 return last_download_path_; |
| 390 } | 390 } |
| 391 | 391 |
| 392 void DownloadManagerImpl::CreateDownloadItem( | 392 void DownloadManagerImpl::CreateDownloadItem( |
| 393 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) { | 393 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) { |
| 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 395 | 395 |
| 396 DownloadItem* download = new DownloadItemImpl( | 396 DownloadItem* download = new DownloadItemImpl( |
| 397 this, *info, new DownloadRequestHandle(request_handle), | 397 this, *info, new DownloadRequestHandle(request_handle), |
| 398 browser_context_->IsOffTheRecord()); | 398 browser_context_->IsOffTheRecord(), net::BoundNetLog()); |
| 399 int32 download_id = info->download_id.local(); | 399 int32 download_id = info->download_id.local(); |
| 400 DCHECK(!ContainsKey(in_progress_, download_id)); | 400 DCHECK(!ContainsKey(in_progress_, download_id)); |
| 401 | 401 |
| 402 CHECK_96627(!ContainsKey(active_downloads_, download_id)); | 402 CHECK_96627(!ContainsKey(active_downloads_, download_id)); |
| 403 downloads_.insert(download); | 403 downloads_.insert(download); |
| 404 active_downloads_[download_id] = download; | 404 active_downloads_[download_id] = download; |
| 405 } | 405 } |
| 406 | 406 |
| 407 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( | 407 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( |
| 408 const FilePath& main_file_path, | 408 const FilePath& main_file_path, |
| 409 const GURL& page_url, | 409 const GURL& page_url, |
| 410 bool is_otr, | 410 bool is_otr, |
| 411 DownloadItem::Observer* observer) { | 411 DownloadItem::Observer* observer) { |
| 412 DownloadItem* download = new DownloadItemImpl( | 412 DownloadItem* download = new DownloadItemImpl( |
| 413 this, main_file_path, page_url, is_otr, GetNextId()); | 413 this, main_file_path, page_url, is_otr, GetNextId(), net::BoundNetLog()); |
| 414 | 414 |
| 415 download->AddObserver(observer); | 415 download->AddObserver(observer); |
| 416 | 416 |
| 417 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); | 417 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); |
| 418 downloads_.insert(download); | 418 downloads_.insert(download); |
| 419 save_page_downloads_[download->GetId()] = download; | 419 save_page_downloads_[download->GetId()] = download; |
| 420 | 420 |
| 421 // Will notify the observer in the callback. | 421 // Will notify the observer in the callback. |
| 422 delegate_->AddItemToPersistentStore(download); | 422 delegate_->AddItemToPersistentStore(download); |
| 423 | 423 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 // The history service has retrieved all download entries. 'entries' contains | 908 // The history service has retrieved all download entries. 'entries' contains |
| 909 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). | 909 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). |
| 910 void DownloadManagerImpl::OnPersistentStoreQueryComplete( | 910 void DownloadManagerImpl::OnPersistentStoreQueryComplete( |
| 911 std::vector<DownloadPersistentStoreInfo>* entries) { | 911 std::vector<DownloadPersistentStoreInfo>* entries) { |
| 912 // TODO(rdsmith): Remove this and related logic when | 912 // TODO(rdsmith): Remove this and related logic when |
| 913 // http://crbug.com/96627 is fixed. | 913 // http://crbug.com/96627 is fixed. |
| 914 largest_db_handle_in_history_ = 0; | 914 largest_db_handle_in_history_ = 0; |
| 915 | 915 |
| 916 for (size_t i = 0; i < entries->size(); ++i) { | 916 for (size_t i = 0; i < entries->size(); ++i) { |
| 917 DownloadItem* download = new DownloadItemImpl( | 917 DownloadItem* download = new DownloadItemImpl( |
| 918 this, GetNextId(), entries->at(i)); | 918 this, GetNextId(), entries->at(i), net::BoundNetLog()); |
| 919 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle())); | 919 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle())); |
| 920 downloads_.insert(download); | 920 downloads_.insert(download); |
| 921 history_downloads_[download->GetDbHandle()] = download; | 921 history_downloads_[download->GetDbHandle()] = download; |
| 922 VLOG(20) << __FUNCTION__ << "()" << i << ">" | 922 VLOG(20) << __FUNCTION__ << "()" << i << ">" |
| 923 << " download = " << download->DebugString(true); | 923 << " download = " << download->DebugString(true); |
| 924 | 924 |
| 925 if (download->GetDbHandle() > largest_db_handle_in_history_) | 925 if (download->GetDbHandle() > largest_db_handle_in_history_) |
| 926 largest_db_handle_in_history_ = download->GetDbHandle(); | 926 largest_db_handle_in_history_ = download->GetDbHandle(); |
| 927 } | 927 } |
| 928 NotifyModelChanged(); | 928 NotifyModelChanged(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 it != history_downloads_.end(); ++it) { | 1166 it != history_downloads_.end(); ++it) { |
| 1167 if (it->second->IsComplete() && !it->second->GetOpened()) | 1167 if (it->second->IsComplete() && !it->second->GetOpened()) |
| 1168 ++num_unopened; | 1168 ++num_unopened; |
| 1169 } | 1169 } |
| 1170 download_stats::RecordOpensOutstanding(num_unopened); | 1170 download_stats::RecordOpensOutstanding(num_unopened); |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { | 1173 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { |
| 1174 file_manager_ = file_manager; | 1174 file_manager_ = file_manager; |
| 1175 } | 1175 } |
| OLD | NEW |