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