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

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

Issue 1407443002: Remove old C++03 move emulation code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: std::move and reflow Created 5 years 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
« no previous file with comments | « base/files/file.h ('k') | base/memory/scoped_vector.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 #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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 DCHECK_GE(platform_file, -1); 43 DCHECK_GE(platform_file, -1);
44 #endif 44 #endif
45 } 45 }
46 46
47 File::File(Error error_details) 47 File::File(Error error_details)
48 : error_details_(error_details), 48 : error_details_(error_details),
49 created_(false), 49 created_(false),
50 async_(false) { 50 async_(false) {
51 } 51 }
52 52
53 File::File(RValue other) 53 File::File(File&& other)
54 : file_(other.object->TakePlatformFile()), 54 : file_(other.TakePlatformFile()),
55 tracing_path_(other.object->tracing_path_), 55 tracing_path_(other.tracing_path_),
56 error_details_(other.object->error_details()), 56 error_details_(other.error_details()),
57 created_(other.object->created()), 57 created_(other.created()),
58 async_(other.object->async_) { 58 async_(other.async_) {}
59 }
60 59
61 File::~File() { 60 File::~File() {
62 // Go through the AssertIOAllowed logic. 61 // Go through the AssertIOAllowed logic.
63 Close(); 62 Close();
64 } 63 }
65 64
66 // static 65 // static
67 File File::CreateForAsyncHandle(PlatformFile platform_file) { 66 File File::CreateForAsyncHandle(PlatformFile platform_file) {
68 File file(platform_file); 67 File file(platform_file);
69 // It would be nice if we could validate that |platform_file| was opened with 68 // 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. 69 // FILE_FLAG_OVERLAPPED on Windows but this doesn't appear to be possible.
71 file.async_ = true; 70 file.async_ = true;
72 return file.Pass(); 71 return file.Pass();
73 } 72 }
74 73
75 File& File::operator=(RValue other) { 74 File& File::operator=(File&& other) {
76 if (this != other.object) { 75 DCHECK_NE(this, &other);
77 Close(); 76 Close();
78 SetPlatformFile(other.object->TakePlatformFile()); 77 SetPlatformFile(other.TakePlatformFile());
79 tracing_path_ = other.object->tracing_path_; 78 tracing_path_ = other.tracing_path_;
80 error_details_ = other.object->error_details(); 79 error_details_ = other.error_details();
81 created_ = other.object->created(); 80 created_ = other.created();
82 async_ = other.object->async_; 81 async_ = other.async_;
83 }
84 return *this; 82 return *this;
85 } 83 }
86 84
87 #if !defined(OS_NACL) 85 #if !defined(OS_NACL)
88 void File::Initialize(const FilePath& path, uint32 flags) { 86 void File::Initialize(const FilePath& path, uint32 flags) {
89 if (path.ReferencesParent()) { 87 if (path.ReferencesParent()) {
90 error_details_ = FILE_ERROR_ACCESS_DENIED; 88 error_details_ = FILE_ERROR_ACCESS_DENIED;
91 return; 89 return;
92 } 90 }
93 if (FileTracing::IsCategoryEnabled()) 91 if (FileTracing::IsCategoryEnabled())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 141
144 bool File::Flush() { 142 bool File::Flush() {
145 ElapsedTimer timer; 143 ElapsedTimer timer;
146 SCOPED_FILE_TRACE("Flush"); 144 SCOPED_FILE_TRACE("Flush");
147 bool return_value = DoFlush(); 145 bool return_value = DoFlush();
148 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed()); 146 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed());
149 return return_value; 147 return return_value;
150 } 148 }
151 149
152 } // namespace base 150 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file.h ('k') | base/memory/scoped_vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698