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 #include "base/files/file.h" | 5 #include "base/files/file.h" |
6 | 6 |
7 // TODO(rvargas): remove this (needed for kInvalidPlatformFileValue). | 7 // TODO(rvargas): remove this (needed for kInvalidPlatformFileValue). |
8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 22 matching lines...) Expand all Loading... |
33 async_(false) { | 33 async_(false) { |
34 Initialize(name, flags); | 34 Initialize(name, flags); |
35 } | 35 } |
36 #endif | 36 #endif |
37 | 37 |
38 File::File(PlatformFile platform_file) | 38 File::File(PlatformFile platform_file) |
39 : file_(platform_file), | 39 : file_(platform_file), |
40 error_details_(FILE_OK), | 40 error_details_(FILE_OK), |
41 created_(false), | 41 created_(false), |
42 async_(false) { | 42 async_(false) { |
| 43 #if defined(OS_POSIX) |
| 44 DCHECK_GE(platform_file, -1); |
| 45 #endif |
43 } | 46 } |
44 | 47 |
45 File::File(RValue other) | 48 File::File(RValue other) |
46 : file_(other.object->TakePlatformFile()), | 49 : file_(other.object->TakePlatformFile()), |
47 error_details_(other.object->error_details()), | 50 error_details_(other.object->error_details()), |
48 created_(other.object->created()), | 51 created_(other.object->created()), |
49 async_(other.object->async_) { | 52 async_(other.object->async_) { |
50 } | 53 } |
51 | 54 |
52 File::~File() { | 55 File::~File() { |
53 Close(); | |
54 } | 56 } |
55 | 57 |
56 File& File::operator=(RValue other) { | 58 File& File::operator=(RValue other) { |
57 if (this != other.object) { | 59 if (this != other.object) { |
58 Close(); | 60 Close(); |
59 SetPlatformFile(other.object->TakePlatformFile()); | 61 SetPlatformFile(other.object->TakePlatformFile()); |
60 error_details_ = other.object->error_details(); | 62 error_details_ = other.object->error_details(); |
61 created_ = other.object->created(); | 63 created_ = other.object->created(); |
62 async_ = other.object->async_; | 64 async_ = other.object->async_; |
63 } | 65 } |
64 return *this; | 66 return *this; |
65 } | 67 } |
66 | 68 |
67 #if !defined(OS_NACL) | 69 #if !defined(OS_NACL) |
68 void File::Initialize(const FilePath& name, uint32 flags) { | 70 void File::Initialize(const FilePath& name, uint32 flags) { |
69 if (name.ReferencesParent()) { | 71 if (name.ReferencesParent()) { |
70 error_details_ = FILE_ERROR_ACCESS_DENIED; | 72 error_details_ = FILE_ERROR_ACCESS_DENIED; |
71 return; | 73 return; |
72 } | 74 } |
73 InitializeUnsafe(name, flags); | 75 InitializeUnsafe(name, flags); |
74 } | 76 } |
75 #endif | 77 #endif |
76 | 78 |
77 } // namespace base | 79 } // namespace base |
OLD | NEW |