Chromium Code Reviews| 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 // Closes the file. If the file si open asynchronously, returns ERR_IO_PENDING | |
|
Sorin Jianu
2013/09/05 19:59:12
s/si/is/
waffles
2013/09/05 20:31:52
Done.
| |
| 85 // and closes the file asynchronously, calling |callback| when done. | |
| 86 // Otherwise, closes the file immediately and returns OK. | |
| 87 virtual int Close(const CompletionCallback& callback); | |
| 88 | |
| 84 // Returns true if Open succeeded and Close has not been called. | 89 // Returns true if Open succeeded and Close has not been called. |
| 85 virtual bool IsOpen() const; | 90 virtual bool IsOpen() const; |
| 86 | 91 |
| 87 // Adjust the position from where data is read asynchronously. | 92 // Adjust the position from where data is read asynchronously. |
| 88 // Upon success, ERR_IO_PENDING is returned and |callback| will be run | 93 // 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 | 94 // 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. | 95 // 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 | 96 // It is invalid to request any asynchronous operations while there is an |
| 92 // in-flight asynchronous operation. | 97 // in-flight asynchronous operation. |
| 93 virtual int Seek(Whence whence, int64 offset, | 98 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 | 251 // delaying FileStream's destructor. To perform all that separate object is |
| 247 // necessary. | 252 // necessary. |
| 248 scoped_ptr<Context> context_; | 253 scoped_ptr<Context> context_; |
| 249 | 254 |
| 250 DISALLOW_COPY_AND_ASSIGN(FileStream); | 255 DISALLOW_COPY_AND_ASSIGN(FileStream); |
| 251 }; | 256 }; |
| 252 | 257 |
| 253 } // namespace net | 258 } // namespace net |
| 254 | 259 |
| 255 #endif // NET_BASE_FILE_STREAM_H_ | 260 #endif // NET_BASE_FILE_STREAM_H_ |
| OLD | NEW |