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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 //////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////// |
60 | 60 |
61 explicit Context(const scoped_refptr<base::TaskRunner>& task_runner); | 61 explicit Context(const scoped_refptr<base::TaskRunner>& task_runner); |
62 Context(base::File file, const scoped_refptr<base::TaskRunner>& task_runner); | 62 Context(base::File file, const scoped_refptr<base::TaskRunner>& task_runner); |
63 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
64 virtual ~Context(); | 64 virtual ~Context(); |
65 #elif defined(OS_POSIX) | 65 #elif defined(OS_POSIX) |
66 ~Context(); | 66 ~Context(); |
67 #endif | 67 #endif |
68 | 68 |
69 int ReadAsync(IOBuffer* buf, | 69 int ReadAsync(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
70 int buf_len, | |
71 const CompletionCallback& callback); | |
72 | 70 |
73 int WriteAsync(IOBuffer* buf, | 71 int WriteAsync(IOBuffer* buf, |
74 int buf_len, | 72 int buf_len, |
75 const CompletionCallback& callback); | 73 const CompletionCallback& callback); |
76 | 74 |
77 //////////////////////////////////////////////////////////////////////////// | 75 //////////////////////////////////////////////////////////////////////////// |
78 // Inline methods. | 76 // Inline methods. |
79 //////////////////////////////////////////////////////////////////////////// | 77 //////////////////////////////////////////////////////////////////////////// |
80 | 78 |
81 const base::File& file() const { return file_; } | 79 const base::File& file() const { return file_; } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 136 |
139 void CloseAndDelete(); | 137 void CloseAndDelete(); |
140 | 138 |
141 Int64CompletionCallback IntToInt64(const CompletionCallback& callback); | 139 Int64CompletionCallback IntToInt64(const CompletionCallback& callback); |
142 | 140 |
143 // Called when asynchronous Open() or Seek() | 141 // Called when asynchronous Open() or Seek() |
144 // is completed. |result| contains the result or a network error code. | 142 // is completed. |result| contains the result or a network error code. |
145 void OnAsyncCompleted(const Int64CompletionCallback& callback, | 143 void OnAsyncCompleted(const Int64CompletionCallback& callback, |
146 const IOResult& result); | 144 const IOResult& result); |
147 | 145 |
148 //////////////////////////////////////////////////////////////////////////// | 146 //////////////////////////////////////////////////////////////////////////// |
149 // Helper stuff which is platform-dependent but is used in the platform- | 147 // Helper stuff which is platform-dependent but is used in the platform- |
150 // independent code implemented in file_stream_context.cc. These helpers were | 148 // independent code implemented in file_stream_context.cc. These helpers were |
151 // introduced solely to implement as much of the Context methods as | 149 // introduced solely to implement as much of the Context methods as |
152 // possible independently from platform. | 150 // possible independently from platform. |
153 //////////////////////////////////////////////////////////////////////////// | 151 //////////////////////////////////////////////////////////////////////////// |
154 | 152 |
155 #if defined(OS_WIN) | 153 #if defined(OS_WIN) |
156 int GetLastErrno() { return GetLastError(); } | 154 int GetLastErrno() { return GetLastError(); } |
157 void OnAsyncFileOpened(); | 155 void OnAsyncFileOpened(); |
158 #elif defined(OS_POSIX) | 156 #elif defined(OS_POSIX) |
159 int GetLastErrno() { return errno; } | 157 int GetLastErrno() { return errno; } |
160 void OnAsyncFileOpened() {} | 158 void OnAsyncFileOpened() {} |
161 void CancelIo(base::PlatformFile) {} | 159 void CancelIo(base::PlatformFile) {} |
162 #endif | 160 #endif |
163 | 161 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 CompletionCallback callback_; | 198 CompletionCallback callback_; |
201 scoped_refptr<IOBuffer> in_flight_buf_; | 199 scoped_refptr<IOBuffer> in_flight_buf_; |
202 #endif | 200 #endif |
203 | 201 |
204 DISALLOW_COPY_AND_ASSIGN(Context); | 202 DISALLOW_COPY_AND_ASSIGN(Context); |
205 }; | 203 }; |
206 | 204 |
207 } // namespace net | 205 } // namespace net |
208 | 206 |
209 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ | 207 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ |
OLD | NEW |