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

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: Merged with latest version 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 17 matching lines...) Expand all
28 #include "content/public/browser/browser_context.h" 28 #include "content/public/browser/browser_context.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/content_browser_client.h" 30 #include "content/public/browser/content_browser_client.h"
31 #include "content/public/browser/download_interrupt_reasons.h" 31 #include "content/public/browser/download_interrupt_reasons.h"
32 #include "content/public/browser/download_manager_delegate.h" 32 #include "content/public/browser/download_manager_delegate.h"
33 #include "content/public/browser/download_persistent_store_info.h" 33 #include "content/public/browser/download_persistent_store_info.h"
34 #include "content/public/browser/download_url_parameters.h" 34 #include "content/public/browser/download_url_parameters.h"
35 #include "content/public/browser/notification_service.h" 35 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/notification_types.h" 36 #include "content/public/browser/notification_types.h"
37 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
38 #include "content/public/browser/resource_context.h"
38 #include "content/public/browser/web_contents_delegate.h" 39 #include "content/public/browser/web_contents_delegate.h"
39 #include "net/base/load_flags.h" 40 #include "net/base/load_flags.h"
40 #include "net/base/upload_data.h" 41 #include "net/base/upload_data.h"
41 #include "webkit/glue/webkit_glue.h" 42 #include "webkit/glue/webkit_glue.h"
42 43
43 using content::BrowserThread; 44 using content::BrowserThread;
44 using content::DownloadId; 45 using content::DownloadId;
45 using content::DownloadItem; 46 using content::DownloadItem;
46 using content::DownloadPersistentStoreInfo; 47 using content::DownloadPersistentStoreInfo;
47 using content::ResourceDispatcherHostImpl; 48 using content::ResourceDispatcherHostImpl;
48 using content::WebContents; 49 using content::WebContents;
49 50
50 namespace { 51 namespace {
51 52
52 void BeginDownload(content::DownloadUrlParameters* params) { 53 void BeginDownload(content::DownloadUrlParameters* params) {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and 55 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and
55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so 56 // 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. 57 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4.
57 scoped_ptr<net::URLRequest> request(new net::URLRequest( 58 scoped_ptr<net::URLRequest> request(new net::URLRequest(
58 params->url(), NULL)); 59 params->url(),
60 NULL,
61 params->resource_context()->GetRequestContext()));
59 request->set_referrer(params->referrer().url.spec()); 62 request->set_referrer(params->referrer().url.spec());
60 webkit_glue::ConfigureURLRequestForReferrerPolicy( 63 webkit_glue::ConfigureURLRequestForReferrerPolicy(
61 request.get(), params->referrer().policy); 64 request.get(), params->referrer().policy);
62 request->set_load_flags(request->load_flags() | params->load_flags()); 65 request->set_load_flags(request->load_flags() | params->load_flags());
63 request->set_method(params->method()); 66 request->set_method(params->method());
64 if (!params->post_body().empty()) 67 if (!params->post_body().empty())
65 request->AppendBytesToUpload(params->post_body().data(), 68 request->AppendBytesToUpload(params->post_body().data(),
66 params->post_body().size()); 69 params->post_body().size());
67 if (params->post_id() >= 0) { 70 if (params->post_id() >= 0) {
68 // The POST in this case does not have an actual body, and only works 71 // The POST in this case does not have an actual body, and only works
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 void DownloadManagerImpl::DownloadRenamedToFinalName( 1219 void DownloadManagerImpl::DownloadRenamedToFinalName(
1217 DownloadItem* download) { 1220 DownloadItem* download) {
1218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1219 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1222 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1220 // receive the DownloadRenamedToFinalName() call. 1223 // receive the DownloadRenamedToFinalName() call.
1221 if (delegate_) { 1224 if (delegate_) {
1222 delegate_->UpdatePathForItemInPersistentStore( 1225 delegate_->UpdatePathForItemInPersistentStore(
1223 download, download->GetFullPath()); 1226 download, download->GetFullPath());
1224 } 1227 }
1225 } 1228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698