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

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: Incorporated Al's comments. 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(),
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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 771 }
772 772
773 void DownloadManagerImpl::DownloadUrl( 773 void DownloadManagerImpl::DownloadUrl(
774 scoped_ptr<content::DownloadUrlParameters> params) { 774 scoped_ptr<content::DownloadUrlParameters> params) {
775 if (params->post_id() >= 0) { 775 if (params->post_id() >= 0) {
776 // Check this here so that the traceback is more useful. 776 // Check this here so that the traceback is more useful.
777 DCHECK(params->prefer_cache()); 777 DCHECK(params->prefer_cache());
778 DCHECK(params->method() == "POST"); 778 DCHECK(params->method() == "POST");
779 } 779 }
780 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( 780 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(
781 &BeginDownload, base::Owned(params.release()))); 781 &BeginDownload, base::Passed(params.Pass())));
782 } 782 }
783 783
784 void DownloadManagerImpl::AddObserver(Observer* observer) { 784 void DownloadManagerImpl::AddObserver(Observer* observer) {
785 observers_.AddObserver(observer); 785 observers_.AddObserver(observer);
786 // TODO: It is the responsibility of the observers to query the 786 // TODO: It is the responsibility of the observers to query the
787 // DownloadManager. Remove the following call from here and update all 787 // DownloadManager. Remove the following call from here and update all
788 // observers. 788 // observers.
789 observer->ModelChanged(this); 789 observer->ModelChanged(this);
790 } 790 }
791 791
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 void DownloadManagerImpl::DownloadRenamedToFinalName( 1025 void DownloadManagerImpl::DownloadRenamedToFinalName(
1026 DownloadItemImpl* download) { 1026 DownloadItemImpl* download) {
1027 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1027 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1028 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1028 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1029 // receive the DownloadRenamedToFinalName() call. 1029 // receive the DownloadRenamedToFinalName() call.
1030 if (delegate_) { 1030 if (delegate_) {
1031 delegate_->UpdatePathForItemInPersistentStore( 1031 delegate_->UpdatePathForItemInPersistentStore(
1032 download, download->GetFullPath()); 1032 download, download->GetFullPath());
1033 } 1033 }
1034 } 1034 }
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl_unittest.cc ('k') | content/browser/download/download_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698