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

Unified Diff: components/filesystem/file_impl.cc

Issue 1962503002: Add mojom module suffix in .mojom files for components/filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/filesystem/file_impl.h ('k') | components/filesystem/file_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/filesystem/file_impl.cc
diff --git a/components/filesystem/file_impl.cc b/components/filesystem/file_impl.cc
index ee73031f99e499e92351b478b21a1b071a48a427..94e4916f3d2267854480065fa12e6d5ec8146279 100644
--- a/components/filesystem/file_impl.cc
+++ b/components/filesystem/file_impl.cc
@@ -32,7 +32,7 @@ const size_t kMaxReadSize = 1 * 1024 * 1024; // 1 MB.
} // namespace
-FileImpl::FileImpl(mojo::InterfaceRequest<File> request,
+FileImpl::FileImpl(mojo::InterfaceRequest<mojom::File> request,
const base::FilePath& path,
uint32_t flags,
scoped_refptr<SharedTempDir> temp_dir,
@@ -45,7 +45,7 @@ FileImpl::FileImpl(mojo::InterfaceRequest<File> request,
DCHECK(file_.IsValid());
}
-FileImpl::FileImpl(mojo::InterfaceRequest<File> request,
+FileImpl::FileImpl(mojo::InterfaceRequest<mojom::File> request,
const base::FilePath& path,
base::File file,
scoped_refptr<SharedTempDir> temp_dir,
@@ -83,35 +83,35 @@ void FileImpl::Close(const CloseCallback& callback) {
lock_table_->RemoveFromLockTable(path_);
file_.Close();
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
// TODO(vtl): Move the implementation to a thread pool.
void FileImpl::Read(uint32_t num_bytes_to_read,
int64_t offset,
- Whence whence,
+ mojom::Whence whence,
const ReadCallback& callback) {
if (!file_.IsValid()) {
callback.Run(GetError(file_), mojo::Array<uint8_t>());
return;
}
if (num_bytes_to_read > kMaxReadSize) {
- callback.Run(FileError::INVALID_OPERATION, mojo::Array<uint8_t>());
+ callback.Run(mojom::FileError::INVALID_OPERATION, mojo::Array<uint8_t>());
return;
}
- FileError error = IsOffsetValid(offset);
- if (error != FileError::OK) {
+ mojom::FileError error = IsOffsetValid(offset);
+ if (error != mojom::FileError::OK) {
callback.Run(error, mojo::Array<uint8_t>());
return;
}
error = IsWhenceValid(whence);
- if (error != FileError::OK) {
+ if (error != mojom::FileError::OK) {
callback.Run(error, mojo::Array<uint8_t>());
return;
}
if (file_.Seek(static_cast<base::File::Whence>(whence), offset) == -1) {
- callback.Run(FileError::FAILED, mojo::Array<uint8_t>());
+ callback.Run(mojom::FileError::FAILED, mojo::Array<uint8_t>());
return;
}
@@ -119,19 +119,19 @@ void FileImpl::Read(uint32_t num_bytes_to_read,
int num_bytes_read = file_.ReadAtCurrentPos(
reinterpret_cast<char*>(&bytes_read.front()), num_bytes_to_read);
if (num_bytes_read < 0) {
- callback.Run(FileError::FAILED, mojo::Array<uint8_t>());
+ callback.Run(mojom::FileError::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(FileError::OK, std::move(bytes_read));
+ callback.Run(mojom::FileError::OK, std::move(bytes_read));
}
// TODO(vtl): Move the implementation to a thread pool.
void FileImpl::Write(mojo::Array<uint8_t> bytes_to_write,
int64_t offset,
- Whence whence,
+ mojom::Whence whence,
const WriteCallback& callback) {
DCHECK(!bytes_to_write.is_null());
if (!file_.IsValid()) {
@@ -146,22 +146,22 @@ void FileImpl::Write(mojo::Array<uint8_t> bytes_to_write,
#else
static_cast<size_t>(std::numeric_limits<ssize_t>::max())) {
#endif
- callback.Run(FileError::INVALID_OPERATION, 0);
+ callback.Run(mojom::FileError::INVALID_OPERATION, 0);
return;
}
- FileError error = IsOffsetValid(offset);
- if (error != FileError::OK) {
+ mojom::FileError error = IsOffsetValid(offset);
+ if (error != mojom::FileError::OK) {
callback.Run(error, 0);
return;
}
error = IsWhenceValid(whence);
- if (error != FileError::OK) {
+ if (error != mojom::FileError::OK) {
callback.Run(error, 0);
return;
}
if (file_.Seek(static_cast<base::File::Whence>(whence), offset) == -1) {
- callback.Run(FileError::FAILED, 0);
+ callback.Run(mojom::FileError::FAILED, 0);
return;
}
@@ -171,33 +171,33 @@ void FileImpl::Write(mojo::Array<uint8_t> bytes_to_write,
int num_bytes_written = file_.WriteAtCurrentPos(
buf, static_cast<int>(bytes_to_write.size()));
if (num_bytes_written < 0) {
- callback.Run(FileError::FAILED, 0);
+ callback.Run(mojom::FileError::FAILED, 0);
return;
}
DCHECK_LE(static_cast<size_t>(num_bytes_written),
std::numeric_limits<uint32_t>::max());
- callback.Run(FileError::OK, static_cast<uint32_t>(num_bytes_written));
+ callback.Run(mojom::FileError::OK, static_cast<uint32_t>(num_bytes_written));
}
void FileImpl::Tell(const TellCallback& callback) {
- Seek(0, Whence::FROM_CURRENT, callback);
+ Seek(0, mojom::Whence::FROM_CURRENT, callback);
}
void FileImpl::Seek(int64_t offset,
- Whence whence,
+ mojom::Whence whence,
const SeekCallback& callback) {
if (!file_.IsValid()) {
callback.Run(GetError(file_), 0);
return;
}
- FileError error = IsOffsetValid(offset);
- if (error != FileError::OK) {
+ mojom::FileError error = IsOffsetValid(offset);
+ if (error != mojom::FileError::OK) {
callback.Run(error, 0);
return;
}
error = IsWhenceValid(whence);
- if (error != FileError::OK) {
+ if (error != mojom::FileError::OK) {
callback.Run(error, 0);
return;
}
@@ -205,11 +205,11 @@ void FileImpl::Seek(int64_t offset,
int64_t position =
file_.Seek(static_cast<base::File::Whence>(whence), offset);
if (position < 0) {
- callback.Run(FileError::FAILED, 0);
+ callback.Run(mojom::FileError::FAILED, 0);
return;
}
- callback.Run(FileError::OK, static_cast<int64_t>(position));
+ callback.Run(mojom::FileError::OK, static_cast<int64_t>(position));
}
void FileImpl::Stat(const StatCallback& callback) {
@@ -220,11 +220,11 @@ void FileImpl::Stat(const StatCallback& callback) {
base::File::Info info;
if (!file_.GetInfo(&info)) {
- callback.Run(FileError::FAILED, nullptr);
+ callback.Run(mojom::FileError::FAILED, nullptr);
return;
}
- callback.Run(FileError::OK, MakeFileInformation(info));
+ callback.Run(mojom::FileError::OK, MakeFileInformation(info));
}
void FileImpl::Truncate(int64_t size, const TruncateCallback& callback) {
@@ -233,25 +233,25 @@ void FileImpl::Truncate(int64_t size, const TruncateCallback& callback) {
return;
}
if (size < 0) {
- callback.Run(FileError::INVALID_OPERATION);
+ callback.Run(mojom::FileError::INVALID_OPERATION);
return;
}
- FileError error = IsOffsetValid(size);
- if (error != FileError::OK) {
+ mojom::FileError error = IsOffsetValid(size);
+ if (error != mojom::FileError::OK) {
callback.Run(error);
return;
}
if (!file_.SetLength(size)) {
- callback.Run(FileError::NOT_FOUND);
+ callback.Run(mojom::FileError::NOT_FOUND);
return;
}
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
-void FileImpl::Touch(TimespecOrNowPtr atime,
- TimespecOrNowPtr mtime,
+void FileImpl::Touch(mojom::TimespecOrNowPtr atime,
+ mojom::TimespecOrNowPtr mtime,
const TouchCallback& callback) {
if (!file_.IsValid()) {
callback.Run(GetError(file_));
@@ -262,7 +262,7 @@ void FileImpl::Touch(TimespecOrNowPtr atime,
if (!atime) {
base::File::Info info;
if (!file_.GetInfo(&info)) {
- callback.Run(FileError::FAILED);
+ callback.Run(mojom::FileError::FAILED);
return;
}
@@ -275,7 +275,7 @@ void FileImpl::Touch(TimespecOrNowPtr atime,
if (!mtime) {
base::File::Info info;
if (!file_.GetInfo(&info)) {
- callback.Run(FileError::FAILED);
+ callback.Run(mojom::FileError::FAILED);
return;
}
@@ -285,10 +285,10 @@ void FileImpl::Touch(TimespecOrNowPtr atime,
}
file_.SetTimes(base_atime, base_mtime);
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
-void FileImpl::Dup(mojo::InterfaceRequest<File> file,
+void FileImpl::Dup(mojo::InterfaceRequest<mojom::File> file,
const DupCallback& callback) {
if (!file_.IsValid()) {
callback.Run(GetError(file_));
@@ -304,7 +304,7 @@ void FileImpl::Dup(mojo::InterfaceRequest<File> file,
if (file.is_pending())
new FileImpl(std::move(file), path_, std::move(new_file), temp_dir_,
lock_table_);
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
void FileImpl::Flush(const FlushCallback& callback) {
@@ -314,16 +314,17 @@ void FileImpl::Flush(const FlushCallback& callback) {
}
bool ret = file_.Flush();
- callback.Run(ret ? FileError::OK : FileError::FAILED);
+ callback.Run(ret ? mojom::FileError::OK : mojom::FileError::FAILED);
}
void FileImpl::Lock(const LockCallback& callback) {
- callback.Run(static_cast<filesystem::FileError>(lock_table_->LockFile(this)));
+ callback.Run(
+ static_cast<filesystem::mojom::FileError>(lock_table_->LockFile(this)));
}
void FileImpl::Unlock(const UnlockCallback& callback) {
callback.Run(
- static_cast<filesystem::FileError>(lock_table_->UnlockFile(this)));
+ static_cast<filesystem::mojom::FileError>(lock_table_->UnlockFile(this)));
}
void FileImpl::AsHandle(const AsHandleCallback& callback) {
@@ -340,7 +341,7 @@ void FileImpl::AsHandle(const AsHandleCallback& callback) {
base::File::Info info;
if (!new_file.GetInfo(&info)) {
- callback.Run(FileError::FAILED, ScopedHandle());
+ callback.Run(mojom::FileError::FAILED, ScopedHandle());
return;
}
@@ -349,7 +350,7 @@ void FileImpl::AsHandle(const AsHandleCallback& callback) {
// passing a file descriptor to a directory is a sandbox escape on Windows,
// we should be absolutely paranoid.
if (info.is_directory) {
- callback.Run(FileError::NOT_A_FILE, ScopedHandle());
+ callback.Run(mojom::FileError::NOT_A_FILE, ScopedHandle());
return;
}
@@ -357,11 +358,11 @@ void FileImpl::AsHandle(const AsHandleCallback& callback) {
MojoResult create_result = MojoCreatePlatformHandleWrapper(
new_file.TakePlatformFile(), &mojo_handle);
if (create_result != MOJO_RESULT_OK) {
- callback.Run(FileError::FAILED, ScopedHandle());
+ callback.Run(mojom::FileError::FAILED, ScopedHandle());
return;
}
- callback.Run(FileError::OK, ScopedHandle(mojo::Handle(mojo_handle)));
+ callback.Run(mojom::FileError::OK, ScopedHandle(mojo::Handle(mojo_handle)));
}
} // namespace filesystem
« no previous file with comments | « components/filesystem/file_impl.h ('k') | components/filesystem/file_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698