| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/filesystem/directory_impl.h" | 5 #include "components/filesystem/directory_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 mojom::FileError error = ValidatePath(raw_path, directory_path_, &path); | 217 mojom::FileError error = ValidatePath(raw_path, directory_path_, &path); |
| 218 if (error != mojom::FileError::OK) { | 218 if (error != mojom::FileError::OK) { |
| 219 callback.Run(error, false); | 219 callback.Run(error, false); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 | 222 |
| 223 callback.Run(mojom::FileError::OK, base::PathIsWritable(path)); | 223 callback.Run(mojom::FileError::OK, base::PathIsWritable(path)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void DirectoryImpl::Flush(const FlushCallback& callback) { | 226 void DirectoryImpl::Flush(const FlushCallback& callback) { |
| 227 base::File file(directory_path_, base::File::FLAG_READ); | 227 base::File file(directory_path_, |
| 228 base::File::FLAG_OPEN | base::File::FLAG_READ); |
| 228 if (!file.IsValid()) { | 229 if (!file.IsValid()) { |
| 229 callback.Run(GetError(file)); | 230 callback.Run(GetError(file)); |
| 230 return; | 231 return; |
| 231 } | 232 } |
| 232 | 233 |
| 233 if (!file.Flush()) { | 234 if (!file.Flush()) { |
| 234 callback.Run(mojom::FileError::FAILED); | 235 callback.Run(mojom::FileError::FAILED); |
| 235 return; | 236 return; |
| 236 } | 237 } |
| 237 | 238 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // We must not return directories as files. In the file abstraction, we | 347 // We must not return directories as files. In the file abstraction, we |
| 347 // can fetch raw file descriptors over mojo pipes, and passing a file | 348 // can fetch raw file descriptors over mojo pipes, and passing a file |
| 348 // descriptor to a directory is a sandbox escape on Windows. | 349 // descriptor to a directory is a sandbox escape on Windows. |
| 349 return base::File(base::File::FILE_ERROR_NOT_A_FILE); | 350 return base::File(base::File::FILE_ERROR_NOT_A_FILE); |
| 350 } | 351 } |
| 351 | 352 |
| 352 return base::File(path, open_flags); | 353 return base::File(path, open_flags); |
| 353 } | 354 } |
| 354 | 355 |
| 355 } // namespace filesystem | 356 } // namespace filesystem |
| OLD | NEW |