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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 namespace { | 49 namespace { |
50 | 50 |
51 void BeginDownload(scoped_ptr<DownloadUrlParameters> params, | 51 void BeginDownload(scoped_ptr<DownloadUrlParameters> params, |
52 uint32 download_id) { | 52 uint32 download_id) { |
53 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 53 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and | 54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and |
55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so | 55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so |
56 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. | 56 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. |
57 scoped_ptr<net::URLRequest> request( | 57 scoped_ptr<net::URLRequest> request( |
58 params->resource_context()->GetRequestContext()->CreateRequest( | 58 params->resource_context()->GetRequestContext()->CreateRequest( |
59 params->url(), net::DEFAULT_PRIORITY, NULL, NULL)); | 59 params->url(), net::DEFAULT_PRIORITY, NULL)); |
60 request->set_method(params->method()); | 60 request->set_method(params->method()); |
61 if (!params->post_body().empty()) { | 61 if (!params->post_body().empty()) { |
62 const std::string& body = params->post_body(); | 62 const std::string& body = params->post_body(); |
63 scoped_ptr<net::UploadElementReader> reader( | 63 scoped_ptr<net::UploadElementReader> reader( |
64 net::UploadOwnedBytesElementReader::CreateWithString(body)); | 64 net::UploadOwnedBytesElementReader::CreateWithString(body)); |
65 request->set_upload( | 65 request->set_upload( |
66 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); | 66 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); |
67 } | 67 } |
68 if (params->post_id() >= 0) { | 68 if (params->post_id() >= 0) { |
69 // The POST in this case does not have an actual body, and only works | 69 // The POST in this case does not have an actual body, and only works |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 if (delegate_) | 716 if (delegate_) |
717 delegate_->OpenDownload(download); | 717 delegate_->OpenDownload(download); |
718 } | 718 } |
719 | 719 |
720 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 720 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
721 if (delegate_) | 721 if (delegate_) |
722 delegate_->ShowDownloadInShell(download); | 722 delegate_->ShowDownloadInShell(download); |
723 } | 723 } |
724 | 724 |
725 } // namespace content | 725 } // namespace content |
OLD | NEW |