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 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/file_tracing.h" | 7 #include "base/files/file_tracing.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/timer/elapsed_timer.h" | 9 #include "base/timer/elapsed_timer.h" |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 error_details_(other.object->error_details()), | 56 error_details_(other.object->error_details()), |
57 created_(other.object->created()), | 57 created_(other.object->created()), |
58 async_(other.object->async_) { | 58 async_(other.object->async_) { |
59 } | 59 } |
60 | 60 |
61 File::~File() { | 61 File::~File() { |
62 // Go through the AssertIOAllowed logic. | 62 // Go through the AssertIOAllowed logic. |
63 Close(); | 63 Close(); |
64 } | 64 } |
65 | 65 |
| 66 // static |
| 67 File File::CreateForAsyncHandle(PlatformFile platform_file) { |
| 68 File file(platform_file); |
| 69 // It would be nice if we could validate that |platform_file| was opened with |
| 70 // FILE_FLAG_OVERLAPPED on Windows but this doesn't appear to be possible. |
| 71 file.async_ = true; |
| 72 return file.Pass(); |
| 73 } |
| 74 |
66 File& File::operator=(RValue other) { | 75 File& File::operator=(RValue other) { |
67 if (this != other.object) { | 76 if (this != other.object) { |
68 Close(); | 77 Close(); |
69 SetPlatformFile(other.object->TakePlatformFile()); | 78 SetPlatformFile(other.object->TakePlatformFile()); |
70 path_ = other.object->path_; | 79 path_ = other.object->path_; |
71 error_details_ = other.object->error_details(); | 80 error_details_ = other.object->error_details(); |
72 created_ = other.object->created(); | 81 created_ = other.object->created(); |
73 async_ = other.object->async_; | 82 async_ = other.object->async_; |
74 } | 83 } |
75 return *this; | 84 return *this; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 142 |
134 bool File::Flush() { | 143 bool File::Flush() { |
135 ElapsedTimer timer; | 144 ElapsedTimer timer; |
136 SCOPED_FILE_TRACE("Flush"); | 145 SCOPED_FILE_TRACE("Flush"); |
137 bool return_value = DoFlush(); | 146 bool return_value = DoFlush(); |
138 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed()); | 147 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed()); |
139 return return_value; | 148 return return_value; |
140 } | 149 } |
141 | 150 |
142 } // namespace base | 151 } // namespace base |
OLD | NEW |