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

Unified Diff: components/filesystem/directory_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/directory_impl.h ('k') | components/filesystem/directory_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/filesystem/directory_impl.cc
diff --git a/components/filesystem/directory_impl.cc b/components/filesystem/directory_impl.cc
index aa208bcd85231b98e7a5fb293ddc1893dd0d4d0a..8df2b122d8941a950c2b3f5372a9b46fb4d3fefe 100644
--- a/components/filesystem/directory_impl.cc
+++ b/components/filesystem/directory_impl.cc
@@ -20,7 +20,7 @@
namespace filesystem {
-DirectoryImpl::DirectoryImpl(mojo::InterfaceRequest<Directory> request,
+DirectoryImpl::DirectoryImpl(mojo::InterfaceRequest<mojom::Directory> request,
base::FilePath directory_path,
scoped_refptr<SharedTempDir> temp_dir,
scoped_refptr<LockTable> lock_table)
@@ -32,21 +32,21 @@ DirectoryImpl::DirectoryImpl(mojo::InterfaceRequest<Directory> request,
DirectoryImpl::~DirectoryImpl() {}
void DirectoryImpl::Read(const ReadCallback& callback) {
- mojo::Array<DirectoryEntryPtr> entries;
+ mojo::Array<mojom::DirectoryEntryPtr> entries;
base::FileEnumerator directory_enumerator(
directory_path_, false,
base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES);
for (base::FilePath name = directory_enumerator.Next(); !name.empty();
name = directory_enumerator.Next()) {
base::FileEnumerator::FileInfo info = directory_enumerator.GetInfo();
- DirectoryEntryPtr entry = DirectoryEntry::New();
- entry->type =
- info.IsDirectory() ? FsFileType::DIRECTORY : FsFileType::REGULAR_FILE;
+ mojom::DirectoryEntryPtr entry = mojom::DirectoryEntry::New();
+ entry->type = info.IsDirectory() ? mojom::FsFileType::DIRECTORY
+ : mojom::FsFileType::REGULAR_FILE;
entry->name = info.GetName().AsUTF8Unsafe();
entries.push_back(std::move(entry));
}
- callback.Run(FileError::OK, std::move(entries));
+ callback.Run(mojom::FileError::OK, std::move(entries));
}
// TODO(erg): Consider adding an implementation of Stat()/Touch() to the
@@ -55,12 +55,12 @@ void DirectoryImpl::Read(const ReadCallback& callback) {
// TODO(vtl): Move the implementation to a thread pool.
void DirectoryImpl::OpenFile(const mojo::String& raw_path,
- mojo::InterfaceRequest<File> file,
+ mojo::InterfaceRequest<mojom::File> file,
uint32_t open_flags,
const OpenFileCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error);
return;
}
@@ -69,7 +69,7 @@ void DirectoryImpl::OpenFile(const mojo::String& raw_path,
// We must not return directories as files. In the file abstraction, we can
// fetch raw file descriptors over mojo pipes, and passing a file
// descriptor to a directory is a sandbox escape on Windows.
- callback.Run(FileError::NOT_A_FILE);
+ callback.Run(mojom::FileError::NOT_A_FILE);
return;
}
@@ -83,24 +83,25 @@ void DirectoryImpl::OpenFile(const mojo::String& raw_path,
new FileImpl(std::move(file), path, std::move(base_file), temp_dir_,
lock_table_);
}
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
void DirectoryImpl::OpenFileHandle(const mojo::String& raw_path,
uint32_t open_flags,
const OpenFileHandleCallback& callback) {
- FileError error = FileError::OK;
+ mojom::FileError error = mojom::FileError::OK;
mojo::ScopedHandle handle = OpenFileHandleImpl(raw_path, open_flags, &error);
callback.Run(error, std::move(handle));
}
-void DirectoryImpl::OpenFileHandles(mojo::Array<FileOpenDetailsPtr> details,
- const OpenFileHandlesCallback& callback) {
- mojo::Array<FileOpenResultPtr> results(
- mojo::Array<FileOpenResultPtr>::New(details.size()));
+void DirectoryImpl::OpenFileHandles(
+ mojo::Array<mojom::FileOpenDetailsPtr> details,
+ const OpenFileHandlesCallback& callback) {
+ mojo::Array<mojom::FileOpenResultPtr> results(
+ mojo::Array<mojom::FileOpenResultPtr>::New(details.size()));
size_t i = 0;
for (const auto& detail : details) {
- FileOpenResultPtr result(FileOpenResult::New());
+ mojom::FileOpenResultPtr result(mojom::FileOpenResult::New());
result->path = detail->path;
result->file_handle =
OpenFileHandleImpl(detail->path, detail->open_flags, &result->error);
@@ -109,109 +110,112 @@ void DirectoryImpl::OpenFileHandles(mojo::Array<FileOpenDetailsPtr> details,
callback.Run(std::move(results));
}
-void DirectoryImpl::OpenDirectory(const mojo::String& raw_path,
- mojo::InterfaceRequest<Directory> directory,
- uint32_t open_flags,
- const OpenDirectoryCallback& callback) {
+void DirectoryImpl::OpenDirectory(
+ const mojo::String& raw_path,
+ mojo::InterfaceRequest<mojom::Directory> directory,
+ uint32_t open_flags,
+ const OpenDirectoryCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error);
return;
}
if (!base::DirectoryExists(path)) {
if (base::PathExists(path)) {
- callback.Run(FileError::NOT_A_DIRECTORY);
+ callback.Run(mojom::FileError::NOT_A_DIRECTORY);
return;
}
- if (!(open_flags & kFlagOpenAlways || open_flags & kFlagCreate)) {
+ if (!(open_flags & mojom::kFlagOpenAlways ||
+ open_flags & mojom::kFlagCreate)) {
// The directory doesn't exist, and we weren't passed parameters to
// create it.
- callback.Run(FileError::NOT_FOUND);
+ callback.Run(mojom::FileError::NOT_FOUND);
return;
}
base::File::Error error;
if (!base::CreateDirectoryAndGetError(path, &error)) {
- callback.Run(static_cast<filesystem::FileError>(error));
+ callback.Run(static_cast<filesystem::mojom::FileError>(error));
return;
}
}
if (directory.is_pending())
new DirectoryImpl(std::move(directory), path, temp_dir_, lock_table_);
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
void DirectoryImpl::Rename(const mojo::String& raw_old_path,
const mojo::String& raw_new_path,
const RenameCallback& callback) {
base::FilePath old_path;
- FileError error = ValidatePath(raw_old_path, directory_path_, &old_path);
- if (error != FileError::OK) {
+ mojom::FileError error =
+ ValidatePath(raw_old_path, directory_path_, &old_path);
+ if (error != mojom::FileError::OK) {
callback.Run(error);
return;
}
base::FilePath new_path;
error = ValidatePath(raw_new_path, directory_path_, &new_path);
- if (error != FileError::OK) {
+ if (error != mojom::FileError::OK) {
callback.Run(error);
return;
}
if (!base::Move(old_path, new_path)) {
- callback.Run(FileError::FAILED);
+ callback.Run(mojom::FileError::FAILED);
return;
}
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
void DirectoryImpl::Delete(const mojo::String& raw_path,
uint32_t delete_flags,
const DeleteCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error);
return;
}
- bool recursive = delete_flags & kDeleteFlagRecursive;
+ bool recursive = delete_flags & mojom::kDeleteFlagRecursive;
if (!base::DeleteFile(path, recursive)) {
- callback.Run(FileError::FAILED);
+ callback.Run(mojom::FileError::FAILED);
return;
}
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
void DirectoryImpl::Exists(const mojo::String& raw_path,
const ExistsCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error, false);
return;
}
bool exists = base::PathExists(path);
- callback.Run(FileError::OK, exists);
+ callback.Run(mojom::FileError::OK, exists);
}
void DirectoryImpl::IsWritable(const mojo::String& raw_path,
const IsWritableCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error, false);
return;
}
- callback.Run(FileError::OK, base::PathIsWritable(path));
+ callback.Run(mojom::FileError::OK, base::PathIsWritable(path));
}
void DirectoryImpl::Flush(const FlushCallback& callback) {
@@ -222,18 +226,18 @@ void DirectoryImpl::Flush(const FlushCallback& callback) {
}
if (!file.Flush()) {
- callback.Run(FileError::FAILED);
+ callback.Run(mojom::FileError::FAILED);
return;
}
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
void DirectoryImpl::StatFile(const mojo::String& raw_path,
const StatFileCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error, nullptr);
return;
}
@@ -246,14 +250,14 @@ void DirectoryImpl::StatFile(const mojo::String& raw_path,
base::File::Info info;
if (!base_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 DirectoryImpl::Clone(mojo::InterfaceRequest<Directory> directory) {
+void DirectoryImpl::Clone(mojo::InterfaceRequest<mojom::Directory> directory) {
if (directory.is_pending()) {
new DirectoryImpl(std::move(directory), directory_path_,
temp_dir_, lock_table_);
@@ -263,14 +267,14 @@ void DirectoryImpl::Clone(mojo::InterfaceRequest<Directory> directory) {
void DirectoryImpl::ReadEntireFile(const mojo::String& raw_path,
const ReadEntireFileCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error, mojo::Array<uint8_t>());
return;
}
if (base::DirectoryExists(path)) {
- callback.Run(FileError::NOT_A_FILE, mojo::Array<uint8_t>());
+ callback.Run(mojom::FileError::NOT_A_FILE, mojo::Array<uint8_t>());
return;
}
@@ -287,21 +291,21 @@ void DirectoryImpl::ReadEntireFile(const mojo::String& raw_path,
while ((len = base_file.ReadAtCurrentPos(buf.get(), kBufferSize)) > 0)
contents.append(buf.get(), len);
- callback.Run(FileError::OK, mojo::Array<uint8_t>::From(contents));
+ callback.Run(mojom::FileError::OK, mojo::Array<uint8_t>::From(contents));
}
void DirectoryImpl::WriteFile(const mojo::String& raw_path,
mojo::Array<uint8_t> data,
const WriteFileCallback& callback) {
base::FilePath path;
- FileError error = ValidatePath(raw_path, directory_path_, &path);
- if (error != FileError::OK) {
+ mojom::FileError error = ValidatePath(raw_path, directory_path_, &path);
+ if (error != mojom::FileError::OK) {
callback.Run(error);
return;
}
if (base::DirectoryExists(path)) {
- callback.Run(FileError::NOT_A_FILE);
+ callback.Run(mojom::FileError::NOT_A_FILE);
return;
}
@@ -322,23 +326,23 @@ void DirectoryImpl::WriteFile(const mojo::String& raw_path,
}
}
- callback.Run(FileError::OK);
+ callback.Run(mojom::FileError::OK);
}
mojo::ScopedHandle DirectoryImpl::OpenFileHandleImpl(
const mojo::String& raw_path,
uint32_t open_flags,
- FileError* error) {
+ mojom::FileError* error) {
base::FilePath path;
*error = ValidatePath(raw_path, directory_path_, &path);
- if (*error != FileError::OK)
+ if (*error != mojom::FileError::OK)
return mojo::ScopedHandle();
if (base::DirectoryExists(path)) {
// We must not return directories as files. In the file abstraction, we
// can fetch raw file descriptors over mojo pipes, and passing a file
// descriptor to a directory is a sandbox escape on Windows.
- *error = FileError::NOT_A_FILE;
+ *error = mojom::FileError::NOT_A_FILE;
return mojo::ScopedHandle();
}
@@ -352,11 +356,11 @@ mojo::ScopedHandle DirectoryImpl::OpenFileHandleImpl(
MojoResult create_result = MojoCreatePlatformHandleWrapper(
base_file.TakePlatformFile(), &mojo_handle);
if (create_result != MOJO_RESULT_OK) {
- *error = FileError::FAILED;
+ *error = mojom::FileError::FAILED;
return mojo::ScopedHandle();
}
- *error = FileError::OK;
+ *error = mojom::FileError::OK;
return mojo::ScopedHandle(mojo::Handle(mojo_handle));
}
« no previous file with comments | « components/filesystem/directory_impl.h ('k') | components/filesystem/directory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698