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

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

Issue 9949011: Make FileStream::Seek async and add FileStream::SeekSync for sync operation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 8 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 | « net/base/completion_callback.h ('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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // the file cannot be opened then an error code is returned. open_flags is 87 // the file cannot be opened then an error code is returned. open_flags is
88 // a bitfield of base::PlatformFileFlags 88 // a bitfield of base::PlatformFileFlags
89 // 89 //
90 // If the file stream is not closed manually, the underlying file will be 90 // If the file stream is not closed manually, the underlying file will be
91 // automatically closed when FileStream is destructed. 91 // automatically closed when FileStream is destructed.
92 virtual int OpenSync(const FilePath& path, int open_flags); 92 virtual int OpenSync(const FilePath& path, int open_flags);
93 93
94 // Returns true if Open succeeded and Close has not been called. 94 // Returns true if Open succeeded and Close has not been called.
95 virtual bool IsOpen() const; 95 virtual bool IsOpen() const;
96 96
97 // Adjust the position from where data is read. Upon success, the stream 97 // Adjust the position from where data is read asynchronously.
98 // position relative to the start of the file is returned. Otherwise, an 98 // Upon success, ERR_IO_PENDING is returned and |callback| will be run
99 // error code is returned. It is not valid to call Seek while a Read call 99 // on the thread where Seek() was called with the the stream position
100 // has a pending completion. 100 // relative to the start of the file. Otherwise, an error code is returned.
101 virtual int64 Seek(Whence whence, int64 offset); 101 // It is invalid to request any asynchronous operations while there is an
102 // in-flight asynchronous operation.
103 virtual int Seek(Whence whence, int64 offset,
104 const Int64CompletionCallback& callback);
105
106 // Adjust the position from where data is read synchronously.
107 // Upon success, the stream position relative to the start of the file is
108 // returned. Otherwise, an error code is returned. It is not valid to
109 // call SeekSync while a Read call has a pending completion.
110 virtual int64 SeekSync(Whence whence, int64 offset);
102 111
103 // Returns the number of bytes available to read from the current stream 112 // Returns the number of bytes available to read from the current stream
104 // position until the end of the file. Otherwise, an error code is returned. 113 // position until the end of the file. Otherwise, an error code is returned.
105 virtual int64 Available(); 114 virtual int64 Available();
106 115
107 // Call this method to read data from the current stream position 116 // Call this method to read data from the current stream position
108 // asynchronously. Up to buf_len bytes will be copied into buf. (In 117 // asynchronously. Up to buf_len bytes will be copied into buf. (In
109 // other words, partial reads are allowed.) Returns the number of bytes 118 // other words, partial reads are allowed.) Returns the number of bytes
110 // copied, 0 if at end-of-file, or an error code if the operation could 119 // copied, 0 if at end-of-file, or an error code if the operation could
111 // not be performed. 120 // not be performed.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 #elif defined(OS_POSIX) 222 #elif defined(OS_POSIX)
214 FileStreamPosix impl_; 223 FileStreamPosix impl_;
215 #endif 224 #endif
216 225
217 DISALLOW_COPY_AND_ASSIGN(FileStream); 226 DISALLOW_COPY_AND_ASSIGN(FileStream);
218 }; 227 };
219 228
220 } // namespace net 229 } // namespace net
221 230
222 #endif // NET_BASE_FILE_STREAM_H_ 231 #endif // NET_BASE_FILE_STREAM_H_
OLDNEW
« no previous file with comments | « net/base/completion_callback.h ('k') | net/base/file_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698