Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 9369009: Make content::ResourceContext be a real interface like the rest of the Content API (i.e. don't ha... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 : render_process_id_(rpi), render_view_id_(rvi) {} 67 : render_process_id_(rpi), render_view_id_(rvi) {}
68 int render_process_id_; 68 int render_process_id_;
69 int render_view_id_; 69 int render_view_id_;
70 }; 70 };
71 71
72 void BeginDownload(const URLParams& url_params, 72 void BeginDownload(const URLParams& url_params,
73 bool prefer_cache, 73 bool prefer_cache,
74 const DownloadSaveInfo& save_info, 74 const DownloadSaveInfo& save_info,
75 ResourceDispatcherHost* resource_dispatcher_host, 75 ResourceDispatcherHost* resource_dispatcher_host,
76 const RenderParams& render_params, 76 const RenderParams& render_params,
77 const content::ResourceContext* context) { 77 content::ResourceContext* context) {
78 scoped_ptr<net::URLRequest> request( 78 scoped_ptr<net::URLRequest> request(
79 new net::URLRequest(url_params.url_, resource_dispatcher_host)); 79 new net::URLRequest(url_params.url_, resource_dispatcher_host));
80 request->set_referrer(url_params.referrer_.spec()); 80 request->set_referrer(url_params.referrer_.spec());
81 if (url_params.post_id_ >= 0) { 81 if (url_params.post_id_ >= 0) {
82 // The POST in this case does not have an actual body, and only works 82 // The POST in this case does not have an actual body, and only works
83 // when retrieving data from cache. This is done because we don't want 83 // when retrieving data from cache. This is done because we don't want
84 // to do a re-POST without user consent, and currently don't have a good 84 // to do a re-POST without user consent, and currently don't have a good
85 // plan on how to display the UI for that. 85 // plan on how to display the UI for that.
86 DCHECK(prefer_cache); 86 DCHECK(prefer_cache);
87 request->set_method("POST"); 87 request->set_method("POST");
88 scoped_refptr<net::UploadData> upload_data = new net::UploadData(); 88 scoped_refptr<net::UploadData> upload_data = new net::UploadData();
89 upload_data->set_identifier(url_params.post_id_); 89 upload_data->set_identifier(url_params.post_id_);
90 request->set_upload(upload_data); 90 request->set_upload(upload_data);
91 } 91 }
92 resource_dispatcher_host->BeginDownload( 92 resource_dispatcher_host->BeginDownload(
93 request.Pass(), prefer_cache, save_info, 93 request.Pass(), prefer_cache, save_info,
94 DownloadResourceHandler::OnStartedCallback(), 94 DownloadResourceHandler::OnStartedCallback(),
95 render_params.render_process_id_, 95 render_params.render_process_id_,
96 render_params.render_view_id_, 96 render_params.render_view_id_,
97 *context); 97 context);
98 } 98 }
99 99
100 class MapValueIteratorAdapter { 100 class MapValueIteratorAdapter {
101 public: 101 public:
102 explicit MapValueIteratorAdapter( 102 explicit MapValueIteratorAdapter(
103 base::hash_map<int64, DownloadItem*>::const_iterator iter) 103 base::hash_map<int64, DownloadItem*>::const_iterator iter)
104 : iter_(iter) { 104 : iter_(iter) {
105 } 105 }
106 ~MapValueIteratorAdapter() {} 106 ~MapValueIteratorAdapter() {}
107 107
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 BrowserThread::PostTask( 840 BrowserThread::PostTask(
841 BrowserThread::IO, FROM_HERE, 841 BrowserThread::IO, FROM_HERE,
842 base::Bind( 842 base::Bind(
843 &BeginDownload, 843 &BeginDownload,
844 URLParams(url, referrer, post_id), 844 URLParams(url, referrer, post_id),
845 prefer_cache, 845 prefer_cache,
846 save_info, 846 save_info,
847 resource_dispatcher_host, 847 resource_dispatcher_host,
848 RenderParams(web_contents->GetRenderProcessHost()->GetID(), 848 RenderParams(web_contents->GetRenderProcessHost()->GetID(),
849 web_contents->GetRenderViewHost()->routing_id()), 849 web_contents->GetRenderViewHost()->routing_id()),
850 &web_contents->GetBrowserContext()->GetResourceContext())); 850 web_contents->GetBrowserContext()->GetResourceContext()));
851 } 851 }
852 852
853 void DownloadManagerImpl::AddObserver(Observer* observer) { 853 void DownloadManagerImpl::AddObserver(Observer* observer) {
854 observers_.AddObserver(observer); 854 observers_.AddObserver(observer);
855 observer->ModelChanged(this); 855 observer->ModelChanged(this);
856 } 856 }
857 857
858 void DownloadManagerImpl::RemoveObserver(Observer* observer) { 858 void DownloadManagerImpl::RemoveObserver(Observer* observer) {
859 observers_.RemoveObserver(observer); 859 observers_.RemoveObserver(observer);
860 } 860 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 it != history_downloads_.end(); ++it) { 1169 it != history_downloads_.end(); ++it) {
1170 if (it->second->IsComplete() && !it->second->GetOpened()) 1170 if (it->second->IsComplete() && !it->second->GetOpened())
1171 ++num_unopened; 1171 ++num_unopened;
1172 } 1172 }
1173 download_stats::RecordOpensOutstanding(num_unopened); 1173 download_stats::RecordOpensOutstanding(num_unopened);
1174 } 1174 }
1175 1175
1176 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { 1176 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) {
1177 file_manager_ = file_manager; 1177 file_manager_ = file_manager;
1178 } 1178 }
OLDNEW
« no previous file with comments | « content/browser/appcache/chrome_appcache_service_unittest.cc ('k') | content/browser/download/save_file_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698