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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // deferred if some asynchronous operation is now in progress or if file is | 85 // deferred if some asynchronous operation is now in progress or if file is |
86 // not closed yet. | 86 // not closed yet. |
87 void Orphan(); | 87 void Orphan(); |
88 | 88 |
89 void Open(const base::FilePath& path, | 89 void Open(const base::FilePath& path, |
90 int open_flags, | 90 int open_flags, |
91 const CompletionCallback& callback); | 91 const CompletionCallback& callback); |
92 | 92 |
93 void Close(const CompletionCallback& callback); | 93 void Close(const CompletionCallback& callback); |
94 | 94 |
95 void Seek(base::File::Whence whence, | 95 // Seeks |offset| bytes from the start of the file. |
96 int64 offset, | 96 void Seek(int64 offset, const Int64CompletionCallback& callback); |
97 const Int64CompletionCallback& callback); | |
98 | 97 |
99 void Flush(const CompletionCallback& callback); | 98 void Flush(const CompletionCallback& callback); |
100 | 99 |
101 private: | 100 private: |
102 struct IOResult { | 101 struct IOResult { |
103 IOResult(); | 102 IOResult(); |
104 IOResult(int64 result, logging::SystemErrorCode os_error); | 103 IOResult(int64 result, logging::SystemErrorCode os_error); |
105 static IOResult FromOSError(logging::SystemErrorCode os_error); | 104 static IOResult FromOSError(logging::SystemErrorCode os_error); |
106 | 105 |
107 int64 result; | 106 int64 result; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // network error code. | 141 // network error code. |
143 void OnAsyncCompleted(const Int64CompletionCallback& callback, | 142 void OnAsyncCompleted(const Int64CompletionCallback& callback, |
144 const IOResult& result); | 143 const IOResult& result); |
145 | 144 |
146 //////////////////////////////////////////////////////////////////////////// | 145 //////////////////////////////////////////////////////////////////////////// |
147 // Platform-dependent methods implemented in | 146 // Platform-dependent methods implemented in |
148 // file_stream_context_{win,posix}.cc. | 147 // file_stream_context_{win,posix}.cc. |
149 //////////////////////////////////////////////////////////////////////////// | 148 //////////////////////////////////////////////////////////////////////////// |
150 | 149 |
151 // Adjusts the position from where the data is read. | 150 // Adjusts the position from where the data is read. |
152 IOResult SeekFileImpl(base::File::Whence whence, int64 offset); | 151 IOResult SeekFileImpl(int64 offset); |
153 | 152 |
154 void OnFileOpened(); | 153 void OnFileOpened(); |
155 | 154 |
156 #if defined(OS_WIN) | 155 #if defined(OS_WIN) |
157 void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf); | 156 void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf); |
158 | 157 |
159 // Implementation of MessageLoopForIO::IOHandler. | 158 // Implementation of MessageLoopForIO::IOHandler. |
160 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 159 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
161 DWORD bytes_read, | 160 DWORD bytes_read, |
162 DWORD error) override; | 161 DWORD error) override; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Tracks the result of the IO completion operation. Set in OnIOComplete. | 232 // Tracks the result of the IO completion operation. Set in OnIOComplete. |
234 int result_; | 233 int result_; |
235 #endif | 234 #endif |
236 | 235 |
237 DISALLOW_COPY_AND_ASSIGN(Context); | 236 DISALLOW_COPY_AND_ASSIGN(Context); |
238 }; | 237 }; |
239 | 238 |
240 } // namespace net | 239 } // namespace net |
241 | 240 |
242 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ | 241 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ |
OLD | NEW |