OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PLATFORM_FILE_H_ | 5 #ifndef BASE_PLATFORM_FILE_H_ |
6 #define BASE_PLATFORM_FILE_H_ | 6 #define BASE_PLATFORM_FILE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include <windows.h> | 11 #include <windows.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/base_api.h" | 16 #include "base/base_api.h" |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/file_path.h" | 18 #include "base/file_path.h" |
| 19 #include "base/process.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 | 23 |
23 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
24 typedef HANDLE PlatformFile; | 25 typedef HANDLE PlatformFile; |
25 const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; | 26 const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; |
26 #elif defined(OS_POSIX) | 27 #elif defined(OS_POSIX) |
27 typedef int PlatformFile; | 28 typedef int PlatformFile; |
28 const PlatformFile kInvalidPlatformFileValue = -1; | 29 const PlatformFile kInvalidPlatformFileValue = -1; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Flushes the buffers of the given file. | 134 // Flushes the buffers of the given file. |
134 BASE_API bool FlushPlatformFile(PlatformFile file); | 135 BASE_API bool FlushPlatformFile(PlatformFile file); |
135 | 136 |
136 // Touches the given file. | 137 // Touches the given file. |
137 BASE_API bool TouchPlatformFile(PlatformFile file, const Time& last_access_time, | 138 BASE_API bool TouchPlatformFile(PlatformFile file, const Time& last_access_time, |
138 const Time& last_modified_time); | 139 const Time& last_modified_time); |
139 | 140 |
140 // Returns some information for the given file. | 141 // Returns some information for the given file. |
141 BASE_API bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info); | 142 BASE_API bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info); |
142 | 143 |
| 144 // Returns a file handle equivalent to |file| that can be used in |process|. |
| 145 BASE_API PlatformFile GetFileHandleForProcess(PlatformFile file, |
| 146 ProcessHandle process, |
| 147 bool close_source_handle); |
| 148 |
143 // Use this class to pass ownership of a PlatformFile to a receiver that may or | 149 // Use this class to pass ownership of a PlatformFile to a receiver that may or |
144 // may not want to accept it. This class does not own the storage for the | 150 // may not want to accept it. This class does not own the storage for the |
145 // PlatformFile. | 151 // PlatformFile. |
146 // | 152 // |
147 // EXAMPLE: | 153 // EXAMPLE: |
148 // | 154 // |
149 // void MaybeProcessFile(PassPlatformFile pass_file) { | 155 // void MaybeProcessFile(PassPlatformFile pass_file) { |
150 // if (...) { | 156 // if (...) { |
151 // PlatformFile file = pass_file.ReleaseValue(); | 157 // PlatformFile file = pass_file.ReleaseValue(); |
152 // // Now, we are responsible for closing |file|. | 158 // // Now, we are responsible for closing |file|. |
(...skipping 21 matching lines...) Expand all Loading... |
174 return temp; | 180 return temp; |
175 } | 181 } |
176 | 182 |
177 private: | 183 private: |
178 PlatformFile* value_; | 184 PlatformFile* value_; |
179 }; | 185 }; |
180 | 186 |
181 } // namespace base | 187 } // namespace base |
182 | 188 |
183 #endif // BASE_PLATFORM_FILE_H_ | 189 #endif // BASE_PLATFORM_FILE_H_ |
OLD | NEW |