Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: base/files/file.cc

Issue 231703002: Base: Make FileProxy automaticaly close the file on a worker thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix initialization order Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/files/file_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
63 } 65 }
64 66
65 File& File::operator=(RValue other) { 67 File& File::operator=(RValue other) {
66 if (this != other.object) { 68 if (this != other.object) {
67 Close(); 69 Close();
68 SetPlatformFile(other.object->TakePlatformFile()); 70 SetPlatformFile(other.object->TakePlatformFile());
69 error_details_ = other.object->error_details(); 71 error_details_ = other.object->error_details();
70 created_ = other.object->created(); 72 created_ = other.object->created();
71 async_ = other.object->async_; 73 async_ = other.object->async_;
72 } 74 }
73 return *this; 75 return *this;
74 } 76 }
75 77
76 #if !defined(OS_NACL) 78 #if !defined(OS_NACL)
77 void File::Initialize(const FilePath& name, uint32 flags) { 79 void File::Initialize(const FilePath& name, uint32 flags) {
78 if (name.ReferencesParent()) { 80 if (name.ReferencesParent()) {
79 error_details_ = FILE_ERROR_ACCESS_DENIED; 81 error_details_ = FILE_ERROR_ACCESS_DENIED;
80 return; 82 return;
81 } 83 }
82 InitializeUnsafe(name, flags); 84 InitializeUnsafe(name, flags);
83 } 85 }
84 #endif 86 #endif
85 87
86 } // namespace base 88 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/files/file_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698