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

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

Issue 11028131: Shift passage of FileStream in downloads system to be by scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed blank line. Created 8 years, 2 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 virtual ~SavePageData() {} 68 virtual ~SavePageData() {}
69 69
70 private: 70 private:
71 static const char kKey[]; 71 static const char kKey[];
72 72
73 DISALLOW_COPY_AND_ASSIGN(SavePageData); 73 DISALLOW_COPY_AND_ASSIGN(SavePageData);
74 }; 74 };
75 75
76 const char SavePageData::kKey[] = "DownloadItem SavePageData"; 76 const char SavePageData::kKey[] = "DownloadItem SavePageData";
77 77
78 void BeginDownload(content::DownloadUrlParameters* params) { 78 void BeginDownload(scoped_ptr<content::DownloadUrlParameters> params) {
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
80 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and 80 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and
81 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so 81 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so
82 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. 82 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4.
83 scoped_ptr<net::URLRequest> request( 83 scoped_ptr<net::URLRequest> request(
84 params->resource_context()->GetRequestContext()->CreateRequest( 84 params->resource_context()->GetRequestContext()->CreateRequest(
85 params->url(), NULL)); 85 params->url(), NULL));
86 request->set_referrer(params->referrer().url.spec()); 86 request->set_referrer(params->referrer().url.spec());
87 webkit_glue::ConfigureURLRequestForReferrerPolicy( 87 webkit_glue::ConfigureURLRequestForReferrerPolicy(
88 request.get(), params->referrer().policy); 88 request.get(), params->referrer().policy);
(...skipping 20 matching lines...) Expand all
109 request->SetExtraRequestHeaderByName( 109 request->SetExtraRequestHeaderByName(
110 iter->first, iter->second, false/*overwrite*/); 110 iter->first, iter->second, false/*overwrite*/);
111 } 111 }
112 params->resource_dispatcher_host()->BeginDownload( 112 params->resource_dispatcher_host()->BeginDownload(
113 request.Pass(), 113 request.Pass(),
114 params->content_initiated(), 114 params->content_initiated(),
115 params->resource_context(), 115 params->resource_context(),
116 params->render_process_host_id(), 116 params->render_process_host_id(),
117 params->render_view_host_routing_id(), 117 params->render_view_host_routing_id(),
118 params->prefer_cache(), 118 params->prefer_cache(),
119 params->save_info(), 119 params->GetSaveInfo(), // Nulls params internal copy.
benjhayden 2012/10/11 19:41:12 This comment belongs in d_u_p.h, not here. |params
Randy Smith (Not in Mondays) 2012/10/15 18:56:32 Ok, but it is already there, and that behavior mig
120 params->callback()); 120 params->callback());
121 } 121 }
122 122
123 class MapValueIteratorAdapter { 123 class MapValueIteratorAdapter {
124 public: 124 public:
125 explicit MapValueIteratorAdapter( 125 explicit MapValueIteratorAdapter(
126 base::hash_map<int64, DownloadItem*>::const_iterator iter) 126 base::hash_map<int64, DownloadItem*>::const_iterator iter)
127 : iter_(iter) { 127 : iter_(iter) {
128 } 128 }
129 ~MapValueIteratorAdapter() {} 129 ~MapValueIteratorAdapter() {}
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 785 }
786 786
787 void DownloadManagerImpl::DownloadUrl( 787 void DownloadManagerImpl::DownloadUrl(
788 scoped_ptr<content::DownloadUrlParameters> params) { 788 scoped_ptr<content::DownloadUrlParameters> params) {
789 if (params->post_id() >= 0) { 789 if (params->post_id() >= 0) {
790 // Check this here so that the traceback is more useful. 790 // Check this here so that the traceback is more useful.
791 DCHECK(params->prefer_cache()); 791 DCHECK(params->prefer_cache());
792 DCHECK(params->method() == "POST"); 792 DCHECK(params->method() == "POST");
793 } 793 }
794 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( 794 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(
795 &BeginDownload, base::Owned(params.release()))); 795 &BeginDownload, base::Passed(params.Pass())));
796 } 796 }
797 797
798 void DownloadManagerImpl::AddObserver(Observer* observer) { 798 void DownloadManagerImpl::AddObserver(Observer* observer) {
799 observers_.AddObserver(observer); 799 observers_.AddObserver(observer);
800 // TODO: It is the responsibility of the observers to query the 800 // TODO: It is the responsibility of the observers to query the
801 // DownloadManager. Remove the following call from here and update all 801 // DownloadManager. Remove the following call from here and update all
802 // observers. 802 // observers.
803 observer->ModelChanged(this); 803 observer->ModelChanged(this);
804 } 804 }
805 805
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 void DownloadManagerImpl::DownloadRenamedToFinalName( 1039 void DownloadManagerImpl::DownloadRenamedToFinalName(
1040 DownloadItemImpl* download) { 1040 DownloadItemImpl* download) {
1041 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1041 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1042 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1042 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1043 // receive the DownloadRenamedToFinalName() call. 1043 // receive the DownloadRenamedToFinalName() call.
1044 if (delegate_) { 1044 if (delegate_) {
1045 delegate_->UpdatePathForItemInPersistentStore( 1045 delegate_->UpdatePathForItemInPersistentStore(
1046 download, download->GetFullPath()); 1046 download, download->GetFullPath());
1047 } 1047 }
1048 } 1048 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698