OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_FILES_FILE_H_ | 5 #ifndef BASE_FILES_FILE_H_ |
6 #define BASE_FILES_FILE_H_ | 6 #define BASE_FILES_FILE_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // * Within a process, locking the same file (by the same or new handle) | 278 // * Within a process, locking the same file (by the same or new handle) |
279 // will succeed. | 279 // will succeed. |
280 // * Closing any descriptor on a given file releases the lock. | 280 // * Closing any descriptor on a given file releases the lock. |
281 Error Lock(); | 281 Error Lock(); |
282 | 282 |
283 // Unlock a file previously locked. | 283 // Unlock a file previously locked. |
284 Error Unlock(); | 284 Error Unlock(); |
285 | 285 |
286 bool async() const { return async_; } | 286 bool async() const { return async_; } |
287 | 287 |
| 288 uint32 flags() const { return flags_; } |
| 289 |
288 #if defined(OS_WIN) | 290 #if defined(OS_WIN) |
289 static Error OSErrorToFileError(DWORD last_error); | 291 static Error OSErrorToFileError(DWORD last_error); |
290 #elif defined(OS_POSIX) | 292 #elif defined(OS_POSIX) |
291 static Error OSErrorToFileError(int saved_errno); | 293 static Error OSErrorToFileError(int saved_errno); |
292 #endif | 294 #endif |
293 | 295 |
294 // Converts an error value to a human-readable form. Used for logging. | 296 // Converts an error value to a human-readable form. Used for logging. |
295 static std::string ErrorToString(Error error); | 297 static std::string ErrorToString(Error error); |
296 | 298 |
297 private: | 299 private: |
298 void SetPlatformFile(PlatformFile file); | 300 void SetPlatformFile(PlatformFile file); |
299 | 301 |
300 #if defined(OS_WIN) | 302 #if defined(OS_WIN) |
301 win::ScopedHandle file_; | 303 win::ScopedHandle file_; |
302 #elif defined(OS_POSIX) | 304 #elif defined(OS_POSIX) |
303 ScopedFD file_; | 305 ScopedFD file_; |
304 #endif | 306 #endif |
305 | 307 |
306 Error error_details_; | 308 Error error_details_; |
307 bool created_; | 309 bool created_; |
308 bool async_; | 310 bool async_; |
| 311 uint32 flags_; |
309 }; | 312 }; |
310 | 313 |
311 } // namespace base | 314 } // namespace base |
312 | 315 |
313 #endif // BASE_FILES_FILE_H_ | 316 #endif // BASE_FILES_FILE_H_ |
OLD | NEW |