Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 created_(false), | 24 created_(false), |
| 25 async_(false) { | 25 async_(false) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 #if !defined(OS_NACL) | 28 #if !defined(OS_NACL) |
| 29 File::File(const FilePath& name, uint32 flags) | 29 File::File(const FilePath& name, uint32 flags) |
| 30 : file_(kInvalidPlatformFileValue), | 30 : file_(kInvalidPlatformFileValue), |
| 31 error_(FILE_OK), | 31 error_(FILE_OK), |
| 32 created_(false), | 32 created_(false), |
| 33 async_(false) { | 33 async_(false) { |
| 34 if (name.ReferencesParent()) { | 34 Initialize(name, flags); |
| 35 error_ = FILE_ERROR_ACCESS_DENIED; | |
| 36 return; | |
| 37 } | |
| 38 CreateBaseFileUnsafe(name, flags); | |
| 39 } | 35 } |
| 40 #endif | 36 #endif |
| 41 | 37 |
| 38 File::File(PlatformFile platform_file) | |
| 39 : file_(platform_file), | |
| 40 error_(FILE_OK), | |
| 41 created_(false), | |
|
cpu_(ooo_6.6-7.5)
2013/12/21 22:59:33
if they pass you a handle then the created_ = true
rvargas (doing something else)
2013/12/27 23:54:39
In this case there is not enough information to de
| |
| 42 async_(false) { | |
| 43 } | |
| 44 | |
| 42 File::File(RValue other) | 45 File::File(RValue other) |
| 43 : file_(other.object->TakePlatformFile()), | 46 : file_(other.object->TakePlatformFile()), |
| 44 error_(other.object->error()), | 47 error_(other.object->error()), |
| 45 created_(other.object->created()), | 48 created_(other.object->created()), |
| 46 async_(other.object->async_) { | 49 async_(other.object->async_) { |
| 47 } | 50 } |
| 48 | 51 |
| 49 File::~File() { | 52 File::~File() { |
| 50 Close(); | 53 Close(); |
| 51 } | 54 } |
| 52 | 55 |
| 53 File& File::operator=(RValue other) { | 56 File& File::operator=(RValue other) { |
| 54 if (this != other.object) { | 57 if (this != other.object) { |
| 55 Close(); | 58 Close(); |
| 56 SetPlatformFile(other.object->TakePlatformFile()); | 59 SetPlatformFile(other.object->TakePlatformFile()); |
| 57 error_ = other.object->error(); | 60 error_ = other.object->error(); |
| 58 created_ = other.object->created(); | 61 created_ = other.object->created(); |
| 59 async_ = other.object->async_; | 62 async_ = other.object->async_; |
| 60 } | 63 } |
| 61 return *this; | 64 return *this; |
| 62 } | 65 } |
| 63 | 66 |
| 67 #if !defined(OS_NACL) | |
| 68 void File::Initialize(const FilePath& name, uint32 flags) { | |
| 69 if (name.ReferencesParent()) { | |
| 70 error_ = FILE_ERROR_ACCESS_DENIED; | |
| 71 return; | |
| 72 } | |
| 73 InitializeUnsafe(name, flags); | |
| 74 } | |
| 75 #endif | |
| 76 | |
| 64 } // namespace base | 77 } // namespace base |
| OLD | NEW |