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

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

Issue 12213066: Use base namespace for FilePath in content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 class DownloadItemFactoryImpl : public DownloadItemFactory { 163 class DownloadItemFactoryImpl : public DownloadItemFactory {
164 public: 164 public:
165 DownloadItemFactoryImpl() {} 165 DownloadItemFactoryImpl() {}
166 virtual ~DownloadItemFactoryImpl() {} 166 virtual ~DownloadItemFactoryImpl() {}
167 167
168 virtual DownloadItemImpl* CreatePersistedItem( 168 virtual DownloadItemImpl* CreatePersistedItem(
169 DownloadItemImplDelegate* delegate, 169 DownloadItemImplDelegate* delegate,
170 DownloadId download_id, 170 DownloadId download_id,
171 const FilePath& current_path, 171 const base::FilePath& current_path,
172 const FilePath& target_path, 172 const base::FilePath& target_path,
173 const std::vector<GURL>& url_chain, 173 const std::vector<GURL>& url_chain,
174 const GURL& referrer_url, 174 const GURL& referrer_url,
175 const base::Time& start_time, 175 const base::Time& start_time,
176 const base::Time& end_time, 176 const base::Time& end_time,
177 int64 received_bytes, 177 int64 received_bytes,
178 int64 total_bytes, 178 int64 total_bytes,
179 DownloadItem::DownloadState state, 179 DownloadItem::DownloadState state,
180 DownloadDangerType danger_type, 180 DownloadDangerType danger_type,
181 DownloadInterruptReason interrupt_reason, 181 DownloadInterruptReason interrupt_reason,
182 bool opened, 182 bool opened,
(...skipping 18 matching lines...) Expand all
201 201
202 virtual DownloadItemImpl* CreateActiveItem( 202 virtual DownloadItemImpl* CreateActiveItem(
203 DownloadItemImplDelegate* delegate, 203 DownloadItemImplDelegate* delegate,
204 const DownloadCreateInfo& info, 204 const DownloadCreateInfo& info,
205 const net::BoundNetLog& bound_net_log) OVERRIDE { 205 const net::BoundNetLog& bound_net_log) OVERRIDE {
206 return new DownloadItemImpl(delegate, info, bound_net_log); 206 return new DownloadItemImpl(delegate, info, bound_net_log);
207 } 207 }
208 208
209 virtual DownloadItemImpl* CreateSavePageItem( 209 virtual DownloadItemImpl* CreateSavePageItem(
210 DownloadItemImplDelegate* delegate, 210 DownloadItemImplDelegate* delegate,
211 const FilePath& path, 211 const base::FilePath& path,
212 const GURL& url, 212 const GURL& url,
213 DownloadId download_id, 213 DownloadId download_id,
214 const std::string& mime_type, 214 const std::string& mime_type,
215 const net::BoundNetLog& bound_net_log) OVERRIDE { 215 const net::BoundNetLog& bound_net_log) OVERRIDE {
216 return new DownloadItemImpl(delegate, path, url, download_id, 216 return new DownloadItemImpl(delegate, path, url, download_id,
217 mime_type, bound_net_log); 217 mime_type, bound_net_log);
218 } 218 }
219 }; 219 };
220 220
221 } // namespace 221 } // namespace
(...skipping 26 matching lines...) Expand all
248 } 248 }
249 249
250 void DownloadManagerImpl::DetermineDownloadTarget( 250 void DownloadManagerImpl::DetermineDownloadTarget(
251 DownloadItemImpl* item, const DownloadTargetCallback& callback) { 251 DownloadItemImpl* item, const DownloadTargetCallback& callback) {
252 // Note that this next call relies on 252 // Note that this next call relies on
253 // DownloadItemImplDelegate::DownloadTargetCallback and 253 // DownloadItemImplDelegate::DownloadTargetCallback and
254 // DownloadManagerDelegate::DownloadTargetCallback having the same 254 // DownloadManagerDelegate::DownloadTargetCallback having the same
255 // type. If the types ever diverge, gasket code will need to 255 // type. If the types ever diverge, gasket code will need to
256 // be written here. 256 // be written here.
257 if (!delegate_ || !delegate_->DetermineDownloadTarget(item, callback)) { 257 if (!delegate_ || !delegate_->DetermineDownloadTarget(item, callback)) {
258 FilePath target_path = item->GetForcedFilePath(); 258 base::FilePath target_path = item->GetForcedFilePath();
259 // TODO(asanka): Determine a useful path if |target_path| is empty. 259 // TODO(asanka): Determine a useful path if |target_path| is empty.
260 callback.Run(target_path, 260 callback.Run(target_path,
261 DownloadItem::TARGET_DISPOSITION_OVERWRITE, 261 DownloadItem::TARGET_DISPOSITION_OVERWRITE,
262 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 262 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
263 target_path); 263 target_path);
264 } 264 }
265 } 265 }
266 266
267 bool DownloadManagerImpl::ShouldCompleteDownload( 267 bool DownloadManagerImpl::ShouldCompleteDownload(
268 DownloadItemImpl* item, const base::Closure& complete_callback) { 268 DownloadItemImpl* item, const base::Closure& complete_callback) {
269 if (!delegate_ || 269 if (!delegate_ ||
270 delegate_->ShouldCompleteDownload(item, complete_callback)) { 270 delegate_->ShouldCompleteDownload(item, complete_callback)) {
271 return true; 271 return true;
272 } 272 }
273 // Otherwise, the delegate has accepted responsibility to run the 273 // Otherwise, the delegate has accepted responsibility to run the
274 // callback when the download is ready for completion. 274 // callback when the download is ready for completion.
275 return false; 275 return false;
276 } 276 }
277 277
278 bool DownloadManagerImpl::ShouldOpenFileBasedOnExtension(const FilePath& path) { 278 bool DownloadManagerImpl::ShouldOpenFileBasedOnExtension(
279 const base::FilePath& path) {
279 if (!delegate_) 280 if (!delegate_)
280 return false; 281 return false;
281 282
282 return delegate_->ShouldOpenFileBasedOnExtension(path); 283 return delegate_->ShouldOpenFileBasedOnExtension(path);
283 } 284 }
284 285
285 bool DownloadManagerImpl::ShouldOpenDownload( 286 bool DownloadManagerImpl::ShouldOpenDownload(
286 DownloadItemImpl* item, const ShouldOpenDownloadCallback& callback) { 287 DownloadItemImpl* item, const ShouldOpenDownloadCallback& callback) {
287 if (!delegate_) 288 if (!delegate_)
288 return true; 289 return true;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 browser_context_ = browser_context; 360 browser_context_ = browser_context;
360 361
361 return true; 362 return true;
362 } 363 }
363 364
364 DownloadItem* DownloadManagerImpl::StartDownload( 365 DownloadItem* DownloadManagerImpl::StartDownload(
365 scoped_ptr<DownloadCreateInfo> info, 366 scoped_ptr<DownloadCreateInfo> info,
366 scoped_ptr<ByteStreamReader> stream) { 367 scoped_ptr<ByteStreamReader> stream) {
367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
368 369
369 FilePath default_download_directory; 370 base::FilePath default_download_directory;
370 if (delegate_) { 371 if (delegate_) {
371 FilePath website_save_directory; // Unused 372 base::FilePath website_save_directory; // Unused
372 bool skip_dir_check = false; // Unused 373 bool skip_dir_check = false; // Unused
373 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory, 374 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory,
374 &default_download_directory, &skip_dir_check); 375 &default_download_directory, &skip_dir_check);
375 } 376 }
376 377
377 // We create the DownloadItem before the DownloadFile because the 378 // We create the DownloadItem before the DownloadFile because the
378 // DownloadItem already needs to handle a state in which there is 379 // DownloadItem already needs to handle a state in which there is
379 // no associated DownloadFile (history downloads, !IN_PROGRESS downloads) 380 // no associated DownloadFile (history downloads, !IN_PROGRESS downloads)
380 DownloadItemImpl* download = GetOrCreateDownloadItem(info.get()); 381 DownloadItemImpl* download = GetOrCreateDownloadItem(info.get());
381 scoped_ptr<DownloadFile> download_file( 382 scoped_ptr<DownloadFile> download_file(
382 file_factory_->CreateFile( 383 file_factory_->CreateFile(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 net::BoundNetLog bound_net_log = 448 net::BoundNetLog bound_net_log =
448 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 449 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
449 download = item_factory_->CreateActiveItem(this, *info, bound_net_log); 450 download = item_factory_->CreateActiveItem(this, *info, bound_net_log);
450 downloads_[download->GetId()] = download; 451 downloads_[download->GetId()] = download;
451 } 452 }
452 453
453 return download; 454 return download;
454 } 455 }
455 456
456 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem( 457 DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem(
457 const FilePath& main_file_path, 458 const base::FilePath& main_file_path,
458 const GURL& page_url, 459 const GURL& page_url,
459 const std::string& mime_type, 460 const std::string& mime_type,
460 DownloadItem::Observer* observer) { 461 DownloadItem::Observer* observer) {
461 net::BoundNetLog bound_net_log = 462 net::BoundNetLog bound_net_log =
462 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 463 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
463 DownloadItemImpl* download_item = item_factory_->CreateSavePageItem( 464 DownloadItemImpl* download_item = item_factory_->CreateSavePageItem(
464 this, 465 this,
465 main_file_path, 466 main_file_path,
466 page_url, 467 page_url,
467 GetNextId(), 468 GetNextId(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 590
590 void DownloadManagerImpl::AddObserver(Observer* observer) { 591 void DownloadManagerImpl::AddObserver(Observer* observer) {
591 observers_.AddObserver(observer); 592 observers_.AddObserver(observer);
592 } 593 }
593 594
594 void DownloadManagerImpl::RemoveObserver(Observer* observer) { 595 void DownloadManagerImpl::RemoveObserver(Observer* observer) {
595 observers_.RemoveObserver(observer); 596 observers_.RemoveObserver(observer);
596 } 597 }
597 598
598 DownloadItem* DownloadManagerImpl::CreateDownloadItem( 599 DownloadItem* DownloadManagerImpl::CreateDownloadItem(
599 const FilePath& current_path, 600 const base::FilePath& current_path,
600 const FilePath& target_path, 601 const base::FilePath& target_path,
601 const std::vector<GURL>& url_chain, 602 const std::vector<GURL>& url_chain,
602 const GURL& referrer_url, 603 const GURL& referrer_url,
603 const base::Time& start_time, 604 const base::Time& start_time,
604 const base::Time& end_time, 605 const base::Time& end_time,
605 int64 received_bytes, 606 int64 received_bytes,
606 int64 total_bytes, 607 int64 total_bytes,
607 DownloadItem::DownloadState state, 608 DownloadItem::DownloadState state,
608 DownloadDangerType danger_type, 609 DownloadDangerType danger_type,
609 DownloadInterruptReason interrupt_reason, 610 DownloadInterruptReason interrupt_reason,
610 bool opened) { 611 bool opened) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 if (delegate_) 682 if (delegate_)
682 delegate_->OpenDownload(download); 683 delegate_->OpenDownload(download);
683 } 684 }
684 685
685 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 686 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
686 if (delegate_) 687 if (delegate_)
687 delegate_->ShowDownloadInShell(download); 688 delegate_->ShowDownloadInShell(download);
688 } 689 }
689 690
690 } // namespace content 691 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698