Chromium Code Reviews| 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 DownloadItemImpl* download = factory_->CreateActiveItem( | 527 DownloadItemImpl* download = factory_->CreateActiveItem( |
| 528 this, *info, | 528 this, *info, |
| 529 scoped_ptr<DownloadRequestHandleInterface>( | 529 scoped_ptr<DownloadRequestHandleInterface>( |
| 530 new DownloadRequestHandle(info->request_handle)).Pass(), | 530 new DownloadRequestHandle(info->request_handle)).Pass(), |
| 531 browser_context_->IsOffTheRecord(), bound_net_log); | 531 browser_context_->IsOffTheRecord(), bound_net_log); |
| 532 | 532 |
| 533 DCHECK(!ContainsKey(downloads_, download->GetId())); | 533 DCHECK(!ContainsKey(downloads_, download->GetId())); |
| 534 downloads_[download->GetId()] = download; | 534 downloads_[download->GetId()] = download; |
| 535 DCHECK(!ContainsKey(active_downloads_, download->GetId())); | 535 DCHECK(!ContainsKey(active_downloads_, download->GetId())); |
| 536 active_downloads_[download->GetId()] = download; | 536 active_downloads_[download->GetId()] = download; |
| 537 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download)); | |
| 537 | 538 |
| 538 return bound_net_log; | 539 return bound_net_log; |
| 539 } | 540 } |
| 540 | 541 |
| 541 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem( | 542 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem( |
| 542 const FilePath& main_file_path, | 543 const FilePath& main_file_path, |
| 543 const GURL& page_url, | 544 const GURL& page_url, |
| 544 bool is_otr, | 545 bool is_otr, |
| 545 const std::string& mime_type, | 546 const std::string& mime_type, |
| 546 DownloadItem::Observer* observer) { | 547 DownloadItem::Observer* observer) { |
| 547 net::BoundNetLog bound_net_log = | 548 net::BoundNetLog bound_net_log = |
| 548 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); | 549 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); |
| 549 DownloadItemImpl* download = factory_->CreateSavePageItem( | 550 DownloadItemImpl* download = factory_->CreateSavePageItem( |
| 550 this, | 551 this, |
| 551 main_file_path, | 552 main_file_path, |
| 552 page_url, | 553 page_url, |
| 553 is_otr, | 554 is_otr, |
| 554 GetNextId(), | 555 GetNextId(), |
| 555 mime_type, | 556 mime_type, |
| 556 bound_net_log); | 557 bound_net_log); |
| 557 | 558 |
| 558 download->AddObserver(observer); | 559 download->AddObserver(observer); |
| 559 | 560 |
| 560 DCHECK(!ContainsKey(downloads_, download->GetId())); | 561 DCHECK(!ContainsKey(downloads_, download->GetId())); |
| 561 downloads_[download->GetId()] = download; | 562 downloads_[download->GetId()] = download; |
| 562 DCHECK(!SavePageExternalData::Get(download)); | 563 DCHECK(!SavePageExternalData::Get(download)); |
| 563 new SavePageExternalData(download); | 564 new SavePageExternalData(download); |
| 564 DCHECK(SavePageExternalData::Get(download)); | 565 DCHECK(SavePageExternalData::Get(download)); |
| 565 | 566 |
|
Randy Smith (Not in Mondays)
2012/07/19 17:25:36
small nit: It seems like whether or not there's ve
benjhayden
2012/07/23 15:58:42
I think that whitespace is more context-dependent
| |
| 567 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download)); | |
| 568 | |
| 566 // Will notify the observer in the callback. | 569 // Will notify the observer in the callback. |
| 567 if (delegate_) | 570 if (delegate_) |
| 568 delegate_->AddItemToPersistentStore(download); | 571 delegate_->AddItemToPersistentStore(download); |
| 569 | 572 |
| 570 return download; | 573 return download; |
| 571 } | 574 } |
| 572 | 575 |
| 573 // The target path for the download item is now valid. We proceed with the | 576 // The target path for the download item is now valid. We proceed with the |
| 574 // determination of an intermediate path. | 577 // determination of an intermediate path. |
| 575 void DownloadManagerImpl::OnTargetPathAvailable(DownloadItemImpl* download) { | 578 void DownloadManagerImpl::OnTargetPathAvailable(DownloadItemImpl* download) { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 for (size_t i = 0; i < entries->size(); ++i) { | 943 for (size_t i = 0; i < entries->size(); ++i) { |
| 941 int64 db_handle = entries->at(i).db_handle; | 944 int64 db_handle = entries->at(i).db_handle; |
| 942 base::debug::Alias(&db_handle); | 945 base::debug::Alias(&db_handle); |
| 943 | 946 |
| 944 net::BoundNetLog bound_net_log = | 947 net::BoundNetLog bound_net_log = |
| 945 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); | 948 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); |
| 946 DownloadItemImpl* download = factory_->CreatePersistedItem( | 949 DownloadItemImpl* download = factory_->CreatePersistedItem( |
| 947 this, GetNextId(), entries->at(i), bound_net_log); | 950 this, GetNextId(), entries->at(i), bound_net_log); |
| 948 DCHECK(!ContainsKey(downloads_, download->GetId())); | 951 DCHECK(!ContainsKey(downloads_, download->GetId())); |
| 949 downloads_[download->GetId()] = download; | 952 downloads_[download->GetId()] = download; |
| 953 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download)); | |
| 950 VLOG(20) << __FUNCTION__ << "()" << i << ">" | 954 VLOG(20) << __FUNCTION__ << "()" << i << ">" |
| 951 << " download = " << download->DebugString(true); | 955 << " download = " << download->DebugString(true); |
| 952 } | 956 } |
| 953 NotifyModelChanged(); | 957 NotifyModelChanged(); |
| 954 CheckForHistoryFilesRemoval(); | 958 CheckForHistoryFilesRemoval(); |
| 955 } | 959 } |
| 956 | 960 |
| 957 void DownloadManagerImpl::AddDownloadItemToHistory(DownloadItemImpl* download, | 961 void DownloadManagerImpl::AddDownloadItemToHistory(DownloadItemImpl* download, |
| 958 int64 db_handle) { | 962 int64 db_handle) { |
| 959 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 963 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1169 void DownloadManagerImpl::DownloadRenamedToFinalName( | 1173 void DownloadManagerImpl::DownloadRenamedToFinalName( |
| 1170 DownloadItemImpl* download) { | 1174 DownloadItemImpl* download) { |
| 1171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1172 // If the rename failed, we receive an OnDownloadInterrupted() call before we | 1176 // If the rename failed, we receive an OnDownloadInterrupted() call before we |
| 1173 // receive the DownloadRenamedToFinalName() call. | 1177 // receive the DownloadRenamedToFinalName() call. |
| 1174 if (delegate_) { | 1178 if (delegate_) { |
| 1175 delegate_->UpdatePathForItemInPersistentStore( | 1179 delegate_->UpdatePathForItemInPersistentStore( |
| 1176 download, download->GetFullPath()); | 1180 download, download->GetFullPath()); |
| 1177 } | 1181 } |
| 1178 } | 1182 } |
| OLD | NEW |