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

Side by Side Diff: components/filesystem/directory_impl.cc

Issue 2604843002: Fix crash in DirectoryImpl::Flush() (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/filesystem/directory_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | components/filesystem/directory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698