| 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 #include "net/base/file_stream_context.h" | 5 #include "net/base/file_stream_context.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 FileStream::Context::Context(const scoped_refptr<base::TaskRunner>& task_runner) | 39 FileStream::Context::Context(const scoped_refptr<base::TaskRunner>& task_runner) |
| 40 : async_in_progress_(false), | 40 : async_in_progress_(false), |
| 41 orphaned_(false), | 41 orphaned_(false), |
| 42 task_runner_(task_runner), | 42 task_runner_(task_runner), |
| 43 io_context_(), | 43 io_context_(), |
| 44 async_read_initiated_(false), | 44 async_read_initiated_(false), |
| 45 async_read_completed_(false), | 45 async_read_completed_(false), |
| 46 io_complete_for_read_received_(false), | 46 io_complete_for_read_received_(false), |
| 47 result_(0) { | 47 result_(0) {} |
| 48 io_context_.handler = this; | |
| 49 memset(&io_context_.overlapped, 0, sizeof(io_context_.overlapped)); | |
| 50 } | |
| 51 | 48 |
| 52 FileStream::Context::Context(base::File file, | 49 FileStream::Context::Context(base::File file, |
| 53 const scoped_refptr<base::TaskRunner>& task_runner) | 50 const scoped_refptr<base::TaskRunner>& task_runner) |
| 54 : file_(std::move(file)), | 51 : file_(std::move(file)), |
| 55 async_in_progress_(false), | 52 async_in_progress_(false), |
| 56 orphaned_(false), | 53 orphaned_(false), |
| 57 task_runner_(task_runner), | 54 task_runner_(task_runner), |
| 58 io_context_(), | 55 io_context_(), |
| 59 async_read_initiated_(false), | 56 async_read_initiated_(false), |
| 60 async_read_completed_(false), | 57 async_read_completed_(false), |
| 61 io_complete_for_read_received_(false), | 58 io_complete_for_read_received_(false), |
| 62 result_(0) { | 59 result_(0) { |
| 63 io_context_.handler = this; | |
| 64 memset(&io_context_.overlapped, 0, sizeof(io_context_.overlapped)); | |
| 65 if (file_.IsValid()) { | 60 if (file_.IsValid()) { |
| 66 DCHECK(file_.async()); | 61 DCHECK(file_.async()); |
| 67 OnFileOpened(); | 62 OnFileOpened(); |
| 68 } | 63 } |
| 69 } | 64 } |
| 70 | 65 |
| 71 FileStream::Context::~Context() { | 66 FileStream::Context::~Context() { |
| 72 } | 67 } |
| 73 | 68 |
| 74 int FileStream::Context::Read(IOBuffer* buf, | 69 int FileStream::Context::Read(IOBuffer* buf, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 231 |
| 237 IOResult error = IOResult::FromOSError(os_error); | 232 IOResult error = IOResult::FromOSError(os_error); |
| 238 if (error.os_error == ERROR_IO_PENDING) { | 233 if (error.os_error == ERROR_IO_PENDING) { |
| 239 InvokeUserCallback(); | 234 InvokeUserCallback(); |
| 240 } else { | 235 } else { |
| 241 OnIOCompleted(&io_context_, 0, error.os_error); | 236 OnIOCompleted(&io_context_, 0, error.os_error); |
| 242 } | 237 } |
| 243 } | 238 } |
| 244 | 239 |
| 245 } // namespace net | 240 } // namespace net |
| OLD | NEW |