| 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 #include "base/files/file.h" | 5 #include "base/files/file.h" |
| 6 | 6 |
| 7 #include <io.h> | 7 #include <io.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 DCHECK(IsValid()); | 242 DCHECK(IsValid()); |
| 243 | 243 |
| 244 SCOPED_FILE_TRACE("Unlock"); | 244 SCOPED_FILE_TRACE("Unlock"); |
| 245 | 245 |
| 246 BOOL result = UnlockFile(file_.Get(), 0, 0, MAXDWORD, MAXDWORD); | 246 BOOL result = UnlockFile(file_.Get(), 0, 0, MAXDWORD, MAXDWORD); |
| 247 if (!result) | 247 if (!result) |
| 248 return OSErrorToFileError(GetLastError()); | 248 return OSErrorToFileError(GetLastError()); |
| 249 return FILE_OK; | 249 return FILE_OK; |
| 250 } | 250 } |
| 251 | 251 |
| 252 File File::Duplicate() { | 252 File File::Duplicate() const { |
| 253 if (!IsValid()) | 253 if (!IsValid()) |
| 254 return File(); | 254 return File(); |
| 255 | 255 |
| 256 SCOPED_FILE_TRACE("Duplicate"); | 256 SCOPED_FILE_TRACE("Duplicate"); |
| 257 | 257 |
| 258 HANDLE other_handle = nullptr; | 258 HANDLE other_handle = nullptr; |
| 259 | 259 |
| 260 if (!::DuplicateHandle(GetCurrentProcess(), // hSourceProcessHandle | 260 if (!::DuplicateHandle(GetCurrentProcess(), // hSourceProcessHandle |
| 261 GetPlatformFile(), | 261 GetPlatformFile(), |
| 262 GetCurrentProcess(), // hTargetProcessHandle | 262 GetCurrentProcess(), // hTargetProcessHandle |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 ThreadRestrictions::AssertIOAllowed(); | 400 ThreadRestrictions::AssertIOAllowed(); |
| 401 DCHECK(IsValid()); | 401 DCHECK(IsValid()); |
| 402 return ::FlushFileBuffers(file_.Get()) != FALSE; | 402 return ::FlushFileBuffers(file_.Get()) != FALSE; |
| 403 } | 403 } |
| 404 | 404 |
| 405 void File::SetPlatformFile(PlatformFile file) { | 405 void File::SetPlatformFile(PlatformFile file) { |
| 406 file_.Set(file); | 406 file_.Set(file); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace base | 409 } // namespace base |
| OLD | NEW |