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.h" | 5 #include "content/browser/download/download_manager.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_impl.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" | 28 #include "content/browser/renderer_host/render_process_host.h" |
29 #include "content/browser/renderer_host/render_view_host.h" | 29 #include "content/browser/renderer_host/render_view_host.h" |
30 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 30 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
31 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/content_browser_client.h" | 33 #include "content/public/browser/content_browser_client.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } else { | 311 } else { |
312 // No prompting for download, just continue with the suggested name. | 312 // No prompting for download, just continue with the suggested name. |
313 ContinueDownloadWithPath(download, suggested_path); | 313 ContinueDownloadWithPath(download, suggested_path); |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 void DownloadManager::CreateDownloadItem( | 317 void DownloadManager::CreateDownloadItem( |
318 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) { | 318 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) { |
319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
320 | 320 |
321 DownloadItem* download = new DownloadItem( | 321 DownloadItem* download = new DownloadItemImpl( |
322 this, *info, new DownloadRequestHandle(request_handle), | 322 this, *info, new DownloadRequestHandle(request_handle), |
323 browser_context_->IsOffTheRecord()); | 323 browser_context_->IsOffTheRecord()); |
324 int32 download_id = info->download_id.local(); | 324 int32 download_id = info->download_id.local(); |
325 DCHECK(!ContainsKey(in_progress_, download_id)); | 325 DCHECK(!ContainsKey(in_progress_, download_id)); |
326 | 326 |
327 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved. | 327 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved. |
328 CHECK(!ContainsKey(active_downloads_, download_id)); | 328 CHECK(!ContainsKey(active_downloads_, download_id)); |
329 downloads_.insert(download); | 329 downloads_.insert(download); |
330 active_downloads_[download_id] = download; | 330 active_downloads_[download_id] = download; |
331 } | 331 } |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 | 812 |
813 // The history service has retrieved all download entries. 'entries' contains | 813 // The history service has retrieved all download entries. 'entries' contains |
814 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). | 814 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). |
815 void DownloadManager::OnPersistentStoreQueryComplete( | 815 void DownloadManager::OnPersistentStoreQueryComplete( |
816 std::vector<DownloadPersistentStoreInfo>* entries) { | 816 std::vector<DownloadPersistentStoreInfo>* entries) { |
817 // TODO(rdsmith): Remove this and related logic when | 817 // TODO(rdsmith): Remove this and related logic when |
818 // http://crbug.com/85408 is fixed. | 818 // http://crbug.com/85408 is fixed. |
819 largest_db_handle_in_history_ = 0; | 819 largest_db_handle_in_history_ = 0; |
820 | 820 |
821 for (size_t i = 0; i < entries->size(); ++i) { | 821 for (size_t i = 0; i < entries->size(); ++i) { |
822 DownloadItem* download = new DownloadItem(this, entries->at(i)); | 822 DownloadItem* download = new DownloadItemImpl(this, entries->at(i)); |
823 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved. | 823 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved. |
824 CHECK(!ContainsKey(history_downloads_, download->db_handle())); | 824 CHECK(!ContainsKey(history_downloads_, download->db_handle())); |
825 downloads_.insert(download); | 825 downloads_.insert(download); |
826 history_downloads_[download->db_handle()] = download; | 826 history_downloads_[download->db_handle()] = download; |
827 VLOG(20) << __FUNCTION__ << "()" << i << ">" | 827 VLOG(20) << __FUNCTION__ << "()" << i << ">" |
828 << " download = " << download->DebugString(true); | 828 << " download = " << download->DebugString(true); |
829 | 829 |
830 if (download->db_handle() > largest_db_handle_in_history_) | 830 if (download->db_handle() > largest_db_handle_in_history_) |
831 largest_db_handle_in_history_ = download->db_handle(); | 831 largest_db_handle_in_history_ = download->db_handle(); |
832 } | 832 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { | 1074 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { |
1075 delegate_->UpdateItemInPersistentStore(download); | 1075 delegate_->UpdateItemInPersistentStore(download); |
1076 int num_unopened = 0; | 1076 int num_unopened = 0; |
1077 for (DownloadMap::iterator it = history_downloads_.begin(); | 1077 for (DownloadMap::iterator it = history_downloads_.begin(); |
1078 it != history_downloads_.end(); ++it) { | 1078 it != history_downloads_.end(); ++it) { |
1079 if (it->second->IsComplete() && !it->second->opened()) | 1079 if (it->second->IsComplete() && !it->second->opened()) |
1080 ++num_unopened; | 1080 ++num_unopened; |
1081 } | 1081 } |
1082 download_stats::RecordOpensOutstanding(num_unopened); | 1082 download_stats::RecordOpensOutstanding(num_unopened); |
1083 } | 1083 } |
OLD | NEW |