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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void Seek(base::File::Whence whence, |
96 int64 offset, | 96 int64_t offset, |
97 const Int64CompletionCallback& callback); | 97 const Int64CompletionCallback& callback); |
98 | 98 |
99 void Flush(const CompletionCallback& callback); | 99 void Flush(const CompletionCallback& callback); |
100 | 100 |
101 private: | 101 private: |
102 struct IOResult { | 102 struct IOResult { |
103 IOResult(); | 103 IOResult(); |
104 IOResult(int64 result, logging::SystemErrorCode os_error); | 104 IOResult(int64_t result, logging::SystemErrorCode os_error); |
105 static IOResult FromOSError(logging::SystemErrorCode os_error); | 105 static IOResult FromOSError(logging::SystemErrorCode os_error); |
106 | 106 |
107 int64 result; | 107 int64_t result; |
108 logging::SystemErrorCode os_error; // Set only when result < 0. | 108 logging::SystemErrorCode os_error; // Set only when result < 0. |
109 }; | 109 }; |
110 | 110 |
111 struct OpenResult { | 111 struct OpenResult { |
112 MOVE_ONLY_TYPE_FOR_CPP_03(OpenResult, RValue) | 112 MOVE_ONLY_TYPE_FOR_CPP_03(OpenResult, RValue) |
113 public: | 113 public: |
114 OpenResult(); | 114 OpenResult(); |
115 OpenResult(base::File file, IOResult error_code); | 115 OpenResult(base::File file, IOResult error_code); |
116 // C++03 move emulation of this type. | 116 // C++03 move emulation of this type. |
117 OpenResult(RValue other); | 117 OpenResult(RValue other); |
(...skipping 24 matching lines...) Expand all Loading... |
142 // network error code. | 142 // network error code. |
143 void OnAsyncCompleted(const Int64CompletionCallback& callback, | 143 void OnAsyncCompleted(const Int64CompletionCallback& callback, |
144 const IOResult& result); | 144 const IOResult& result); |
145 | 145 |
146 //////////////////////////////////////////////////////////////////////////// | 146 //////////////////////////////////////////////////////////////////////////// |
147 // Platform-dependent methods implemented in | 147 // Platform-dependent methods implemented in |
148 // file_stream_context_{win,posix}.cc. | 148 // file_stream_context_{win,posix}.cc. |
149 //////////////////////////////////////////////////////////////////////////// | 149 //////////////////////////////////////////////////////////////////////////// |
150 | 150 |
151 // Adjusts the position from where the data is read. | 151 // Adjusts the position from where the data is read. |
152 IOResult SeekFileImpl(base::File::Whence whence, int64 offset); | 152 IOResult SeekFileImpl(base::File::Whence whence, int64_t offset); |
153 | 153 |
154 void OnFileOpened(); | 154 void OnFileOpened(); |
155 | 155 |
156 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
157 void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf); | 157 void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf); |
158 | 158 |
159 // Implementation of MessageLoopForIO::IOHandler. | 159 // Implementation of MessageLoopForIO::IOHandler. |
160 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 160 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
161 DWORD bytes_read, | 161 DWORD bytes_read, |
162 DWORD error) override; | 162 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. | 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 |