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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "content/public/browser/resource_context.h" | 44 #include "content/public/browser/resource_context.h" |
45 #include "content/public/browser/web_contents_delegate.h" | 45 #include "content/public/browser/web_contents_delegate.h" |
46 #include "content/public/common/previews_state.h" | 46 #include "content/public/common/previews_state.h" |
47 #include "content/public/common/referrer.h" | 47 #include "content/public/common/referrer.h" |
48 #include "net/base/elements_upload_data_stream.h" | 48 #include "net/base/elements_upload_data_stream.h" |
49 #include "net/base/load_flags.h" | 49 #include "net/base/load_flags.h" |
50 #include "net/base/request_priority.h" | 50 #include "net/base/request_priority.h" |
51 #include "net/base/upload_bytes_element_reader.h" | 51 #include "net/base/upload_bytes_element_reader.h" |
52 #include "net/log/net_log_source_type.h" | 52 #include "net/log/net_log_source_type.h" |
53 #include "net/log/net_log_with_source.h" | 53 #include "net/log/net_log_with_source.h" |
| 54 #include "net/traffic_annotation/network_traffic_annotation.h" |
54 #include "net/url_request/url_request_context.h" | 55 #include "net/url_request/url_request_context.h" |
55 #include "storage/browser/blob/blob_url_request_job_factory.h" | 56 #include "storage/browser/blob/blob_url_request_job_factory.h" |
56 #include "url/origin.h" | 57 #include "url/origin.h" |
57 | 58 |
58 namespace content { | 59 namespace content { |
59 namespace { | 60 namespace { |
60 | 61 |
61 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> BeginDownload( | 62 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> BeginDownload( |
62 std::unique_ptr<DownloadUrlParameters> params, | 63 std::unique_ptr<DownloadUrlParameters> params, |
63 content::ResourceContext* resource_context, | 64 content::ResourceContext* resource_context, |
64 uint32_t download_id, | 65 uint32_t download_id, |
65 base::WeakPtr<DownloadManagerImpl> download_manager) { | 66 base::WeakPtr<DownloadManagerImpl> download_manager) { |
66 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
67 | 68 |
68 std::unique_ptr<net::URLRequest> url_request = | 69 std::unique_ptr<net::URLRequest> url_request = |
69 DownloadRequestCore::CreateRequestOnIOThread(download_id, params.get()); | 70 DownloadRequestCore::CreateRequestOnIOThread(download_id, params.get(), |
| 71 NO_TRAFFIC_ANNOTATION_YET); |
70 std::unique_ptr<storage::BlobDataHandle> blob_data_handle = | 72 std::unique_ptr<storage::BlobDataHandle> blob_data_handle = |
71 params->GetBlobDataHandle(); | 73 params->GetBlobDataHandle(); |
72 if (blob_data_handle) { | 74 if (blob_data_handle) { |
73 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 75 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
74 url_request.get(), std::move(blob_data_handle)); | 76 url_request.get(), std::move(blob_data_handle)); |
75 } | 77 } |
76 | 78 |
77 // If there's a valid renderer process associated with the request, then the | 79 // If there's a valid renderer process associated with the request, then the |
78 // request should be driven by the ResourceLoader. Pass it over to the | 80 // request should be driven by the ResourceLoader. Pass it over to the |
79 // ResourceDispatcherHostImpl which will in turn pass it along to the | 81 // ResourceDispatcherHostImpl which will in turn pass it along to the |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 download->GetStartTime() >= remove_begin && | 601 download->GetStartTime() >= remove_begin && |
600 (remove_end.is_null() || download->GetStartTime() < remove_end)) { | 602 (remove_end.is_null() || download->GetStartTime() < remove_end)) { |
601 download->Remove(); | 603 download->Remove(); |
602 count++; | 604 count++; |
603 } | 605 } |
604 } | 606 } |
605 return count; | 607 return count; |
606 } | 608 } |
607 | 609 |
608 void DownloadManagerImpl::DownloadUrl( | 610 void DownloadManagerImpl::DownloadUrl( |
609 std::unique_ptr<DownloadUrlParameters> params) { | 611 std::unique_ptr<DownloadUrlParameters> params, |
| 612 const net::NetworkTrafficAnnotationTag& traffic_annotation) { |
610 if (params->post_id() >= 0) { | 613 if (params->post_id() >= 0) { |
611 // Check this here so that the traceback is more useful. | 614 // Check this here so that the traceback is more useful. |
612 DCHECK(params->prefer_cache()); | 615 DCHECK(params->prefer_cache()); |
613 DCHECK_EQ("POST", params->method()); | 616 DCHECK_EQ("POST", params->method()); |
614 } | 617 } |
615 BrowserThread::PostTaskAndReplyWithResult( | 618 BrowserThread::PostTaskAndReplyWithResult( |
616 BrowserThread::IO, FROM_HERE, | 619 BrowserThread::IO, FROM_HERE, |
617 base::Bind(&BeginDownload, base::Passed(¶ms), | 620 base::Bind(&BeginDownload, base::Passed(¶ms), |
618 browser_context_->GetResourceContext(), | 621 browser_context_->GetResourceContext(), |
619 content::DownloadItem::kInvalidId, weak_factory_.GetWeakPtr()), | 622 content::DownloadItem::kInvalidId, weak_factory_.GetWeakPtr()), |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 if (delegate_) | 762 if (delegate_) |
760 delegate_->OpenDownload(download); | 763 delegate_->OpenDownload(download); |
761 } | 764 } |
762 | 765 |
763 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 766 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
764 if (delegate_) | 767 if (delegate_) |
765 delegate_->ShowDownloadInShell(download); | 768 delegate_->ShowDownloadInShell(download); |
766 } | 769 } |
767 | 770 |
768 } // namespace content | 771 } // namespace content |
OLD | NEW |