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

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

Issue 10559036: Added URLRequestContext to constructor for URLRequest. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated unittests Created 8 years, 6 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
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 16 matching lines...) Expand all
27 #include "content/public/browser/browser_context.h" 27 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/download_interrupt_reasons.h" 30 #include "content/public/browser/download_interrupt_reasons.h"
31 #include "content/public/browser/download_manager_delegate.h" 31 #include "content/public/browser/download_manager_delegate.h"
32 #include "content/public/browser/download_persistent_store_info.h" 32 #include "content/public/browser/download_persistent_store_info.h"
33 #include "content/public/browser/download_url_parameters.h" 33 #include "content/public/browser/download_url_parameters.h"
34 #include "content/public/browser/notification_service.h" 34 #include "content/public/browser/notification_service.h"
35 #include "content/public/browser/notification_types.h" 35 #include "content/public/browser/notification_types.h"
36 #include "content/public/browser/render_process_host.h" 36 #include "content/public/browser/render_process_host.h"
37 #include "content/public/browser/resource_context.h"
37 #include "content/public/browser/web_contents_delegate.h" 38 #include "content/public/browser/web_contents_delegate.h"
38 #include "net/base/load_flags.h" 39 #include "net/base/load_flags.h"
39 #include "net/base/upload_data.h" 40 #include "net/base/upload_data.h"
40 #include "webkit/glue/webkit_glue.h" 41 #include "webkit/glue/webkit_glue.h"
41 42
42 using content::BrowserThread; 43 using content::BrowserThread;
43 using content::DownloadId; 44 using content::DownloadId;
44 using content::DownloadItem; 45 using content::DownloadItem;
45 using content::DownloadPersistentStoreInfo; 46 using content::DownloadPersistentStoreInfo;
46 using content::ResourceDispatcherHostImpl; 47 using content::ResourceDispatcherHostImpl;
47 using content::WebContents; 48 using content::WebContents;
48 49
49 namespace { 50 namespace {
50 51
51 void BeginDownload(content::DownloadUrlParameters* params) { 52 void BeginDownload(content::DownloadUrlParameters* params) {
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 content::ResourceDispatcherHostImpl* resource_dispatcher_host = 57 content::ResourceDispatcherHostImpl* resource_dispatcher_host =
57 static_cast<content::ResourceDispatcherHostImpl*>( 58 static_cast<content::ResourceDispatcherHostImpl*>(
58 params->resource_dispatcher_host()); 59 params->resource_dispatcher_host());
59 scoped_ptr<net::URLRequest> request(new net::URLRequest( 60 scoped_ptr<net::URLRequest> request(new net::URLRequest(
60 params->url(), resource_dispatcher_host)); 61 params->url(),
62 resource_dispatcher_host,
63 params->resource_context()->GetRequestContext()));
61 request->set_referrer(params->referrer().url.spec()); 64 request->set_referrer(params->referrer().url.spec());
62 webkit_glue::ConfigureURLRequestForReferrerPolicy( 65 webkit_glue::ConfigureURLRequestForReferrerPolicy(
63 request.get(), params->referrer().policy); 66 request.get(), params->referrer().policy);
64 request->set_load_flags(request->load_flags() | params->load_flags()); 67 request->set_load_flags(request->load_flags() | params->load_flags());
65 request->set_method(params->method()); 68 request->set_method(params->method());
66 if (!params->post_body().empty()) 69 if (!params->post_body().empty())
67 request->AppendBytesToUpload(params->post_body().data(), 70 request->AppendBytesToUpload(params->post_body().data(),
68 params->post_body().size()); 71 params->post_body().size());
69 if (params->post_id() >= 0) { 72 if (params->post_id() >= 0) {
70 // The POST in this case does not have an actual body, and only works 73 // The POST in this case does not have an actual body, and only works
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 if (delegate_) { 1151 if (delegate_) {
1149 delegate_->UpdatePathForItemInPersistentStore( 1152 delegate_->UpdatePathForItemInPersistentStore(
1150 download, download->GetFullPath()); 1153 download, download->GetFullPath());
1151 } 1154 }
1152 } 1155 }
1153 1156
1154 void DownloadManagerImpl::SetFileManagerForTesting( 1157 void DownloadManagerImpl::SetFileManagerForTesting(
1155 DownloadFileManager* file_manager) { 1158 DownloadFileManager* file_manager) {
1156 file_manager_ = file_manager; 1159 file_manager_ = file_manager;
1157 } 1160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698