| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/location.h" | 14 #include "base/location.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/posix/eintr_wrapper.h" | 16 #include "base/posix/eintr_wrapper.h" |
| 16 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
| 17 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
| 18 #include "base/task_runner_util.h" | 19 #include "base/task_runner_util.h" |
| 19 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 | 24 |
| 24 FileStream::Context::Context(const scoped_refptr<base::TaskRunner>& task_runner) | 25 FileStream::Context::Context(const scoped_refptr<base::TaskRunner>& task_runner) |
| 25 : async_in_progress_(false), | 26 : async_in_progress_(false), |
| 26 orphaned_(false), | 27 orphaned_(false), |
| 27 task_runner_(task_runner) { | 28 task_runner_(task_runner) { |
| 28 } | 29 } |
| 29 | 30 |
| 30 FileStream::Context::Context(base::File file, | 31 FileStream::Context::Context(base::File file, |
| 31 const scoped_refptr<base::TaskRunner>& task_runner) | 32 const scoped_refptr<base::TaskRunner>& task_runner) |
| 32 : file_(file.Pass()), | 33 : file_(std::move(file)), |
| 33 async_in_progress_(false), | 34 async_in_progress_(false), |
| 34 orphaned_(false), | 35 orphaned_(false), |
| 35 task_runner_(task_runner) { | 36 task_runner_(task_runner) {} |
| 36 } | |
| 37 | 37 |
| 38 FileStream::Context::~Context() { | 38 FileStream::Context::~Context() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 int FileStream::Context::Read(IOBuffer* in_buf, | 41 int FileStream::Context::Read(IOBuffer* in_buf, |
| 42 int buf_len, | 42 int buf_len, |
| 43 const CompletionCallback& callback) { | 43 const CompletionCallback& callback) { |
| 44 DCHECK(!async_in_progress_); | 44 DCHECK(!async_in_progress_); |
| 45 | 45 |
| 46 scoped_refptr<IOBuffer> buf = in_buf; | 46 scoped_refptr<IOBuffer> buf = in_buf; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 scoped_refptr<IOBuffer> buf, | 106 scoped_refptr<IOBuffer> buf, |
| 107 int buf_len) { | 107 int buf_len) { |
| 108 int res = file_.WriteAtCurrentPosNoBestEffort(buf->data(), buf_len); | 108 int res = file_.WriteAtCurrentPosNoBestEffort(buf->data(), buf_len); |
| 109 if (res == -1) | 109 if (res == -1) |
| 110 return IOResult::FromOSError(errno); | 110 return IOResult::FromOSError(errno); |
| 111 | 111 |
| 112 return IOResult(res, 0); | 112 return IOResult(res, 0); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace net | 115 } // namespace net |
| OLD | NEW |