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 22 matching lines...) Expand all Loading... |
33 #include "content/public/browser/download_interrupt_reasons.h" | 33 #include "content/public/browser/download_interrupt_reasons.h" |
34 #include "content/public/browser/download_manager_delegate.h" | 34 #include "content/public/browser/download_manager_delegate.h" |
35 #include "content/public/browser/download_url_parameters.h" | 35 #include "content/public/browser/download_url_parameters.h" |
36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
38 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
39 #include "content/public/browser/resource_context.h" | 39 #include "content/public/browser/resource_context.h" |
40 #include "content/public/browser/web_contents_delegate.h" | 40 #include "content/public/browser/web_contents_delegate.h" |
41 #include "content/public/common/referrer.h" | 41 #include "content/public/common/referrer.h" |
42 #include "net/base/load_flags.h" | 42 #include "net/base/load_flags.h" |
| 43 #include "net/base/request_priority.h" |
43 #include "net/base/upload_bytes_element_reader.h" | 44 #include "net/base/upload_bytes_element_reader.h" |
44 #include "net/base/upload_data_stream.h" | 45 #include "net/base/upload_data_stream.h" |
45 #include "net/url_request/url_request_context.h" | 46 #include "net/url_request/url_request_context.h" |
46 | 47 |
47 namespace content { | 48 namespace content { |
48 namespace { | 49 namespace { |
49 | 50 |
50 void BeginDownload(scoped_ptr<DownloadUrlParameters> params, | 51 void BeginDownload(scoped_ptr<DownloadUrlParameters> params, |
51 uint32 download_id) { | 52 uint32 download_id) { |
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
53 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and | 54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and |
54 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so | 55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so |
55 // 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. |
56 scoped_ptr<net::URLRequest> request( | 57 scoped_ptr<net::URLRequest> request( |
57 params->resource_context()->GetRequestContext()->CreateRequest( | 58 params->resource_context()->GetRequestContext()->CreateRequest( |
58 params->url(), NULL)); | 59 params->url(), net::DEFAULT_PRIORITY, NULL)); |
59 request->set_load_flags(request->load_flags() | params->load_flags()); | 60 request->set_load_flags(request->load_flags() | params->load_flags()); |
60 request->set_method(params->method()); | 61 request->set_method(params->method()); |
61 if (!params->post_body().empty()) { | 62 if (!params->post_body().empty()) { |
62 const std::string& body = params->post_body(); | 63 const std::string& body = params->post_body(); |
63 scoped_ptr<net::UploadElementReader> reader( | 64 scoped_ptr<net::UploadElementReader> reader( |
64 net::UploadOwnedBytesElementReader::CreateWithString(body)); | 65 net::UploadOwnedBytesElementReader::CreateWithString(body)); |
65 request->set_upload(make_scoped_ptr( | 66 request->set_upload(make_scoped_ptr( |
66 net::UploadDataStream::CreateWithReader(reader.Pass(), 0))); | 67 net::UploadDataStream::CreateWithReader(reader.Pass(), 0))); |
67 } | 68 } |
68 if (params->post_id() >= 0) { | 69 if (params->post_id() >= 0) { |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 if (delegate_) | 714 if (delegate_) |
714 delegate_->OpenDownload(download); | 715 delegate_->OpenDownload(download); |
715 } | 716 } |
716 | 717 |
717 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 718 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
718 if (delegate_) | 719 if (delegate_) |
719 delegate_->ShowDownloadInShell(download); | 720 delegate_->ShowDownloadInShell(download); |
720 } | 721 } |
721 | 722 |
722 } // namespace content | 723 } // namespace content |
OLD | NEW |