OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 NET_DISK_CACHE_OS_FILE_H_ | 5 #ifndef BASE_PLATFORM_FILE_H_ |
6 #define NET_DISK_CACHE_OS_FILE_H_ | 6 #define BASE_PLATFORM_FILE_H_ |
| 7 |
| 8 #include "build/build_config.h" |
| 9 #if defined(OS_WIN) |
| 10 #include <windows.h> |
| 11 #endif |
7 | 12 |
8 #include <string> | 13 #include <string> |
9 | 14 |
10 #include "build/build_config.h" | 15 namespace base { |
11 | |
12 namespace disk_cache { | |
13 | 16 |
14 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
15 #include <windows.h> | 18 typedef HANDLE PlatformFile; |
16 typedef HANDLE OSFile; | 19 const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; |
17 #elif defined(OS_POSIX) | 20 #elif defined(OS_POSIX) |
18 typedef int OSFile; | 21 typedef int PlatformFile; |
19 const OSFile INVALID_HANDLE_VALUE = -1; | 22 const PlatformFile kInvalidPlatformFileValue = -1; |
20 #endif | 23 #endif |
21 | 24 |
22 enum OSFileFlags { | 25 enum PlatformFileFlags { |
23 OS_FILE_OPEN = 1, | 26 PLATFORM_FILE_OPEN = 1, |
24 OS_FILE_CREATE = 2, | 27 PLATFORM_FILE_CREATE = 2, |
25 OS_FILE_OPEN_ALWAYS = 4, // May create a new file. | 28 PLATFORM_FILE_OPEN_ALWAYS = 4, // May create a new file. |
26 OS_FILE_CREATE_ALWAYS = 8, // May overwrite an old file. | 29 PLATFORM_FILE_CREATE_ALWAYS = 8, // May overwrite an old file. |
27 OS_FILE_READ = 16, | 30 PLATFORM_FILE_READ = 16, |
28 OS_FILE_WRITE = 32, | 31 PLATFORM_FILE_WRITE = 32, |
29 OS_FILE_SHARE_READ = 64, | 32 PLATFORM_FILE_EXCLUSIVE_READ = 64, // EXCLUSIVE is opposite of Windows SHARE |
30 OS_FILE_SHARE_WRITE = 128 | 33 PLATFORM_FILE_EXCLUSIVE_WRITE = 128, |
| 34 PLATFORM_FILE_ASYNC = 256 |
31 }; | 35 }; |
32 | 36 |
33 // Creates or open the given file. If OS_FILE_OPEN_ALWAYS is used, and |created| | 37 // Creates or open the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and |
34 // is provided, |created| will be set to true if the file was created or to | 38 // |created| is provided, |created| will be set to true if the file was created |
35 // false in case the file was just opened. | 39 // or to false in case the file was just opened. |
36 OSFile CreateOSFile(const std::wstring& name, int flags, bool* created); | 40 PlatformFile CreatePlatformFile(const std::wstring& name, |
| 41 int flags, |
| 42 bool* created); |
37 | 43 |
38 } // namespace disk_cache | 44 } // namespace base |
39 | 45 |
40 #endif // NET_DISK_CACHE_OS_FILE_H_ | 46 #endif // BASE_PLATFORM_FILE_H_ |
OLD | NEW |