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

Side by Side Diff: net/base/file_stream.h

Issue 11030044: Merge 159454 - Flush at the end of local file writing in FileWriter API. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years, 2 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 | « content/browser/download/base_file.cc ('k') | net/base/file_stream.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file defines FileStream, a basic interface for reading and writing files 5 // This file defines FileStream, a basic interface for reading and writing files
6 // synchronously or asynchronously with support for seeking to an offset. 6 // synchronously or asynchronously with support for seeking to an offset.
7 // Note that even when used asynchronously, only one operation is supported at 7 // Note that even when used asynchronously, only one operation is supported at
8 // a time. 8 // a time.
9 9
10 #ifndef NET_BASE_FILE_STREAM_H_ 10 #ifndef NET_BASE_FILE_STREAM_H_
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // position is returned, or a value < 0 on error. 190 // position is returned, or a value < 0 on error.
191 // WARNING: one may not truncate a file beyond its current length on any 191 // WARNING: one may not truncate a file beyond its current length on any
192 // platform with this call. 192 // platform with this call.
193 virtual int64 Truncate(int64 bytes); 193 virtual int64 Truncate(int64 bytes);
194 194
195 // Forces out a filesystem sync on this file to make sure that the file was 195 // Forces out a filesystem sync on this file to make sure that the file was
196 // written out to disk and is not currently sitting in the buffer. This does 196 // written out to disk and is not currently sitting in the buffer. This does
197 // not have to be called, it just forces one to happen at the time of 197 // not have to be called, it just forces one to happen at the time of
198 // calling. 198 // calling.
199 // 199 //
200 /// Returns an error code if the operation could not be performed. 200 // The file must be opened with PLATFORM_FILE_ASYNC, and a non-null
201 // callback must be passed to this method. If the write could not
202 // complete synchronously, then ERR_IO_PENDING is returned, and the
203 // callback will be run on the thread where Flush() was called when
204 // the write has completed.
205 //
206 // It is valid to destroy or close the file stream while there is an
207 // asynchronous flush in progress. That will cancel the flush and allow
208 // the buffer to be freed.
209 //
210 // It is invalid to request any asynchronous operations while there is an
211 // in-flight asynchronous operation.
201 // 212 //
202 // This method should not be called if the stream was opened READ_ONLY. 213 // This method should not be called if the stream was opened READ_ONLY.
203 virtual int Flush(); 214 virtual int Flush(const CompletionCallback& callback);
215
216 // Forces out a filesystem sync on this file to make sure that the file was
217 // written out to disk and is not currently sitting in the buffer. This does
218 // not have to be called, it just forces one to happen at the time of
219 // calling.
220 //
221 // Returns an error code if the operation could not be performed.
222 //
223 // This method should not be called if the stream was opened READ_ONLY.
224 virtual int FlushSync();
204 225
205 // Turns on UMA error statistics gathering. 226 // Turns on UMA error statistics gathering.
206 void EnableErrorStatistics(); 227 void EnableErrorStatistics();
207 228
208 // Sets the source reference for net-internals logging. 229 // Sets the source reference for net-internals logging.
209 // Creates source dependency events between |owner_bound_net_log| and 230 // Creates source dependency events between |owner_bound_net_log| and
210 // |bound_net_log_|. Each gets an event showing the dependency on the other. 231 // |bound_net_log_|. Each gets an event showing the dependency on the other.
211 // If only one of those is valid, it gets an event showing that a change 232 // If only one of those is valid, it gets an event showing that a change
212 // of ownership happened, but without details. 233 // of ownership happened, but without details.
213 void SetBoundNetLogSource(const net::BoundNetLog& owner_bound_net_log); 234 void SetBoundNetLogSource(const net::BoundNetLog& owner_bound_net_log);
214 235
215 // Returns the underlying platform file for testing. 236 // Returns the underlying platform file for testing.
216 base::PlatformFile GetPlatformFileForTesting(); 237 base::PlatformFile GetPlatformFileForTesting();
217 238
218 private: 239 private:
219 #if defined(OS_WIN) 240 #if defined(OS_WIN)
220 FileStreamWin impl_; 241 FileStreamWin impl_;
221 #elif defined(OS_POSIX) 242 #elif defined(OS_POSIX)
222 FileStreamPosix impl_; 243 FileStreamPosix impl_;
223 #endif 244 #endif
224 245
225 DISALLOW_COPY_AND_ASSIGN(FileStream); 246 DISALLOW_COPY_AND_ASSIGN(FileStream);
226 }; 247 };
227 248
228 } // namespace net 249 } // namespace net
229 250
230 #endif // NET_BASE_FILE_STREAM_H_ 251 #endif // NET_BASE_FILE_STREAM_H_
OLDNEW
« no previous file with comments | « content/browser/download/base_file.cc ('k') | net/base/file_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698