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

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

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "content/browser/download/save_file_manager.h" 7 #include "content/browser/download/save_file_manager.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 void SaveFileManager::CancelSave(int save_id) { 404 void SaveFileManager::CancelSave(int save_id) {
405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
406 SaveFileMap::iterator it = save_file_map_.find(save_id); 406 SaveFileMap::iterator it = save_file_map_.find(save_id);
407 if (it != save_file_map_.end()) { 407 if (it != save_file_map_.end()) {
408 SaveFile* save_file = it->second; 408 SaveFile* save_file = it->second;
409 409
410 if (!save_file->InProgress()) { 410 if (!save_file->InProgress()) {
411 // We've won a race with the UI thread--we finished the file before 411 // We've won a race with the UI thread--we finished the file before
412 // the UI thread cancelled it on us. Unfortunately, in this situation 412 // the UI thread cancelled it on us. Unfortunately, in this situation
413 // the cancel wins, so we need to delete the now detached file. 413 // the cancel wins, so we need to delete the now detached file.
414 file_util::Delete(save_file->FullPath(), false); 414 base::Delete(save_file->FullPath(), false);
415 } else if (save_file->save_source() == 415 } else if (save_file->save_source() ==
416 SaveFileCreateInfo::SAVE_FILE_FROM_NET) { 416 SaveFileCreateInfo::SAVE_FILE_FROM_NET) {
417 // If the data comes from the net IO thread and hasn't completed 417 // If the data comes from the net IO thread and hasn't completed
418 // yet, then forward the cancel message to IO thread & cancel the 418 // yet, then forward the cancel message to IO thread & cancel the
419 // save locally. If the data doesn't come from the IO thread, 419 // save locally. If the data doesn't come from the IO thread,
420 // we can ignore the message. 420 // we can ignore the message.
421 BrowserThread::PostTask( 421 BrowserThread::PostTask(
422 BrowserThread::IO, FROM_HERE, 422 BrowserThread::IO, FROM_HERE,
423 base::Bind(&SaveFileManager::ExecuteCancelSaveRequest, this, 423 base::Bind(&SaveFileManager::ExecuteCancelSaveRequest, this,
424 save_file->render_process_id(), save_file->request_id())); 424 save_file->render_process_id(), save_file->request_id()));
(...skipping 29 matching lines...) Expand all
454 net::FileURLToFilePath(original_file_url, &file_path); 454 net::FileURLToFilePath(original_file_url, &file_path);
455 // If we can not get valid file path from original URL, treat it as 455 // If we can not get valid file path from original URL, treat it as
456 // disk error. 456 // disk error.
457 if (file_path.empty()) 457 if (file_path.empty())
458 SaveFinished(save_id, original_file_url, render_process_id, false); 458 SaveFinished(save_id, original_file_url, render_process_id, false);
459 459
460 // Copy the local file to the temporary file. It will be renamed to its 460 // Copy the local file to the temporary file. It will be renamed to its
461 // final name later. 461 // final name later.
462 bool success = file_util::CopyFile(file_path, save_file->FullPath()); 462 bool success = file_util::CopyFile(file_path, save_file->FullPath());
463 if (!success) 463 if (!success)
464 file_util::Delete(save_file->FullPath(), false); 464 base::Delete(save_file->FullPath(), false);
465 SaveFinished(save_id, original_file_url, render_process_id, success); 465 SaveFinished(save_id, original_file_url, render_process_id, success);
466 } 466 }
467 467
468 void SaveFileManager::OnDeleteDirectoryOrFile(const base::FilePath& full_path, 468 void SaveFileManager::OnDeleteDirectoryOrFile(const base::FilePath& full_path,
469 bool is_dir) { 469 bool is_dir) {
470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
471 DCHECK(!full_path.empty()); 471 DCHECK(!full_path.empty());
472 472
473 file_util::Delete(full_path, is_dir); 473 base::Delete(full_path, is_dir);
474 } 474 }
475 475
476 void SaveFileManager::RenameAllFiles( 476 void SaveFileManager::RenameAllFiles(
477 const FinalNameList& final_names, 477 const FinalNameList& final_names,
478 const base::FilePath& resource_dir, 478 const base::FilePath& resource_dir,
479 int render_process_id, 479 int render_process_id,
480 int render_view_id, 480 int render_view_id,
481 int save_package_id) { 481 int save_package_id) {
482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
483 483
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 void SaveFileManager::RemoveSavedFileFromFileMap( 517 void SaveFileManager::RemoveSavedFileFromFileMap(
518 const SaveIDList& save_ids) { 518 const SaveIDList& save_ids) {
519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
520 520
521 for (SaveIDList::const_iterator i = save_ids.begin(); 521 for (SaveIDList::const_iterator i = save_ids.begin();
522 i != save_ids.end(); ++i) { 522 i != save_ids.end(); ++i) {
523 SaveFileMap::iterator it = save_file_map_.find(*i); 523 SaveFileMap::iterator it = save_file_map_.find(*i);
524 if (it != save_file_map_.end()) { 524 if (it != save_file_map_.end()) {
525 SaveFile* save_file = it->second; 525 SaveFile* save_file = it->second;
526 DCHECK(!save_file->InProgress()); 526 DCHECK(!save_file->InProgress());
527 file_util::Delete(save_file->FullPath(), false); 527 base::Delete(save_file->FullPath(), false);
528 delete save_file; 528 delete save_file;
529 save_file_map_.erase(it); 529 save_file_map_.erase(it);
530 } 530 }
531 } 531 }
532 } 532 }
533 533
534 } // namespace content 534 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | content/browser/gpu/gpu_pixel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698