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