Commit 77e07b84 authored by kinuko@chromium.org's avatar kinuko@chromium.org

Convert MessageLoopProxy to TaskRunner in FileUtilProxy

Also adding unittests to FileUtilProxy.

BUG=123558,77454
TEST=FileUtilProxyTest.*


Review URL: http://codereview.chromium.org/10095028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133484 0039d316-1c4b-4281-b951-d872f2087c98
parent 16fca9b8
......@@ -154,6 +154,7 @@
'environment_unittest.cc',
'file_descriptor_shuffle_unittest.cc',
'file_path_unittest.cc',
'file_util_proxy_unittest.cc',
'file_util_unittest.cc',
'file_version_info_unittest.cc',
'gmock_unittest.cc',
......
This diff is collapsed.
......@@ -17,7 +17,7 @@
namespace base {
class MessageLoopProxy;
class TaskRunner;
class Time;
// This class provides asynchronous access to common file routines.
......@@ -59,7 +59,7 @@ class BASE_EXPORT FileUtilProxy {
// callback. If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to
// create a new file at the given |file_path| and calls back with
// PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists.
static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy,
static bool CreateOrOpen(TaskRunner* task_runner,
const FilePath& file_path,
int file_flags,
const CreateOrOpenCallback& callback);
......@@ -73,44 +73,44 @@ class BASE_EXPORT FileUtilProxy {
// Set |additional_file_flags| to 0 for synchronous writes and set to
// base::PLATFORM_FILE_ASYNC to support asynchronous file operations.
static bool CreateTemporary(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
int additional_file_flags,
const CreateTemporaryCallback& callback);
// Close the given file handle.
static bool Close(scoped_refptr<MessageLoopProxy> message_loop_proxy,
static bool Close(TaskRunner* task_runner,
PlatformFile,
const StatusCallback& callback);
// Retrieves the information about a file. It is invalid to pass a null
// callback.
static bool GetFileInfo(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
const FilePath& file_path,
const GetFileInfoCallback& callback);
static bool GetFileInfoFromPlatformFile(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
PlatformFile file,
const GetFileInfoCallback& callback);
// Deletes a file or a directory.
// It is an error to delete a non-empty directory with recursive=false.
static bool Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy,
static bool Delete(TaskRunner* task_runner,
const FilePath& file_path,
bool recursive,
const StatusCallback& callback);
// Deletes a directory and all of its contents.
static bool RecursiveDelete(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
const FilePath& file_path,
const StatusCallback& callback);
// Reads from a file. On success, the file pointer is moved to position
// |offset + bytes_to_read| in the file. The callback can be null.
static bool Read(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
PlatformFile file,
int64 offset,
int bytes_to_read,
......@@ -121,7 +121,7 @@ class BASE_EXPORT FileUtilProxy {
// |offset + bytes_to_write| in the file. The callback can be null.
// |bytes_to_write| must be greater than zero.
static bool Write(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
PlatformFile file,
int64 offset,
const char* buffer,
......@@ -130,7 +130,7 @@ class BASE_EXPORT FileUtilProxy {
// Touches a file. The callback can be null.
static bool Touch(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
PlatformFile file,
const Time& last_access_time,
const Time& last_modified_time,
......@@ -138,7 +138,7 @@ class BASE_EXPORT FileUtilProxy {
// Touches a file. The callback can be null.
static bool Touch(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
const FilePath& file_path,
const Time& last_access_time,
const Time& last_modified_time,
......@@ -148,7 +148,7 @@ class BASE_EXPORT FileUtilProxy {
// current length of the file, the file will be extended with zeroes.
// The callback can be null.
static bool Truncate(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
PlatformFile file,
int64 length,
const StatusCallback& callback);
......@@ -157,32 +157,32 @@ class BASE_EXPORT FileUtilProxy {
// current length of the file, the file will be extended with zeroes.
// The callback can be null.
static bool Truncate(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
const FilePath& path,
int64 length,
const StatusCallback& callback);
// Flushes a file. The callback can be null.
static bool Flush(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
PlatformFile file,
const StatusCallback& callback);
// Relay helpers.
static bool RelayFileTask(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
const tracked_objects::Location& from_here,
const FileTask& task,
const StatusCallback& callback);
static bool RelayCreateOrOpen(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
const CreateOrOpenTask& open_task,
const CloseTask& close_task,
const CreateOrOpenCallback& callback);
static bool RelayClose(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
TaskRunner* task_runner,
const CloseTask& close_task,
PlatformFile,
const StatusCallback& callback);
......
This diff is collapsed.
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