| 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 29 matching lines...) Expand all Loading... |
| 40 // |flags| is a bitfield of base::PlatformFileFlags when the file handle was | 40 // |flags| is a bitfield of base::PlatformFileFlags when the file handle was |
| 41 // opened. | 41 // opened. |
| 42 // |net_log| is the net log pointer to use to create a |BoundNetLog|. May be | 42 // |net_log| is the net log pointer to use to create a |BoundNetLog|. May be |
| 43 // NULL if logging is not needed. | 43 // NULL if logging is not needed. |
| 44 // The already opened file will not be automatically closed when FileStream | 44 // The already opened file will not be automatically closed when FileStream |
| 45 // is destructed. | 45 // is destructed. |
| 46 FileStream(base::PlatformFile file, int flags, net::NetLog* net_log); | 46 FileStream(base::PlatformFile file, int flags, net::NetLog* net_log); |
| 47 | 47 |
| 48 virtual ~FileStream(); | 48 virtual ~FileStream(); |
| 49 | 49 |
| 50 // Call this method to close the FileStream. It is OK to call Close | 50 // Call this method to close the FileStream synchronously. |
| 51 // multiple times. Redundant calls are ignored. | 51 // It is OK to call Close multiple times. Redundant calls are ignored. |
| 52 // Note that if there are any pending async operations, they'll be aborted. | 52 // Note that if there are any pending async operations, they'll be aborted. |
| 53 virtual void Close(); | 53 // |
| 54 // TODO(satorux): Implement the asynchronous version of this. |
| 55 virtual void CloseSync(); |
| 54 | 56 |
| 55 // Call this method to open the FileStream. The remaining methods | 57 // Call this method to open the FileStream synchronously. |
| 56 // cannot be used unless this method returns OK. If the file cannot be | 58 // The remaining methods cannot be used unless this method returns OK. If |
| 57 // opened then an error code is returned. | 59 // the file cannot be opened then an error code is returned. open_flags is |
| 58 // open_flags is a bitfield of base::PlatformFileFlags | 60 // a bitfield of base::PlatformFileFlags |
| 59 virtual int Open(const FilePath& path, int open_flags); | 61 // |
| 62 // TODO(satorux): Implement the asynchronous version of this. |
| 63 virtual int OpenSync(const FilePath& path, int open_flags); |
| 60 | 64 |
| 61 // Returns true if Open succeeded and Close has not been called. | 65 // Returns true if Open succeeded and Close has not been called. |
| 62 virtual bool IsOpen() const; | 66 virtual bool IsOpen() const; |
| 63 | 67 |
| 64 // Adjust the position from where data is read. Upon success, the stream | 68 // Adjust the position from where data is read. Upon success, the stream |
| 65 // position relative to the start of the file is returned. Otherwise, an | 69 // position relative to the start of the file is returned. Otherwise, an |
| 66 // error code is returned. It is not valid to call Seek while a Read call | 70 // error code is returned. It is not valid to call Seek while a Read call |
| 67 // has a pending completion. | 71 // has a pending completion. |
| 68 virtual int64 Seek(Whence whence, int64 offset); | 72 virtual int64 Seek(Whence whence, int64 offset); |
| 69 | 73 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 bool auto_closed_; | 166 bool auto_closed_; |
| 163 bool record_uma_; | 167 bool record_uma_; |
| 164 net::BoundNetLog bound_net_log_; | 168 net::BoundNetLog bound_net_log_; |
| 165 | 169 |
| 166 DISALLOW_COPY_AND_ASSIGN(FileStream); | 170 DISALLOW_COPY_AND_ASSIGN(FileStream); |
| 167 }; | 171 }; |
| 168 | 172 |
| 169 } // namespace net | 173 } // namespace net |
| 170 | 174 |
| 171 #endif // NET_BASE_FILE_STREAM_H_ | 175 #endif // NET_BASE_FILE_STREAM_H_ |
| OLD | NEW |