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

Unified Diff: components/filesystem/directory_impl.cc

Issue 1724493003: mojo leveldb: Address some comments that came after it was put in the CQ. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile failure Created 4 years, 10 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 | « no previous file | components/filesystem/lock_table.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 58480a18a1fb70ac9faf042ceef83ccd8fb31521..e8fab2a861b4beba9838fbb6ad2a4f22bffa7968 100644
--- a/components/filesystem/directory_impl.cc
+++ b/components/filesystem/directory_impl.cc
@@ -68,25 +68,7 @@ void DirectoryImpl::OpenFile(const mojo::String& raw_path,
return;
}
-#if defined(OS_WIN)
- // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory.
- if (base::DirectoryExists(path))
- open_flags |= base::File::FLAG_BACKUP_SEMANTICS;
-#endif // OS_WIN
-
- base::File base_file(path, open_flags);
- if (!base_file.IsValid()) {
- callback.Run(GetError(base_file));
- return;
- }
-
- base::File::Info info;
- if (!base_file.GetInfo(&info)) {
- callback.Run(FileError::FAILED);
- return;
- }
-
- if (info.is_directory) {
+ 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.
@@ -94,6 +76,12 @@ void DirectoryImpl::OpenFile(const mojo::String& raw_path,
return;
}
+ base::File base_file(path, open_flags);
+ if (!base_file.IsValid()) {
+ callback.Run(GetError(base_file));
+ return;
+ }
+
if (file.is_pending()) {
new FileImpl(std::move(file), path, std::move(base_file), lock_table_);
}
@@ -110,25 +98,7 @@ void DirectoryImpl::OpenFileHandle(const mojo::String& raw_path,
return;
}
-#if defined(OS_WIN)
- // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory.
- if (base::DirectoryExists(path))
- open_flags |= base::File::FLAG_BACKUP_SEMANTICS;
-#endif // OS_WIN
-
- base::File base_file(path, open_flags);
- if (!base_file.IsValid()) {
- callback.Run(GetError(base_file), ScopedHandle());
- return;
- }
-
- base::File::Info info;
- if (!base_file.GetInfo(&info)) {
- callback.Run(FileError::FAILED, ScopedHandle());
- return;
- }
-
- if (info.is_directory) {
+ 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.
@@ -136,6 +106,12 @@ void DirectoryImpl::OpenFileHandle(const mojo::String& raw_path,
return;
}
+ base::File base_file(path, open_flags);
+ if (!base_file.IsValid()) {
+ callback.Run(GetError(base_file), ScopedHandle());
+ return;
+ }
+
MojoHandle mojo_handle;
MojoResult create_result = MojoCreatePlatformHandleWrapper(
base_file.TakePlatformFile(), &mojo_handle);
« no previous file with comments | « no previous file | components/filesystem/lock_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698