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

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

Issue 1624683002: mash: Add a simple, temporary preferences store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky comments Created 4 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 | « components/filesystem/DEPS ('k') | 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 #if defined(OS_WIN) 65 #if defined(OS_WIN)
66 // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. 66 // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory.
67 if (DirectoryExists(path)) 67 if (DirectoryExists(path))
68 open_flags |= base::File::FLAG_BACKUP_SEMANTICS; 68 open_flags |= base::File::FLAG_BACKUP_SEMANTICS;
69 #endif // OS_WIN 69 #endif // OS_WIN
70 70
71 base::File base_file(path, open_flags); 71 base::File base_file(path, open_flags);
72 if (!base_file.IsValid()) { 72 if (!base_file.IsValid()) {
73 callback.Run(FileError::FAILED); 73 callback.Run(GetError(base_file));
74 return; 74 return;
75 } 75 }
76 76
77 base::File::Info info; 77 base::File::Info info;
78 if (!base_file.GetInfo(&info)) { 78 if (!base_file.GetInfo(&info)) {
79 callback.Run(FileError::FAILED); 79 callback.Run(FileError::FAILED);
80 return; 80 return;
81 } 81 }
82 82
83 if (info.is_directory) { 83 if (info.is_directory) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 callback.Run(error, false); 196 callback.Run(error, false);
197 return; 197 return;
198 } 198 }
199 199
200 callback.Run(FileError::OK, base::PathIsWritable(path)); 200 callback.Run(FileError::OK, base::PathIsWritable(path));
201 } 201 }
202 202
203 void DirectoryImpl::Flush(const FlushCallback& callback) { 203 void DirectoryImpl::Flush(const FlushCallback& callback) {
204 base::File file(directory_path_, base::File::FLAG_READ); 204 base::File file(directory_path_, base::File::FLAG_READ);
205 if (!file.IsValid()) { 205 if (!file.IsValid()) {
206 callback.Run(FileError::FAILED); 206 callback.Run(GetError(file));
207 return; 207 return;
208 } 208 }
209 209
210 if (!file.Flush()) { 210 if (!file.Flush()) {
211 callback.Run(FileError::FAILED); 211 callback.Run(FileError::FAILED);
212 return; 212 return;
213 } 213 }
214 214
215 callback.Run(FileError::OK); 215 callback.Run(FileError::OK);
216 } 216 }
217 217
218 } // namespace filesystem 218 } // namespace filesystem
OLDNEW
« no previous file with comments | « components/filesystem/DEPS ('k') | components/filesystem/directory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698