| 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" |
| 11 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "content/browser/download/download_create_info.h" | 20 #include "content/browser/download/download_create_info.h" |
| 21 #include "content/browser/download/download_file_manager.h" | 21 #include "content/browser/download/download_file_manager.h" |
| 22 #include "content/browser/download/download_item_impl.h" | 22 #include "content/browser/download/download_item_impl.h" |
| 23 #include "content/browser/download/download_persistent_store_info.h" | 23 #include "content/browser/download/download_persistent_store_info.h" |
| 24 #include "content/browser/download/download_stats.h" | 24 #include "content/browser/download/download_stats.h" |
| 25 #include "content/browser/download/interrupt_reasons.h" | |
| 26 #include "content/browser/renderer_host/render_view_host_impl.h" | 25 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 27 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 26 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 28 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
| 29 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
| 30 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
| 31 #include "content/public/browser/download_interrupt_reasons.h" |
| 32 #include "content/public/browser/download_manager_delegate.h" | 32 #include "content/public/browser/download_manager_delegate.h" |
| 33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
| 35 #include "content/public/browser/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
| 36 #include "content/public/browser/web_contents_delegate.h" | 36 #include "content/public/browser/web_contents_delegate.h" |
| 37 #include "net/base/upload_data.h" | 37 #include "net/base/upload_data.h" |
| 38 | 38 |
| 39 // TODO(benjhayden): Change this to DCHECK when we have more debugging | 39 // TODO(benjhayden): Change this to DCHECK when we have more debugging |
| 40 // information from the next dev cycle, before the next stable/beta branch is | 40 // information from the next dev cycle, before the next stable/beta branch is |
| 41 // cut, in order to prevent unnecessary crashes on those channels. If we still | 41 // cut, in order to prevent unnecessary crashes on those channels. If we still |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 | 679 |
| 680 RemoveFromActiveList(download); | 680 RemoveFromActiveList(download); |
| 681 // This function is called from the DownloadItem, so DI state | 681 // This function is called from the DownloadItem, so DI state |
| 682 // should already have been updated. | 682 // should already have been updated. |
| 683 AssertStateConsistent(download); | 683 AssertStateConsistent(download); |
| 684 | 684 |
| 685 if (file_manager_) | 685 if (file_manager_) |
| 686 download->OffThreadCancel(file_manager_); | 686 download->OffThreadCancel(file_manager_); |
| 687 } | 687 } |
| 688 | 688 |
| 689 void DownloadManagerImpl::OnDownloadInterrupted(int32 download_id, | 689 void DownloadManagerImpl::OnDownloadInterrupted( |
| 690 int64 size, | 690 int32 download_id, |
| 691 const std::string& hash_state, | 691 int64 size, |
| 692 InterruptReason reason) { | 692 const std::string& hash_state, |
| 693 content::DownloadInterruptReason reason) { |
| 693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 694 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 694 | 695 |
| 695 DownloadItem* download = GetActiveDownload(download_id); | 696 DownloadItem* download = GetActiveDownload(download_id); |
| 696 if (!download) | 697 if (!download) |
| 697 return; | 698 return; |
| 698 | 699 |
| 699 VLOG(20) << __FUNCTION__ << "()" | 700 VLOG(20) << __FUNCTION__ << "()" |
| 700 << " reason " << InterruptReasonDebugString(reason) | 701 << " reason " << InterruptReasonDebugString(reason) |
| 701 << " at offset " << download->GetReceivedBytes() | 702 << " at offset " << download->GetReceivedBytes() |
| 702 << " size = " << size | 703 << " size = " << size |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 it != history_downloads_.end(); ++it) { | 1160 it != history_downloads_.end(); ++it) { |
| 1160 if (it->second->IsComplete() && !it->second->GetOpened()) | 1161 if (it->second->IsComplete() && !it->second->GetOpened()) |
| 1161 ++num_unopened; | 1162 ++num_unopened; |
| 1162 } | 1163 } |
| 1163 download_stats::RecordOpensOutstanding(num_unopened); | 1164 download_stats::RecordOpensOutstanding(num_unopened); |
| 1164 } | 1165 } |
| 1165 | 1166 |
| 1166 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { | 1167 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { |
| 1167 file_manager_ = file_manager; | 1168 file_manager_ = file_manager; |
| 1168 } | 1169 } |
| OLD | NEW |