| 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 |
| 11 // to be able to do and finish all async operations even when FileStream | 11 // to be able to do and finish all async operations even when FileStream |
| 12 // instance is deleted. So FileStream's destructor can schedule file | 12 // instance is deleted. So FileStream's destructor can schedule file |
| 13 // closing to be done by Context in WorkerPool (or the TaskRunner passed to | 13 // closing to be done by Context in WorkerPool (or the TaskRunner passed to |
| 14 // constructor) and then just return (releasing Context pointer from | 14 // constructor) and then just return (releasing Context pointer from |
| 15 // scoped_ptr) without waiting for actual closing to complete. | 15 // scoped_ptr) without waiting for actual closing to complete. |
| 16 // Implementation of FileStream::Context is divided in two parts: some methods | 16 // Implementation of FileStream::Context is divided in two parts: some methods |
| 17 // and members are platform-independent and some depend on the platform. This | 17 // and members are platform-independent and some depend on the platform. This |
| 18 // header file contains the complete definition of Context class including all | 18 // header file contains the complete definition of Context class including all |
| 19 // platform-dependent parts (because of that it has a lot of #if-#else | 19 // platform-dependent parts (because of that it has a lot of #if-#else |
| 20 // branching). Implementations of all platform-independent methods are | 20 // branching). Implementations of all platform-independent methods are |
| 21 // located in file_stream_context.cc, and all platform-dependent methods are | 21 // located in file_stream_context.cc, and all platform-dependent methods are |
| 22 // in file_stream_context_{win,posix}.cc. This separation provides better | 22 // in file_stream_context_{win,posix}.cc. This separation provides better |
| 23 // readability of Context's code. And we tried to make as much Context code | 23 // readability of Context's code. And we tried to make as much Context code |
| 24 // platform-independent as possible. So file_stream_context_{win,posix}.cc are | 24 // platform-independent as possible. So file_stream_context_{win,posix}.cc are |
| 25 // much smaller than file_stream_context.cc now. | 25 // much smaller than file_stream_context.cc now. |
| 26 | 26 |
| 27 #ifndef NET_BASE_FILE_STREAM_CONTEXT_H_ | 27 #ifndef NET_BASE_FILE_STREAM_CONTEXT_H_ |
| 28 #define NET_BASE_FILE_STREAM_CONTEXT_H_ | 28 #define NET_BASE_FILE_STREAM_CONTEXT_H_ |
| 29 | 29 |
| 30 #include <stdint.h> |
| 31 |
| 30 #include "base/files/file.h" | 32 #include "base/files/file.h" |
| 33 #include "base/macros.h" |
| 31 #include "base/memory/weak_ptr.h" | 34 #include "base/memory/weak_ptr.h" |
| 32 #include "base/message_loop/message_loop.h" | 35 #include "base/message_loop/message_loop.h" |
| 33 #include "base/move.h" | 36 #include "base/move.h" |
| 34 #include "base/single_thread_task_runner.h" | 37 #include "base/single_thread_task_runner.h" |
| 35 #include "base/task_runner.h" | 38 #include "base/task_runner.h" |
| 36 #include "net/base/completion_callback.h" | 39 #include "net/base/completion_callback.h" |
| 37 #include "net/base/file_stream.h" | 40 #include "net/base/file_stream.h" |
| 38 | 41 |
| 39 #if defined(OS_POSIX) | 42 #if defined(OS_POSIX) |
| 40 #include <errno.h> | 43 #include <errno.h> |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Tracks the result of the IO completion operation. Set in OnIOComplete. | 236 // Tracks the result of the IO completion operation. Set in OnIOComplete. |
| 234 int result_; | 237 int result_; |
| 235 #endif | 238 #endif |
| 236 | 239 |
| 237 DISALLOW_COPY_AND_ASSIGN(Context); | 240 DISALLOW_COPY_AND_ASSIGN(Context); |
| 238 }; | 241 }; |
| 239 | 242 |
| 240 } // namespace net | 243 } // namespace net |
| 241 | 244 |
| 242 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ | 245 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ |
| OLD | NEW |