| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 162 } |
| 163 | 163 |
| 164 class DownloadItemFactoryImpl : public DownloadItemFactory { | 164 class DownloadItemFactoryImpl : public DownloadItemFactory { |
| 165 public: | 165 public: |
| 166 DownloadItemFactoryImpl() {} | 166 DownloadItemFactoryImpl() {} |
| 167 virtual ~DownloadItemFactoryImpl() {} | 167 virtual ~DownloadItemFactoryImpl() {} |
| 168 | 168 |
| 169 virtual DownloadItemImpl* CreatePersistedItem( | 169 virtual DownloadItemImpl* CreatePersistedItem( |
| 170 DownloadItemImplDelegate* delegate, | 170 DownloadItemImplDelegate* delegate, |
| 171 DownloadId download_id, | 171 DownloadId download_id, |
| 172 const FilePath& path, | 172 const FilePath& current_path, |
| 173 const GURL& url, | 173 const FilePath& target_path, |
| 174 const std::vector<GURL>& url_chain, |
| 174 const GURL& referrer_url, | 175 const GURL& referrer_url, |
| 175 const base::Time& start_time, | 176 const base::Time& start_time, |
| 176 const base::Time& end_time, | 177 const base::Time& end_time, |
| 177 int64 received_bytes, | 178 int64 received_bytes, |
| 178 int64 total_bytes, | 179 int64 total_bytes, |
| 179 DownloadItem::DownloadState state, | 180 DownloadItem::DownloadState state, |
| 181 DownloadDangerType danger_type, |
| 182 DownloadInterruptReason interrupt_reason, |
| 180 bool opened, | 183 bool opened, |
| 181 const net::BoundNetLog& bound_net_log) OVERRIDE { | 184 const net::BoundNetLog& bound_net_log) OVERRIDE { |
| 182 return new DownloadItemImpl( | 185 return new DownloadItemImpl( |
| 183 delegate, | 186 delegate, |
| 184 download_id, | 187 download_id, |
| 185 path, | 188 current_path, |
| 186 url, | 189 target_path, |
| 190 url_chain, |
| 187 referrer_url, | 191 referrer_url, |
| 188 start_time, | 192 start_time, |
| 189 end_time, | 193 end_time, |
| 190 received_bytes, | 194 received_bytes, |
| 191 total_bytes, | 195 total_bytes, |
| 192 state, | 196 state, |
| 197 danger_type, |
| 198 interrupt_reason, |
| 193 opened, | 199 opened, |
| 194 bound_net_log); | 200 bound_net_log); |
| 195 } | 201 } |
| 196 | 202 |
| 197 virtual DownloadItemImpl* CreateActiveItem( | 203 virtual DownloadItemImpl* CreateActiveItem( |
| 198 DownloadItemImplDelegate* delegate, | 204 DownloadItemImplDelegate* delegate, |
| 199 const DownloadCreateInfo& info, | 205 const DownloadCreateInfo& info, |
| 200 const net::BoundNetLog& bound_net_log) OVERRIDE { | 206 const net::BoundNetLog& bound_net_log) OVERRIDE { |
| 201 return new DownloadItemImpl(delegate, info, bound_net_log); | 207 return new DownloadItemImpl(delegate, info, bound_net_log); |
| 202 } | 208 } |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 593 |
| 588 void DownloadManagerImpl::AddObserver(Observer* observer) { | 594 void DownloadManagerImpl::AddObserver(Observer* observer) { |
| 589 observers_.AddObserver(observer); | 595 observers_.AddObserver(observer); |
| 590 } | 596 } |
| 591 | 597 |
| 592 void DownloadManagerImpl::RemoveObserver(Observer* observer) { | 598 void DownloadManagerImpl::RemoveObserver(Observer* observer) { |
| 593 observers_.RemoveObserver(observer); | 599 observers_.RemoveObserver(observer); |
| 594 } | 600 } |
| 595 | 601 |
| 596 DownloadItem* DownloadManagerImpl::CreateDownloadItem( | 602 DownloadItem* DownloadManagerImpl::CreateDownloadItem( |
| 597 const FilePath& path, | 603 const FilePath& current_path, |
| 598 const GURL& url, | 604 const FilePath& target_path, |
| 605 const std::vector<GURL>& url_chain, |
| 599 const GURL& referrer_url, | 606 const GURL& referrer_url, |
| 600 const base::Time& start_time, | 607 const base::Time& start_time, |
| 601 const base::Time& end_time, | 608 const base::Time& end_time, |
| 602 int64 received_bytes, | 609 int64 received_bytes, |
| 603 int64 total_bytes, | 610 int64 total_bytes, |
| 604 DownloadItem::DownloadState state, | 611 DownloadItem::DownloadState state, |
| 612 DownloadDangerType danger_type, |
| 613 DownloadInterruptReason interrupt_reason, |
| 605 bool opened) { | 614 bool opened) { |
| 606 DownloadItemImpl* item = item_factory_->CreatePersistedItem( | 615 DownloadItemImpl* item = item_factory_->CreatePersistedItem( |
| 607 this, | 616 this, |
| 608 GetNextId(), | 617 GetNextId(), |
| 609 path, | 618 current_path, |
| 610 url, | 619 target_path, |
| 620 url_chain, |
| 611 referrer_url, | 621 referrer_url, |
| 612 start_time, | 622 start_time, |
| 613 end_time, | 623 end_time, |
| 614 received_bytes, | 624 received_bytes, |
| 615 total_bytes, | 625 total_bytes, |
| 616 state, | 626 state, |
| 627 danger_type, |
| 628 interrupt_reason, |
| 617 opened, | 629 opened, |
| 618 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); | 630 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); |
| 619 DCHECK(!ContainsKey(downloads_, item->GetId())); | 631 DCHECK(!ContainsKey(downloads_, item->GetId())); |
| 620 downloads_[item->GetId()] = item; | 632 downloads_[item->GetId()] = item; |
| 621 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); | 633 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); |
| 622 VLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); | 634 VLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); |
| 623 return item; | 635 return item; |
| 624 } | 636 } |
| 625 | 637 |
| 626 // TODO(asanka) Move into an observer. | 638 // TODO(asanka) Move into an observer. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 it != downloads_.end(); ++it) { | 677 it != downloads_.end(); ++it) { |
| 666 DownloadItemImpl* item = it->second; | 678 DownloadItemImpl* item = it->second; |
| 667 if (item->IsComplete() && | 679 if (item->IsComplete() && |
| 668 !item->GetOpened()) | 680 !item->GetOpened()) |
| 669 ++num_unopened; | 681 ++num_unopened; |
| 670 } | 682 } |
| 671 RecordOpensOutstanding(num_unopened); | 683 RecordOpensOutstanding(num_unopened); |
| 672 } | 684 } |
| 673 | 685 |
| 674 } // namespace content | 686 } // namespace content |
| OLD | NEW |