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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // on a worker thread. | 173 // on a worker thread. |
174 // The |context| parameter is a pointer to the current Context instance. It | 174 // The |context| parameter is a pointer to the current Context instance. It |
175 // is safe to pass this as is to the pool as the Context instance should | 175 // is safe to pass this as is to the pool as the Context instance should |
176 // remain valid until the pending Read operation completes. | 176 // remain valid until the pending Read operation completes. |
177 // The |file| parameter is the handle to the file being read. | 177 // The |file| parameter is the handle to the file being read. |
178 // The |buf| parameter is the buffer where we want the ReadFile to read the | 178 // The |buf| parameter is the buffer where we want the ReadFile to read the |
179 // data into. | 179 // data into. |
180 // The |buf_len| parameter contains the number of bytes to be read. | 180 // The |buf_len| parameter contains the number of bytes to be read. |
181 // The |overlapped| parameter is a pointer to the OVERLAPPED structure being | 181 // The |overlapped| parameter is a pointer to the OVERLAPPED structure being |
182 // used. | 182 // used. |
183 // The |origin_thread_loop| is a MessageLoopProxy instance used to post tasks | 183 // The |origin_thread_loop| is a SingleThreadTaskRunner instance used to post |
184 // back to the originating thread. | 184 // tasks back to the originating thread. |
185 static void ReadAsync( | 185 static void ReadAsync( |
186 FileStream::Context* context, | 186 FileStream::Context* context, |
187 HANDLE file, | 187 HANDLE file, |
188 scoped_refptr<IOBuffer> buf, | 188 scoped_refptr<IOBuffer> buf, |
189 int buf_len, | 189 int buf_len, |
190 OVERLAPPED* overlapped, | 190 OVERLAPPED* overlapped, |
191 scoped_refptr<base::MessageLoopProxy> origin_thread_loop); | 191 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_loop); |
192 | 192 |
193 // This callback executes on the main calling thread. It informs the caller | 193 // This callback executes on the main calling thread. It informs the caller |
194 // about the result of the ReadFile call. | 194 // about the result of the ReadFile call. |
195 // The |read_file_ret| parameter contains the return value of the ReadFile | 195 // The |read_file_ret| parameter contains the return value of the ReadFile |
196 // call. | 196 // call. |
197 // The |bytes_read| contains the number of bytes read from the file, if | 197 // The |bytes_read| contains the number of bytes read from the file, if |
198 // ReadFile succeeds. | 198 // ReadFile succeeds. |
199 // The |os_error| parameter contains the value of the last error returned by | 199 // The |os_error| parameter contains the value of the last error returned by |
200 // the ReadFile API. | 200 // the ReadFile API. |
201 void ReadAsyncResult(BOOL read_file_ret, DWORD bytes_read, DWORD os_error); | 201 void ReadAsyncResult(BOOL read_file_ret, DWORD bytes_read, DWORD os_error); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Tracks the result of the IO completion operation. Set in OnIOComplete. | 233 // Tracks the result of the IO completion operation. Set in OnIOComplete. |
234 int result_; | 234 int result_; |
235 #endif | 235 #endif |
236 | 236 |
237 DISALLOW_COPY_AND_ASSIGN(Context); | 237 DISALLOW_COPY_AND_ASSIGN(Context); |
238 }; | 238 }; |
239 | 239 |
240 } // namespace net | 240 } // namespace net |
241 | 241 |
242 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ | 242 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ |
OLD | NEW |