| OLD | NEW |
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // Call this method to open the FileStream synchronously. | 75 // Call this method to open the FileStream synchronously. |
| 76 // The remaining methods cannot be used unless this method returns OK. If | 76 // The remaining methods cannot be used unless this method returns OK. If |
| 77 // the file cannot be opened then an error code is returned. open_flags is | 77 // the file cannot be opened then an error code is returned. open_flags is |
| 78 // a bitfield of base::PlatformFileFlags | 78 // a bitfield of base::PlatformFileFlags |
| 79 // | 79 // |
| 80 // If the file stream is not closed manually, the underlying file will be | 80 // If the file stream is not closed manually, the underlying file will be |
| 81 // automatically closed when FileStream is destructed. | 81 // automatically closed when FileStream is destructed. |
| 82 virtual int OpenSync(const base::FilePath& path, int open_flags); | 82 virtual int OpenSync(const base::FilePath& path, int open_flags); |
| 83 | 83 |
| 84 // Returns ERR_IO_PENDING and closes the file asynchronously, calling |
| 85 // |callback| when done. |
| 86 // It is invalid to request any asynchronous operations while there is an |
| 87 // in-flight asynchronous operation. |
| 88 virtual int Close(const CompletionCallback& callback); |
| 89 |
| 90 // Closes the file immediately and returns OK. If the file is open |
| 91 // asynchronously, Close(const CompletionCallback&) should be used instead. |
| 92 virtual int CloseSync(); |
| 93 |
| 84 // Returns true if Open succeeded and Close has not been called. | 94 // Returns true if Open succeeded and Close has not been called. |
| 85 virtual bool IsOpen() const; | 95 virtual bool IsOpen() const; |
| 86 | 96 |
| 87 // Adjust the position from where data is read asynchronously. | 97 // Adjust the position from where data is read asynchronously. |
| 88 // Upon success, ERR_IO_PENDING is returned and |callback| will be run | 98 // Upon success, ERR_IO_PENDING is returned and |callback| will be run |
| 89 // on the thread where Seek() was called with the the stream position | 99 // on the thread where Seek() was called with the the stream position |
| 90 // relative to the start of the file. Otherwise, an error code is returned. | 100 // relative to the start of the file. Otherwise, an error code is returned. |
| 91 // It is invalid to request any asynchronous operations while there is an | 101 // It is invalid to request any asynchronous operations while there is an |
| 92 // in-flight asynchronous operation. | 102 // in-flight asynchronous operation. |
| 93 virtual int Seek(Whence whence, int64 offset, | 103 virtual int Seek(Whence whence, int64 offset, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // delaying FileStream's destructor. To perform all that separate object is | 256 // delaying FileStream's destructor. To perform all that separate object is |
| 247 // necessary. | 257 // necessary. |
| 248 scoped_ptr<Context> context_; | 258 scoped_ptr<Context> context_; |
| 249 | 259 |
| 250 DISALLOW_COPY_AND_ASSIGN(FileStream); | 260 DISALLOW_COPY_AND_ASSIGN(FileStream); |
| 251 }; | 261 }; |
| 252 | 262 |
| 253 } // namespace net | 263 } // namespace net |
| 254 | 264 |
| 255 #endif // NET_BASE_FILE_STREAM_H_ | 265 #endif // NET_BASE_FILE_STREAM_H_ |
| OLD | NEW |