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

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

Issue 1148383003: Only support seeking file streams from the beginning of the file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use static method instead of new constructor. Created 5 years, 7 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 file.async_ = true;
70 return file;
71 }
72
66 File& File::operator=(RValue other) { 73 File& File::operator=(RValue other) {
67 if (this != other.object) { 74 if (this != other.object) {
68 Close(); 75 Close();
69 SetPlatformFile(other.object->TakePlatformFile()); 76 SetPlatformFile(other.object->TakePlatformFile());
70 path_ = other.object->path_; 77 path_ = other.object->path_;
71 error_details_ = other.object->error_details(); 78 error_details_ = other.object->error_details();
72 created_ = other.object->created(); 79 created_ = other.object->created();
73 async_ = other.object->async_; 80 async_ = other.object->async_;
74 } 81 }
75 return *this; 82 return *this;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 140
134 bool File::Flush() { 141 bool File::Flush() {
135 ElapsedTimer timer; 142 ElapsedTimer timer;
136 SCOPED_FILE_TRACE("Flush"); 143 SCOPED_FILE_TRACE("Flush");
137 bool return_value = DoFlush(); 144 bool return_value = DoFlush();
138 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed()); 145 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed());
139 return return_value; 146 return return_value;
140 } 147 }
141 148
142 } // namespace base 149 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698