| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 53 DCHECK(BrowserThread::CurrentlyOn(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, NULL)); |
| 60 request->SetLoadFlags(request->load_flags() | params->load_flags()); | |
| 61 request->set_method(params->method()); | 60 request->set_method(params->method()); |
| 62 if (!params->post_body().empty()) { | 61 if (!params->post_body().empty()) { |
| 63 const std::string& body = params->post_body(); | 62 const std::string& body = params->post_body(); |
| 64 scoped_ptr<net::UploadElementReader> reader( | 63 scoped_ptr<net::UploadElementReader> reader( |
| 65 net::UploadOwnedBytesElementReader::CreateWithString(body)); | 64 net::UploadOwnedBytesElementReader::CreateWithString(body)); |
| 66 request->set_upload( | 65 request->set_upload( |
| 67 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); | 66 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); |
| 68 } | 67 } |
| 69 if (params->post_id() >= 0) { | 68 if (params->post_id() >= 0) { |
| 70 // 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 save_info->file = params->GetFile(); | 121 save_info->file = params->GetFile(); |
| 123 | 122 |
| 124 ResourceDispatcherHost::Get()->BeginDownload( | 123 ResourceDispatcherHost::Get()->BeginDownload( |
| 125 request.Pass(), | 124 request.Pass(), |
| 126 params->referrer(), | 125 params->referrer(), |
| 127 params->content_initiated(), | 126 params->content_initiated(), |
| 128 params->resource_context(), | 127 params->resource_context(), |
| 129 params->render_process_host_id(), | 128 params->render_process_host_id(), |
| 130 params->render_view_host_routing_id(), | 129 params->render_view_host_routing_id(), |
| 131 params->prefer_cache(), | 130 params->prefer_cache(), |
| 131 params->do_not_prompt_for_login(), |
| 132 save_info.Pass(), | 132 save_info.Pass(), |
| 133 download_id, | 133 download_id, |
| 134 params->callback()); | 134 params->callback()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 class MapValueIteratorAdapter { | 137 class MapValueIteratorAdapter { |
| 138 public: | 138 public: |
| 139 explicit MapValueIteratorAdapter( | 139 explicit MapValueIteratorAdapter( |
| 140 base::hash_map<int64, DownloadItem*>::const_iterator iter) | 140 base::hash_map<int64, DownloadItem*>::const_iterator iter) |
| 141 : iter_(iter) { | 141 : iter_(iter) { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 if (delegate_) | 717 if (delegate_) |
| 718 delegate_->OpenDownload(download); | 718 delegate_->OpenDownload(download); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 721 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
| 722 if (delegate_) | 722 if (delegate_) |
| 723 delegate_->ShowDownloadInShell(download); | 723 delegate_->ShowDownloadInShell(download); |
| 724 } | 724 } |
| 725 | 725 |
| 726 } // namespace content | 726 } // namespace content |
| OLD | NEW |