| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return file_ >= 0; | 210 return file_ >= 0; |
| 211 } | 211 } |
| 212 | 212 |
| 213 PlatformFile File::TakePlatformFile() { | 213 PlatformFile File::TakePlatformFile() { |
| 214 PlatformFile file = file_; | 214 PlatformFile file = file_; |
| 215 file_ = kInvalidPlatformFileValue; | 215 file_ = kInvalidPlatformFileValue; |
| 216 return file; | 216 return file; |
| 217 } | 217 } |
| 218 | 218 |
| 219 void File::Close() { | 219 void File::Close() { |
| 220 base::ThreadRestrictions::AssertIOAllowed(); | |
| 221 if (!IsValid()) | 220 if (!IsValid()) |
| 222 return; | 221 return; |
| 223 | 222 |
| 223 base::ThreadRestrictions::AssertIOAllowed(); |
| 224 if (!IGNORE_EINTR(close(file_))) | 224 if (!IGNORE_EINTR(close(file_))) |
| 225 file_ = kInvalidPlatformFileValue; | 225 file_ = kInvalidPlatformFileValue; |
| 226 } | 226 } |
| 227 | 227 |
| 228 int64 File::Seek(Whence whence, int64 offset) { | 228 int64 File::Seek(Whence whence, int64 offset) { |
| 229 base::ThreadRestrictions::AssertIOAllowed(); | 229 base::ThreadRestrictions::AssertIOAllowed(); |
| 230 DCHECK(IsValid()); | 230 DCHECK(IsValid()); |
| 231 if (file_ < 0 || offset < 0) | 231 if (file_ < 0 || offset < 0) |
| 232 return -1; | 232 return -1; |
| 233 | 233 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 return FILE_ERROR_FAILED; | 471 return FILE_ERROR_FAILED; |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 | 474 |
| 475 void File::SetPlatformFile(PlatformFile file) { | 475 void File::SetPlatformFile(PlatformFile file) { |
| 476 DCHECK_EQ(file_, kInvalidPlatformFileValue); | 476 DCHECK_EQ(file_, kInvalidPlatformFileValue); |
| 477 file_ = file; | 477 file_ = file; |
| 478 } | 478 } |
| 479 | 479 |
| 480 } // namespace base | 480 } // namespace base |
| OLD | NEW |