| 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 15 matching lines...) Expand all Loading... |
| 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> | 30 #include <stdint.h> |
| 31 | 31 |
| 32 #include "base/files/file.h" | 32 #include "base/files/file.h" |
| 33 #include "base/macros.h" | 33 #include "base/macros.h" |
| 34 #include "base/memory/weak_ptr.h" | 34 #include "base/memory/weak_ptr.h" |
| 35 #include "base/message_loop/message_loop.h" | 35 #include "base/message_loop/message_loop.h" |
| 36 #include "base/move.h" |
| 36 #include "base/single_thread_task_runner.h" | 37 #include "base/single_thread_task_runner.h" |
| 37 #include "base/task_runner.h" | 38 #include "base/task_runner.h" |
| 38 #include "net/base/completion_callback.h" | 39 #include "net/base/completion_callback.h" |
| 39 #include "net/base/file_stream.h" | 40 #include "net/base/file_stream.h" |
| 40 | 41 |
| 41 #if defined(OS_POSIX) | 42 #if defined(OS_POSIX) |
| 42 #include <errno.h> | 43 #include <errno.h> |
| 43 #endif | 44 #endif |
| 44 | 45 |
| 45 namespace base { | 46 namespace base { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 struct IOResult { | 106 struct IOResult { |
| 106 IOResult(); | 107 IOResult(); |
| 107 IOResult(int64_t result, logging::SystemErrorCode os_error); | 108 IOResult(int64_t result, logging::SystemErrorCode os_error); |
| 108 static IOResult FromOSError(logging::SystemErrorCode os_error); | 109 static IOResult FromOSError(logging::SystemErrorCode os_error); |
| 109 | 110 |
| 110 int64_t result; | 111 int64_t result; |
| 111 logging::SystemErrorCode os_error; // Set only when result < 0. | 112 logging::SystemErrorCode os_error; // Set only when result < 0. |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 struct OpenResult { | 115 struct OpenResult { |
| 116 MOVE_ONLY_TYPE_FOR_CPP_03(OpenResult) |
| 115 public: | 117 public: |
| 116 OpenResult(); | 118 OpenResult(); |
| 117 OpenResult(base::File file, IOResult error_code); | 119 OpenResult(base::File file, IOResult error_code); |
| 118 OpenResult(OpenResult&& other); | 120 OpenResult(OpenResult&& other); |
| 119 OpenResult& operator=(OpenResult&& other); | 121 OpenResult& operator=(OpenResult&& other); |
| 120 | 122 |
| 121 base::File file; | 123 base::File file; |
| 122 IOResult error_code; | 124 IOResult error_code; |
| 123 | |
| 124 private: | |
| 125 DISALLOW_COPY_AND_ASSIGN(OpenResult); | |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 //////////////////////////////////////////////////////////////////////////// | 127 //////////////////////////////////////////////////////////////////////////// |
| 129 // Platform-independent methods implemented in file_stream_context.cc. | 128 // Platform-independent methods implemented in file_stream_context.cc. |
| 130 //////////////////////////////////////////////////////////////////////////// | 129 //////////////////////////////////////////////////////////////////////////// |
| 131 | 130 |
| 132 OpenResult OpenFileImpl(const base::FilePath& path, int open_flags); | 131 OpenResult OpenFileImpl(const base::FilePath& path, int open_flags); |
| 133 | 132 |
| 134 IOResult CloseFileImpl(); | 133 IOResult CloseFileImpl(); |
| 135 | 134 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // Tracks the result of the IO completion operation. Set in OnIOComplete. | 236 // Tracks the result of the IO completion operation. Set in OnIOComplete. |
| 238 int result_; | 237 int result_; |
| 239 #endif | 238 #endif |
| 240 | 239 |
| 241 DISALLOW_COPY_AND_ASSIGN(Context); | 240 DISALLOW_COPY_AND_ASSIGN(Context); |
| 242 }; | 241 }; |
| 243 | 242 |
| 244 } // namespace net | 243 } // namespace net |
| 245 | 244 |
| 246 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ | 245 #endif // NET_BASE_FILE_STREAM_CONTEXT_H_ |
| OLD | NEW |