Commit 77c90085 authored by fdoray's avatar fdoray Committed by Commit bot

Remove FileUtilProxy:DeleteFile().

FileUtilProxy::DeleteFile() deletes a file on a TaskRunner and then
invokes a callback on the source thread. All call sites provide a null
callback. They might as well just post a base::DeleteFile() task to
the TaskRunner.

This is a prerequisite to stop allowing null callbacks in
base::PostTaskAndReplyWithResult().

BUG=162712

Review-Url: https://codereview.chromium.org/2528193002
Cr-Commit-Position: refs/heads/master@{#434765}
parent 175490c1
......@@ -48,19 +48,6 @@ class GetFileInfoHelper {
DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper);
};
File::Error DeleteAdapter(const FilePath& file_path, bool recursive) {
if (!PathExists(file_path)) {
return File::FILE_ERROR_NOT_FOUND;
}
if (!base::DeleteFile(file_path, recursive)) {
if (!recursive && !base::IsDirectoryEmpty(file_path)) {
return File::FILE_ERROR_NOT_EMPTY;
}
return File::FILE_ERROR_FAILED;
}
return File::FILE_OK;
}
} // namespace
// Retrieves the information about a file. It is invalid to pass NULL for the
......@@ -77,17 +64,6 @@ bool FileUtilProxy::GetFileInfo(
Bind(&GetFileInfoHelper::Reply, Owned(helper), callback));
}
// static
bool FileUtilProxy::DeleteFile(TaskRunner* task_runner,
const FilePath& file_path,
bool recursive,
const StatusCallback& callback) {
return base::PostTaskAndReplyWithResult(
task_runner, FROM_HERE,
Bind(&DeleteAdapter, file_path, recursive),
callback);
}
// static
bool FileUtilProxy::Touch(
TaskRunner* task_runner,
......
......@@ -35,14 +35,6 @@ class BASE_EXPORT FileUtilProxy {
const FilePath& file_path,
const GetFileInfoCallback& callback);
// Deletes a file or a directory.
// It is an error to delete a non-empty directory with recursive=false.
// This returns false if task posting to |task_runner| has failed.
static bool DeleteFile(TaskRunner* task_runner,
const FilePath& file_path,
bool recursive,
const StatusCallback& callback);
// Touches a file. The callback can be null.
// This returns false if task posting to |task_runner| has failed.
static bool Touch(
......
......@@ -5,7 +5,7 @@
#include "chrome/browser/safe_browsing/download_feedback.h"
#include "base/bind.h"
#include "base/files/file_util_proxy.h"
#include "base/files/file_util.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
......@@ -106,10 +106,9 @@ DownloadFeedbackImpl::~DownloadFeedbackImpl() {
uploader_.reset();
}
base::FileUtilProxy::DeleteFile(file_task_runner_.get(),
file_path_,
false,
base::FileUtilProxy::StatusCallback());
file_task_runner_->PostTask(
FROM_HERE,
base::Bind(base::IgnoreResult(&base::DeleteFile), file_path_, false));
}
void DownloadFeedbackImpl::Start(const base::Closure& finish_callback) {
......
......@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/file_util_proxy.h"
#include "base/metrics/histogram_macros.h"
#include "base/supports_user_data.h"
#include "base/task_runner.h"
......@@ -176,10 +175,9 @@ void DownloadFeedbackService::BeginFeedbackOrDeleteFile(
return;
service->BeginFeedback(ping_request, ping_response, path);
} else {
base::FileUtilProxy::DeleteFile(file_task_runner.get(),
path,
false,
base::FileUtilProxy::StatusCallback());
file_task_runner->PostTask(
FROM_HERE,
base::Bind(base::IgnoreResult(&base::DeleteFile), path, false));
}
}
......
......@@ -13,7 +13,6 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/file_util_proxy.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
......@@ -529,9 +528,9 @@ void PrintDialogGtk2::OnJobCompleted(GtkPrintJob* print_job,
LOG(ERROR) << "Printing failed: " << error->message;
if (print_job)
g_object_unref(print_job);
base::FileUtilProxy::DeleteFile(
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get(),
path_to_pdf_, false, base::FileUtilProxy::StatusCallback());
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(base::IgnoreResult(&base::DeleteFile), path_to_pdf_, false));
// Printing finished. Matches AddRef() in PrintDocument();
Release();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment