| 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::Context class. | 5 // This file defines FileStream::Context class. |
| 6 // The general design of FileStream is as follows: file_stream.h defines | 6 // The general design of FileStream is as follows: file_stream.h defines |
| 7 // FileStream class which basically is just an "wrapper" not containing any | 7 // FileStream class which basically is just an "wrapper" not containing any |
| 8 // specific implementation details. It re-routes all its method calls to | 8 // specific implementation details. It re-routes all its method calls to |
| 9 // the instance of FileStream::Context (FileStream holds a scoped_ptr to | 9 // the instance of FileStream::Context (FileStream holds a scoped_ptr to |
| 10 // FileStream::Context instance). Context was extracted into a different class | 10 // FileStream::Context instance). Context was extracted into a different class |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // not closed yet. | 102 // not closed yet. |
| 103 void Orphan(); | 103 void Orphan(); |
| 104 | 104 |
| 105 void OpenAsync(const base::FilePath& path, | 105 void OpenAsync(const base::FilePath& path, |
| 106 int open_flags, | 106 int open_flags, |
| 107 const CompletionCallback& callback); | 107 const CompletionCallback& callback); |
| 108 int OpenSync(const base::FilePath& path, int open_flags); | 108 int OpenSync(const base::FilePath& path, int open_flags); |
| 109 | 109 |
| 110 void CloseSync(); | 110 void CloseSync(); |
| 111 | 111 |
| 112 void CloseAsync(const CompletionCallback& callback); |
| 113 |
| 112 void SeekAsync(Whence whence, | 114 void SeekAsync(Whence whence, |
| 113 int64 offset, | 115 int64 offset, |
| 114 const Int64CompletionCallback& callback); | 116 const Int64CompletionCallback& callback); |
| 115 int64 SeekSync(Whence whence, int64 offset); | 117 int64 SeekSync(Whence whence, int64 offset); |
| 116 | 118 |
| 117 void FlushAsync(const CompletionCallback& callback); | 119 void FlushAsync(const CompletionCallback& callback); |
| 118 int FlushSync(); | 120 int FlushSync(); |
| 119 | 121 |
| 120 private: | 122 private: |
| 121 //////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////// |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // Platform-dependent methods implemented in | 186 // Platform-dependent methods implemented in |
| 185 // file_stream_context_{win,posix}.cc. | 187 // file_stream_context_{win,posix}.cc. |
| 186 //////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////// |
| 187 | 189 |
| 188 // Adjusts the position from where the data is read. | 190 // Adjusts the position from where the data is read. |
| 189 IOResult SeekFileImpl(Whence whence, int64 offset); | 191 IOResult SeekFileImpl(Whence whence, int64 offset); |
| 190 | 192 |
| 191 // Flushes all data written to the stream. | 193 // Flushes all data written to the stream. |
| 192 IOResult FlushFileImpl(); | 194 IOResult FlushFileImpl(); |
| 193 | 195 |
| 196 // Closes the file. |
| 197 IOResult CloseFileImpl(); |
| 198 |
| 194 #if defined(OS_WIN) | 199 #if defined(OS_WIN) |
| 195 void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf); | 200 void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf); |
| 196 | 201 |
| 197 // Implementation of MessageLoopForIO::IOHandler. | 202 // Implementation of MessageLoopForIO::IOHandler. |
| 198 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 203 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
| 199 DWORD bytes_read, | 204 DWORD bytes_read, |
| 200 DWORD error) OVERRIDE; | 205 DWORD error) OVERRIDE; |
| 201 #elif defined(OS_POSIX) | 206 #elif defined(OS_POSIX) |
| 202 // ReadFileImpl() is a simple wrapper around read() that handles EINTR | 207 // ReadFileImpl() is a simple wrapper around read() that handles EINTR |
| 203 // signals and calls RecordAndMapError() to map errno to net error codes. | 208 // signals and calls RecordAndMapError() to map errno to net error codes. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 223 FileErrorSource error_source_; | 228 FileErrorSource error_source_; |
| 224 #endif | 229 #endif |
| 225 | 230 |
| 226 DISALLOW_COPY_AND_ASSIGN(Context); | 231 DISALLOW_COPY_AND_ASSIGN(Context); |
| 227 }; | 232 }; |
| 228 | 233 |
| 229 } // namespace net | 234 } // namespace net |
| 230 | 235 |
| 231 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ | 236 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ |
| 232 | 237 |
| OLD | NEW |