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.h" | 5 #include "net/base/file_stream.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
8 #include "net/base/file_stream_context.h" | 10 #include "net/base/file_stream_context.h" |
9 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
10 | 12 |
11 namespace net { | 13 namespace net { |
12 | 14 |
13 FileStream::FileStream(const scoped_refptr<base::TaskRunner>& task_runner) | 15 FileStream::FileStream(const scoped_refptr<base::TaskRunner>& task_runner) |
14 : context_(new Context(task_runner)) { | 16 : context_(new Context(task_runner)) { |
15 } | 17 } |
16 | 18 |
17 FileStream::FileStream(base::File file, | 19 FileStream::FileStream(base::File file, |
18 const scoped_refptr<base::TaskRunner>& task_runner) | 20 const scoped_refptr<base::TaskRunner>& task_runner) |
19 : context_(new Context(file.Pass(), task_runner)) { | 21 : context_(new Context(std::move(file), task_runner)) {} |
20 } | |
21 | 22 |
22 FileStream::~FileStream() { | 23 FileStream::~FileStream() { |
23 context_.release()->Orphan(); | 24 context_.release()->Orphan(); |
24 } | 25 } |
25 | 26 |
26 int FileStream::Open(const base::FilePath& path, int open_flags, | 27 int FileStream::Open(const base::FilePath& path, int open_flags, |
27 const CompletionCallback& callback) { | 28 const CompletionCallback& callback) { |
28 if (IsOpen()) { | 29 if (IsOpen()) { |
29 DLOG(FATAL) << "File is already open!"; | 30 DLOG(FATAL) << "File is already open!"; |
30 return ERR_UNEXPECTED; | 31 return ERR_UNEXPECTED; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 81 |
81 int FileStream::Flush(const CompletionCallback& callback) { | 82 int FileStream::Flush(const CompletionCallback& callback) { |
82 if (!IsOpen()) | 83 if (!IsOpen()) |
83 return ERR_UNEXPECTED; | 84 return ERR_UNEXPECTED; |
84 | 85 |
85 context_->Flush(callback); | 86 context_->Flush(callback); |
86 return ERR_IO_PENDING; | 87 return ERR_IO_PENDING; |
87 } | 88 } |
88 | 89 |
89 } // namespace net | 90 } // namespace net |
OLD | NEW |