Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 10735089: DownloadManager::Observer::OnDownloadCreated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 523
524 net::BoundNetLog bound_net_log = 524 net::BoundNetLog bound_net_log =
525 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 525 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
526 if (!info->download_id.IsValid()) 526 if (!info->download_id.IsValid())
527 info->download_id = GetNextId(); 527 info->download_id = GetNextId();
528 DownloadItem* download = factory_->CreateActiveItem( 528 DownloadItem* download = factory_->CreateActiveItem(
529 this, *info, 529 this, *info,
530 scoped_ptr<DownloadRequestHandleInterface>( 530 scoped_ptr<DownloadRequestHandleInterface>(
531 new DownloadRequestHandle(info->request_handle)).Pass(), 531 new DownloadRequestHandle(info->request_handle)).Pass(),
532 browser_context_->IsOffTheRecord(), bound_net_log); 532 browser_context_->IsOffTheRecord(), bound_net_log);
533 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download));
533 534
534 DCHECK(!ContainsKey(downloads_, download->GetId())); 535 DCHECK(!ContainsKey(downloads_, download->GetId()));
535 downloads_[download->GetId()] = download; 536 downloads_[download->GetId()] = download;
536 DCHECK(!ContainsKey(active_downloads_, download->GetId())); 537 DCHECK(!ContainsKey(active_downloads_, download->GetId()));
537 active_downloads_[download->GetId()] = download; 538 active_downloads_[download->GetId()] = download;
538 539
539 return bound_net_log; 540 return bound_net_log;
540 } 541 }
541 542
542 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( 543 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem(
543 const FilePath& main_file_path, 544 const FilePath& main_file_path,
544 const GURL& page_url, 545 const GURL& page_url,
545 bool is_otr, 546 bool is_otr,
546 const std::string& mime_type, 547 const std::string& mime_type,
547 DownloadItem::Observer* observer) { 548 DownloadItem::Observer* observer) {
548 net::BoundNetLog bound_net_log = 549 net::BoundNetLog bound_net_log =
549 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 550 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
550 DownloadItem* download = factory_->CreateSavePageItem( 551 DownloadItem* download = factory_->CreateSavePageItem(
551 this, 552 this,
552 main_file_path, 553 main_file_path,
553 page_url, 554 page_url,
554 is_otr, 555 is_otr,
555 GetNextId(), 556 GetNextId(),
556 mime_type, 557 mime_type,
557 bound_net_log); 558 bound_net_log);
559 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download));
558 560
559 download->AddObserver(observer); 561 download->AddObserver(observer);
560 562
561 DCHECK(!ContainsKey(downloads_, download->GetId())); 563 DCHECK(!ContainsKey(downloads_, download->GetId()));
562 downloads_[download->GetId()] = download; 564 downloads_[download->GetId()] = download;
563 DCHECK(!SavePageExternalData::Get(download)); 565 DCHECK(!SavePageExternalData::Get(download));
564 new SavePageExternalData(download); 566 new SavePageExternalData(download);
565 DCHECK(SavePageExternalData::Get(download)); 567 DCHECK(SavePageExternalData::Get(download));
566 568
567 // Will notify the observer in the callback. 569 // Will notify the observer in the callback.
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 std::vector<DownloadPersistentStoreInfo>* entries) { 958 std::vector<DownloadPersistentStoreInfo>* entries) {
957 history_size_ = entries->size(); 959 history_size_ = entries->size();
958 for (size_t i = 0; i < entries->size(); ++i) { 960 for (size_t i = 0; i < entries->size(); ++i) {
959 int64 db_handle = entries->at(i).db_handle; 961 int64 db_handle = entries->at(i).db_handle;
960 base::debug::Alias(&db_handle); 962 base::debug::Alias(&db_handle);
961 963
962 net::BoundNetLog bound_net_log = 964 net::BoundNetLog bound_net_log =
963 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 965 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
964 DownloadItem* download = factory_->CreatePersistedItem( 966 DownloadItem* download = factory_->CreatePersistedItem(
965 this, GetNextId(), entries->at(i), bound_net_log); 967 this, GetNextId(), entries->at(i), bound_net_log);
968 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download));
Randy Smith (Not in Mondays) 2012/07/14 19:39:13 I'm a little uncomfortable with this, because the
benjhayden 2012/07/18 21:28:31 Discussed offline.
966 DCHECK(!ContainsKey(downloads_, download->GetId())); 969 DCHECK(!ContainsKey(downloads_, download->GetId()));
967 downloads_[download->GetId()] = download; 970 downloads_[download->GetId()] = download;
968 VLOG(20) << __FUNCTION__ << "()" << i << ">" 971 VLOG(20) << __FUNCTION__ << "()" << i << ">"
969 << " download = " << download->DebugString(true); 972 << " download = " << download->DebugString(true);
970 } 973 }
971 NotifyModelChanged(); 974 NotifyModelChanged();
972 CheckForHistoryFilesRemoval(); 975 CheckForHistoryFilesRemoval();
973 } 976 }
974 977
975 void DownloadManagerImpl::AddDownloadItemToHistory(DownloadItem* download, 978 void DownloadManagerImpl::AddDownloadItemToHistory(DownloadItem* download,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 void DownloadManagerImpl::DownloadRenamedToFinalName( 1189 void DownloadManagerImpl::DownloadRenamedToFinalName(
1187 DownloadItem* download) { 1190 DownloadItem* download) {
1188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1189 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1192 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1190 // receive the DownloadRenamedToFinalName() call. 1193 // receive the DownloadRenamedToFinalName() call.
1191 if (delegate_) { 1194 if (delegate_) {
1192 delegate_->UpdatePathForItemInPersistentStore( 1195 delegate_->UpdatePathForItemInPersistentStore(
1193 download, download->GetFullPath()); 1196 download, download->GetFullPath());
1194 } 1197 }
1195 } 1198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698