OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "content/browser/browser_context.h" | 19 #include "content/browser/browser_context.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_id_factory.h" | 22 #include "content/browser/download/download_id_factory.h" |
23 #include "content/browser/download/download_item.h" | 23 #include "content/browser/download/download_item.h" |
24 #include "content/browser/download/download_persistent_store_info.h" | 24 #include "content/browser/download/download_persistent_store_info.h" |
25 #include "content/browser/download/download_stats.h" | 25 #include "content/browser/download/download_stats.h" |
26 #include "content/browser/download/download_status_updater.h" | 26 #include "content/browser/download/download_status_updater.h" |
27 #include "content/browser/download/interrupt_reasons.h" | 27 #include "content/browser/download/interrupt_reasons.h" |
28 #include "content/browser/renderer_host/render_process_host.h" | |
29 #include "content/browser/renderer_host/render_view_host.h" | 28 #include "content/browser/renderer_host/render_view_host.h" |
30 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 29 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
31 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
32 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
34 #include "content/public/browser/download_manager_delegate.h" | 33 #include "content/public/browser/download_manager_delegate.h" |
35 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
| 36 #include "content/public/browser/render_process_host.h" |
37 | 37 |
38 using content::BrowserThread; | 38 using content::BrowserThread; |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 // Param structs exist because base::Bind can only handle 6 args. | 42 // Param structs exist because base::Bind can only handle 6 args. |
43 struct URLParams { | 43 struct URLParams { |
44 URLParams(const GURL& url, const GURL& referrer) | 44 URLParams(const GURL& url, const GURL& referrer) |
45 : url_(url), referrer_(referrer) {} | 45 : url_(url), referrer_(referrer) {} |
46 GURL url_; | 46 GURL url_; |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 DCHECK(tab_contents); | 723 DCHECK(tab_contents); |
724 ResourceDispatcherHost* resource_dispatcher_host = | 724 ResourceDispatcherHost* resource_dispatcher_host = |
725 content::GetContentClient()->browser()->GetResourceDispatcherHost(); | 725 content::GetContentClient()->browser()->GetResourceDispatcherHost(); |
726 // We send a pointer to content::ResourceContext, instead of the usual | 726 // We send a pointer to content::ResourceContext, instead of the usual |
727 // reference, so that a copy of the object isn't made. | 727 // reference, so that a copy of the object isn't made. |
728 // base::Bind can't handle 7 args, so we use URLParams and RenderParams. | 728 // base::Bind can't handle 7 args, so we use URLParams and RenderParams. |
729 BrowserThread::PostTask( | 729 BrowserThread::PostTask( |
730 BrowserThread::IO, FROM_HERE, | 730 BrowserThread::IO, FROM_HERE, |
731 base::Bind(&BeginDownload, | 731 base::Bind(&BeginDownload, |
732 URLParams(url, referrer), save_info, resource_dispatcher_host, | 732 URLParams(url, referrer), save_info, resource_dispatcher_host, |
733 RenderParams(tab_contents->GetRenderProcessHost()->id(), | 733 RenderParams(tab_contents->GetRenderProcessHost()->GetID(), |
734 tab_contents->render_view_host()->routing_id()), | 734 tab_contents->render_view_host()->routing_id()), |
735 &tab_contents->browser_context()->GetResourceContext())); | 735 &tab_contents->browser_context()->GetResourceContext())); |
736 } | 736 } |
737 | 737 |
738 void DownloadManagerImpl::AddObserver(Observer* observer) { | 738 void DownloadManagerImpl::AddObserver(Observer* observer) { |
739 observers_.AddObserver(observer); | 739 observers_.AddObserver(observer); |
740 observer->ModelChanged(); | 740 observer->ModelChanged(); |
741 } | 741 } |
742 | 742 |
743 void DownloadManagerImpl::RemoveObserver(Observer* observer) { | 743 void DownloadManagerImpl::RemoveObserver(Observer* observer) { |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 it != history_downloads_.end(); ++it) { | 1097 it != history_downloads_.end(); ++it) { |
1098 if (it->second->IsComplete() && !it->second->opened()) | 1098 if (it->second->IsComplete() && !it->second->opened()) |
1099 ++num_unopened; | 1099 ++num_unopened; |
1100 } | 1100 } |
1101 download_stats::RecordOpensOutstanding(num_unopened); | 1101 download_stats::RecordOpensOutstanding(num_unopened); |
1102 } | 1102 } |
1103 | 1103 |
1104 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { | 1104 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { |
1105 file_manager_ = file_manager; | 1105 file_manager_ = file_manager; |
1106 } | 1106 } |
OLD | NEW |