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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 File::File(RValue other) | 55 File::File(RValue other) |
56 : file_(other.object->TakePlatformFile()), | 56 : file_(other.object->TakePlatformFile()), |
57 error_details_(other.object->error_details()), | 57 error_details_(other.object->error_details()), |
58 created_(other.object->created()), | 58 created_(other.object->created()), |
59 async_(other.object->async_) { | 59 async_(other.object->async_) { |
60 } | 60 } |
61 | 61 |
62 File::~File() { | 62 File::~File() { |
63 // Go through the AssertIOAllowed logic. | |
64 Close(); | |
65 } | 63 } |
66 | 64 |
67 File& File::operator=(RValue other) { | 65 File& File::operator=(RValue other) { |
68 if (this != other.object) { | 66 if (this != other.object) { |
69 Close(); | 67 Close(); |
70 SetPlatformFile(other.object->TakePlatformFile()); | 68 SetPlatformFile(other.object->TakePlatformFile()); |
71 error_details_ = other.object->error_details(); | 69 error_details_ = other.object->error_details(); |
72 created_ = other.object->created(); | 70 created_ = other.object->created(); |
73 async_ = other.object->async_; | 71 async_ = other.object->async_; |
74 } | 72 } |
75 return *this; | 73 return *this; |
76 } | 74 } |
77 | 75 |
78 #if !defined(OS_NACL) | 76 #if !defined(OS_NACL) |
79 void File::Initialize(const FilePath& name, uint32 flags) { | 77 void File::Initialize(const FilePath& name, uint32 flags) { |
80 if (name.ReferencesParent()) { | 78 if (name.ReferencesParent()) { |
81 error_details_ = FILE_ERROR_ACCESS_DENIED; | 79 error_details_ = FILE_ERROR_ACCESS_DENIED; |
82 return; | 80 return; |
83 } | 81 } |
84 InitializeUnsafe(name, flags); | 82 InitializeUnsafe(name, flags); |
85 } | 83 } |
86 #endif | 84 #endif |
87 | 85 |
88 } // namespace base | 86 } // namespace base |
OLD | NEW |