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

Side by Side Diff: content/browser/download/download_file_manager.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_file_manager.h" 5 #include "content/browser/download/download_file_manager.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 void DownloadFileManager::CreateDownloadFile( 56 void DownloadFileManager::CreateDownloadFile(
57 scoped_ptr<DownloadCreateInfo> info, 57 scoped_ptr<DownloadCreateInfo> info,
58 scoped_ptr<content::ByteStreamReader> stream, 58 scoped_ptr<content::ByteStreamReader> stream,
59 scoped_refptr<DownloadManager> download_manager, bool get_hash, 59 scoped_refptr<DownloadManager> download_manager, bool get_hash,
60 const net::BoundNetLog& bound_net_log, 60 const net::BoundNetLog& bound_net_log,
61 const CreateDownloadFileCallback& callback) { 61 const CreateDownloadFileCallback& callback) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
63 DCHECK(info.get()); 63 DCHECK(info.get());
64 VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString(); 64 VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString();
65 65
66 // Can't dereference info after info.Pass(), so we need to do it here.
67 DownloadId id(info->download_id);
68
66 scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile( 69 scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile(
67 info.get(), stream.Pass(), download_manager, get_hash, bound_net_log)); 70 info.Pass(), stream.Pass(), download_manager, get_hash, bound_net_log));
68 71
69 content::DownloadInterruptReason interrupt_reason( 72 content::DownloadInterruptReason interrupt_reason(
70 download_file->Initialize()); 73 download_file->Initialize());
71 if (interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NONE) { 74 if (interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NONE) {
72 DCHECK(GetDownloadFile(info->download_id) == NULL); 75 DCHECK(GetDownloadFile(id) == NULL);
73 downloads_[info->download_id] = download_file.release(); 76 downloads_[id] = download_file.release();
74 } 77 }
75 78
76 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 79 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
77 base::Bind(callback, interrupt_reason)); 80 base::Bind(callback, interrupt_reason));
78 } 81 }
79 82
80 DownloadFile* DownloadFileManager::GetDownloadFile( 83 DownloadFile* DownloadFileManager::GetDownloadFile(
81 DownloadId global_id) { 84 DownloadId global_id) {
82 DownloadFileMap::iterator it = downloads_.find(global_id); 85 DownloadFileMap::iterator it = downloads_.find(global_id);
83 return it == downloads_.end() ? NULL : it->second; 86 return it == downloads_.end() ? NULL : it->second;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 DownloadFile* download_file = downloads_[global_id]; 177 DownloadFile* download_file = downloads_[global_id];
175 178
176 VLOG(20) << " " << __FUNCTION__ << "()" 179 VLOG(20) << " " << __FUNCTION__ << "()"
177 << " id = " << global_id 180 << " id = " << global_id
178 << " download_file = " << download_file->DebugString(); 181 << " download_file = " << download_file->DebugString();
179 182
180 downloads_.erase(global_id); 183 downloads_.erase(global_id);
181 184
182 delete download_file; 185 delete download_file;
183 } 186 }
OLDNEW
« no previous file with comments | « content/browser/download/download_file_impl.cc ('k') | content/browser/download/download_file_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698