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

Side by Side Diff: chrome/browser/download/download_extension_api.cc

Issue 9150028: Cleanup: ResourceDispatcherHost::BeginDownload takes a scoped_ptr<URLRequest> argument. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/process_unique_id/child_id/ Created 8 years, 11 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
« no previous file with comments | « no previous file | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/download/download_extension_api.h" 5 #include "chrome/browser/download/download_extension_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return true; 249 return true;
250 } 250 }
251 251
252 void DownloadsDownloadFunction::BeginDownloadOnIOThread() { 252 void DownloadsDownloadFunction::BeginDownloadOnIOThread() {
253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
254 DVLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); 254 DVLOG(1) << __FUNCTION__ << " " << iodata_->url.spec();
255 DownloadSaveInfo save_info; 255 DownloadSaveInfo save_info;
256 // TODO(benjhayden) Ensure that this filename is interpreted as a path 256 // TODO(benjhayden) Ensure that this filename is interpreted as a path
257 // relative to the default downloads directory without allowing '..'. 257 // relative to the default downloads directory without allowing '..'.
258 save_info.suggested_name = iodata_->filename; 258 save_info.suggested_name = iodata_->filename;
259 net::URLRequest* request = new net::URLRequest(iodata_->url, iodata_->rdh); 259 scoped_ptr<net::URLRequest> request(
260 new net::URLRequest(iodata_->url, iodata_->rdh));
260 request->set_method(iodata_->method); 261 request->set_method(iodata_->method);
261 if (iodata_->extra_headers != NULL) { 262 if (iodata_->extra_headers != NULL) {
262 for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) { 263 for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) {
263 base::DictionaryValue* header = NULL; 264 base::DictionaryValue* header = NULL;
264 std::string name, value; 265 std::string name, value;
265 CHECK(iodata_->extra_headers->GetDictionary(index, &header)); 266 CHECK(iodata_->extra_headers->GetDictionary(index, &header));
266 CHECK(header->GetString("name", &name)); 267 CHECK(header->GetString("name", &name));
267 CHECK(header->GetString("value", &value)); 268 CHECK(header->GetString("value", &value));
268 request->SetExtraRequestHeaderByName(name, value, false/*overwrite*/); 269 request->SetExtraRequestHeaderByName(name, value, false/*overwrite*/);
269 } 270 }
270 } 271 }
271 if (!iodata_->post_body.empty()) { 272 if (!iodata_->post_body.empty()) {
272 request->AppendBytesToUpload(iodata_->post_body.data(), 273 request->AppendBytesToUpload(iodata_->post_body.data(),
273 iodata_->post_body.size()); 274 iodata_->post_body.size());
274 } 275 }
275 iodata_->rdh->BeginDownload( 276 iodata_->rdh->BeginDownload(
276 request, 277 request.Pass(),
277 save_info, 278 save_info,
278 iodata_->save_as, 279 iodata_->save_as,
279 base::Bind(&DownloadsDownloadFunction::OnStarted, this), 280 base::Bind(&DownloadsDownloadFunction::OnStarted, this),
280 iodata_->render_process_host_id, 281 iodata_->render_process_host_id,
281 iodata_->render_view_host_routing_id, 282 iodata_->render_view_host_routing_id,
282 *(iodata_->resource_context)); 283 *(iodata_->resource_context));
283 iodata_.reset(); 284 iodata_.reset();
284 } 285 }
285 286
286 void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { 287 void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 ListValue args; 728 ListValue args;
728 args.Append(arg); 729 args.Append(arg);
729 std::string json_args; 730 std::string json_args;
730 base::JSONWriter::Write(&args, false, &json_args); 731 base::JSONWriter::Write(&args, false, &json_args);
731 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 732 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
732 event_name, 733 event_name,
733 json_args, 734 json_args,
734 profile_, 735 profile_,
735 GURL()); 736 GURL());
736 } 737 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698