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

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: Fix Win DBG build by Pass()-ing file out of CreateForAsyncHandle. Created 5 years, 6 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
« no previous file with comments | « base/files/file.h ('k') | chrome/browser/chromeos/drive/local_file_reader.cc » ('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 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 // 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
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
OLDNEW
« no previous file with comments | « base/files/file.h ('k') | chrome/browser/chromeos/drive/local_file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698