| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // POSIX-specific semantics: | 258 // POSIX-specific semantics: |
| 259 // * Locks are advisory only. | 259 // * Locks are advisory only. |
| 260 // * Within a process, locking the same file (by the same or new handle) | 260 // * Within a process, locking the same file (by the same or new handle) |
| 261 // will succeed. | 261 // will succeed. |
| 262 // * Closing any descriptor on a given file releases the lock. | 262 // * Closing any descriptor on a given file releases the lock. |
| 263 Error Lock(); | 263 Error Lock(); |
| 264 | 264 |
| 265 // Unlock a file previously locked. | 265 // Unlock a file previously locked. |
| 266 Error Unlock(); | 266 Error Unlock(); |
| 267 | 267 |
| 268 bool async() const { return async_; } |
| 269 |
| 268 #if defined(OS_WIN) | 270 #if defined(OS_WIN) |
| 269 static Error OSErrorToFileError(DWORD last_error); | 271 static Error OSErrorToFileError(DWORD last_error); |
| 270 #elif defined(OS_POSIX) | 272 #elif defined(OS_POSIX) |
| 271 static Error OSErrorToFileError(int saved_errno); | 273 static Error OSErrorToFileError(int saved_errno); |
| 272 #endif | 274 #endif |
| 273 | 275 |
| 274 private: | 276 private: |
| 275 void SetPlatformFile(PlatformFile file); | 277 void SetPlatformFile(PlatformFile file); |
| 276 | 278 |
| 277 #if defined(OS_WIN) | 279 #if defined(OS_WIN) |
| 278 win::ScopedHandle file_; | 280 win::ScopedHandle file_; |
| 279 #elif defined(OS_POSIX) | 281 #elif defined(OS_POSIX) |
| 280 ScopedFD file_; | 282 ScopedFD file_; |
| 281 #endif | 283 #endif |
| 282 | 284 |
| 283 Error error_details_; | 285 Error error_details_; |
| 284 bool created_; | 286 bool created_; |
| 285 bool async_; | 287 bool async_; |
| 286 }; | 288 }; |
| 287 | 289 |
| 288 } // namespace base | 290 } // namespace base |
| 289 | 291 |
| 290 #endif // BASE_FILES_FILE_H_ | 292 #endif // BASE_FILES_FILE_H_ |
| OLD | NEW |