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

Unified Diff: components/filesystem/directory_impl.cc

Issue 1942473002: Eliminate mojo:resource_provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
Index: components/filesystem/directory_impl.cc
diff --git a/components/filesystem/directory_impl.cc b/components/filesystem/directory_impl.cc
index d6430710db0e45f73821420e5949f8a2225d8a67..bd2e09c3f79287f507b00c79f5a63b386523744b 100644
--- a/components/filesystem/directory_impl.cc
+++ b/components/filesystem/directory_impl.cc
@@ -123,6 +123,62 @@ void DirectoryImpl::OpenFileHandle(const mojo::String& raw_path,
callback.Run(FileError::OK, ScopedHandle(mojo::Handle(mojo_handle)));
}
+void DirectoryImpl::OpenFileHandles(mojo::Array<FileOpenDetailsPtr> details,
+ const OpenFileHandlesCallback& callback) {
+ /*
+ mojo::Array<FileOpenResultPtr> results(
+ mojo::Array<FileOpenResultPtr>::New(details.size()));
+ size_t i = 0;
+ for (const auto& detail : details) {
+ FileOpenResultPtr result(FileOpenResult::New());
+ result->path = detail->path;
+
+ base::FilePath path;
+ FileError error = ValidatePath(detail->path, directory_path_, &path);
+ if (error != FileError::OK) {
+ result->error = error;
+ result->file_handle = ScopedHandle();
+ results[i] = std::move(result);
+ continue;
+ }
+
+ 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.
+ result->error = FileError::NOT_A_FILE;
+ result->file_handle = ScopedHandle();
+ results[i] = std::move(result);
+ continue;
+ }
+
+ base::File base_file(path, detail->open_flags);
+ if (!base_file.IsValid()) {
+ result->error = GetError(base_file);
+ result->file_handle = ScopedHandle();
+ results[i] = std::move(result);
+ continue;
+ }
+
+ MojoHandle mojo_handle;
+ MojoResult create_result = MojoCreatePlatformHandleWrapper(
+ base_file.TakePlatformFile(), &mojo_handle);
+ if (create_result != MOJO_RESULT_OK) {
+ result->error = FileError::FAILED;
+ result->file_handle = ScopedHandle();
+ results[i] = std::move(result);
+ continue;
+ }
+
+ result->error = FileError::OK;
+ result->file_handle = ScopedHandle(mojo::Handle(mojo_handle));
+ results[i] = std::move(result);
+ }
+ callback.Run(std::move(results));
+ */
+ callback.Run();
+}
+
void DirectoryImpl::OpenDirectory(const mojo::String& raw_path,
mojo::InterfaceRequest<Directory> directory,
uint32_t open_flags,

Powered by Google App Engine
This is Rietveld 408576698