| Index: components/filesystem/file_impl.cc
|
| diff --git a/components/filesystem/file_impl.cc b/components/filesystem/file_impl.cc
|
| index 72355328a7d02cf83d1b68c51fe152d56282cc5a..c9d2637179b5c6123ae2126bd2cb0ad13e046c0e 100644
|
| --- a/components/filesystem/file_impl.cc
|
| +++ b/components/filesystem/file_impl.cc
|
| @@ -4,7 +4,6 @@
|
|
|
| #include "components/filesystem/file_impl.h"
|
|
|
| -#include <stdint.h>
|
| #include <limits>
|
|
|
| #include "base/files/file_path.h"
|
| @@ -45,7 +44,7 @@
|
| }
|
|
|
| file_.Close();
|
| - callback.Run(FILE_ERROR_OK);
|
| + callback.Run(ERROR_OK);
|
| }
|
|
|
| // TODO(vtl): Move the implementation to a thread pool.
|
| @@ -58,20 +57,20 @@
|
| return;
|
| }
|
| if (num_bytes_to_read > kMaxReadSize) {
|
| - callback.Run(FILE_ERROR_INVALID_OPERATION, mojo::Array<uint8_t>());
|
| - return;
|
| - }
|
| - if (FileError error = IsOffsetValid(offset)) {
|
| + callback.Run(ERROR_INVALID_OPERATION, mojo::Array<uint8_t>());
|
| + return;
|
| + }
|
| + if (Error error = IsOffsetValid(offset)) {
|
| callback.Run(error, mojo::Array<uint8_t>());
|
| return;
|
| }
|
| - if (FileError error = IsWhenceValid(whence)) {
|
| + if (Error error = IsWhenceValid(whence)) {
|
| callback.Run(error, mojo::Array<uint8_t>());
|
| return;
|
| }
|
|
|
| if (file_.Seek(static_cast<base::File::Whence>(whence), offset) == -1) {
|
| - callback.Run(FILE_ERROR_FAILED, mojo::Array<uint8_t>());
|
| + callback.Run(ERROR_FAILED, mojo::Array<uint8_t>());
|
| return;
|
| }
|
|
|
| @@ -79,13 +78,13 @@
|
| int num_bytes_read = file_.ReadAtCurrentPos(
|
| reinterpret_cast<char*>(&bytes_read.front()), num_bytes_to_read);
|
| if (num_bytes_read < 0) {
|
| - callback.Run(FILE_ERROR_FAILED, mojo::Array<uint8_t>());
|
| + callback.Run(ERROR_FAILED, mojo::Array<uint8_t>());
|
| return;
|
| }
|
|
|
| DCHECK_LE(static_cast<size_t>(num_bytes_read), num_bytes_to_read);
|
| bytes_read.resize(static_cast<size_t>(num_bytes_read));
|
| - callback.Run(FILE_ERROR_OK, bytes_read.Pass());
|
| + callback.Run(ERROR_OK, bytes_read.Pass());
|
| }
|
|
|
| // TODO(vtl): Move the implementation to a thread pool.
|
| @@ -101,25 +100,21 @@
|
| // Who knows what |write()| would return if the size is that big (and it
|
| // actually wrote that much).
|
| if (bytes_to_write.size() >
|
| -#if defined(OS_WIN)
|
| - std::numeric_limits<DWORD>::max()) {
|
| -#else
|
| static_cast<size_t>(std::numeric_limits<ssize_t>::max())) {
|
| -#endif
|
| - callback.Run(FILE_ERROR_INVALID_OPERATION, 0);
|
| - return;
|
| - }
|
| - if (FileError error = IsOffsetValid(offset)) {
|
| - callback.Run(error, 0);
|
| - return;
|
| - }
|
| - if (FileError error = IsWhenceValid(whence)) {
|
| + callback.Run(ERROR_INVALID_OPERATION, 0);
|
| + return;
|
| + }
|
| + if (Error error = IsOffsetValid(offset)) {
|
| + callback.Run(error, 0);
|
| + return;
|
| + }
|
| + if (Error error = IsWhenceValid(whence)) {
|
| callback.Run(error, 0);
|
| return;
|
| }
|
|
|
| if (file_.Seek(static_cast<base::File::Whence>(whence), offset) == -1) {
|
| - callback.Run(FILE_ERROR_FAILED, 0);
|
| + callback.Run(ERROR_FAILED, 0);
|
| return;
|
| }
|
|
|
| @@ -128,13 +123,13 @@
|
| : nullptr;
|
| int num_bytes_written = file_.WriteAtCurrentPos(buf, bytes_to_write.size());
|
| if (num_bytes_written < 0) {
|
| - callback.Run(FILE_ERROR_FAILED, 0);
|
| + callback.Run(ERROR_FAILED, 0);
|
| return;
|
| }
|
|
|
| DCHECK_LE(static_cast<size_t>(num_bytes_written),
|
| std::numeric_limits<uint32_t>::max());
|
| - callback.Run(FILE_ERROR_OK, static_cast<uint32_t>(num_bytes_written));
|
| + callback.Run(ERROR_OK, static_cast<uint32_t>(num_bytes_written));
|
| }
|
|
|
| void FileImpl::Tell(const TellCallback& callback) {
|
| @@ -148,22 +143,22 @@
|
| callback.Run(GetError(file_), 0);
|
| return;
|
| }
|
| - if (FileError error = IsOffsetValid(offset)) {
|
| - callback.Run(error, 0);
|
| - return;
|
| - }
|
| - if (FileError error = IsWhenceValid(whence)) {
|
| + if (Error error = IsOffsetValid(offset)) {
|
| + callback.Run(error, 0);
|
| + return;
|
| + }
|
| + if (Error error = IsWhenceValid(whence)) {
|
| callback.Run(error, 0);
|
| return;
|
| }
|
|
|
| int64 position = file_.Seek(static_cast<base::File::Whence>(whence), offset);
|
| if (position < 0) {
|
| - callback.Run(FILE_ERROR_FAILED, 0);
|
| - return;
|
| - }
|
| -
|
| - callback.Run(FILE_ERROR_OK, static_cast<int64>(position));
|
| + callback.Run(ERROR_FAILED, 0);
|
| + return;
|
| + }
|
| +
|
| + callback.Run(ERROR_OK, static_cast<int64>(position));
|
| }
|
|
|
| void FileImpl::Stat(const StatCallback& callback) {
|
| @@ -174,11 +169,11 @@
|
|
|
| base::File::Info info;
|
| if (!file_.GetInfo(&info)) {
|
| - callback.Run(FILE_ERROR_FAILED, nullptr);
|
| - return;
|
| - }
|
| -
|
| - callback.Run(FILE_ERROR_OK, MakeFileInformation(info).Pass());
|
| + callback.Run(ERROR_FAILED, nullptr);
|
| + return;
|
| + }
|
| +
|
| + callback.Run(ERROR_OK, MakeFileInformation(info).Pass());
|
| }
|
|
|
| void FileImpl::Truncate(int64_t size, const TruncateCallback& callback) {
|
| @@ -187,20 +182,20 @@
|
| return;
|
| }
|
| if (size < 0) {
|
| - callback.Run(FILE_ERROR_INVALID_OPERATION);
|
| - return;
|
| - }
|
| - if (FileError error = IsOffsetValid(size)) {
|
| + callback.Run(ERROR_INVALID_OPERATION);
|
| + return;
|
| + }
|
| + if (Error error = IsOffsetValid(size)) {
|
| callback.Run(error);
|
| return;
|
| }
|
|
|
| if (!file_.SetLength(size)) {
|
| - callback.Run(FILE_ERROR_NOT_FOUND);
|
| - return;
|
| - }
|
| -
|
| - callback.Run(FILE_ERROR_OK);
|
| + callback.Run(ERROR_NOT_FOUND);
|
| + return;
|
| + }
|
| +
|
| + callback.Run(ERROR_OK);
|
| }
|
|
|
| void FileImpl::Touch(TimespecOrNowPtr atime,
|
| @@ -215,7 +210,7 @@
|
| if (!atime) {
|
| base::File::Info info;
|
| if (!file_.GetInfo(&info)) {
|
| - callback.Run(FILE_ERROR_FAILED);
|
| + callback.Run(ERROR_FAILED);
|
| return;
|
| }
|
|
|
| @@ -228,7 +223,7 @@
|
| if (!mtime) {
|
| base::File::Info info;
|
| if (!file_.GetInfo(&info)) {
|
| - callback.Run(FILE_ERROR_FAILED);
|
| + callback.Run(ERROR_FAILED);
|
| return;
|
| }
|
|
|
| @@ -238,7 +233,7 @@
|
| }
|
|
|
| file_.SetTimes(base_atime, base_mtime);
|
| - callback.Run(FILE_ERROR_OK);
|
| + callback.Run(ERROR_OK);
|
| }
|
|
|
| void FileImpl::Dup(mojo::InterfaceRequest<File> file,
|
| @@ -256,7 +251,7 @@
|
|
|
| if (file.is_pending())
|
| new FileImpl(file.Pass(), new_file.Pass());
|
| - callback.Run(FILE_ERROR_OK);
|
| + callback.Run(ERROR_OK);
|
| }
|
|
|
| void FileImpl::AsHandle(const AsHandleCallback& callback) {
|
| @@ -273,7 +268,7 @@
|
|
|
| base::File::Info info;
|
| if (!new_file.GetInfo(&info)) {
|
| - callback.Run(FILE_ERROR_FAILED, ScopedHandle());
|
| + callback.Run(ERROR_FAILED, ScopedHandle());
|
| return;
|
| }
|
|
|
| @@ -282,7 +277,7 @@
|
| // passing a file descriptor to a directory is a sandbox escape on Windows,
|
| // we should be absolutely paranoid.
|
| if (info.is_directory) {
|
| - callback.Run(FILE_ERROR_NOT_A_FILE, ScopedHandle());
|
| + callback.Run(ERROR_NOT_A_FILE, ScopedHandle());
|
| return;
|
| }
|
|
|
| @@ -290,11 +285,11 @@
|
| MojoResult create_result = MojoCreatePlatformHandleWrapper(
|
| new_file.TakePlatformFile(), &mojo_handle);
|
| if (create_result != MOJO_RESULT_OK) {
|
| - callback.Run(FILE_ERROR_FAILED, ScopedHandle());
|
| - return;
|
| - }
|
| -
|
| - callback.Run(FILE_ERROR_OK, ScopedHandle(mojo::Handle(mojo_handle)).Pass());
|
| + callback.Run(ERROR_FAILED, ScopedHandle());
|
| + return;
|
| + }
|
| +
|
| + callback.Run(ERROR_OK, ScopedHandle(mojo::Handle(mojo_handle)).Pass());
|
| }
|
|
|
| } // namespace filesystem
|
|
|