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 "net/base/file_stream_context.h" | 7 #include "net/base/file_stream_context.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 FileStream::FileStream(base::File file, | 22 FileStream::FileStream(base::File file, |
23 const scoped_refptr<base::TaskRunner>& task_runner) | 23 const scoped_refptr<base::TaskRunner>& task_runner) |
24 : context_(new Context(file.Pass(), task_runner)) { | 24 : context_(new Context(file.Pass(), task_runner)) { |
25 } | 25 } |
26 | 26 |
27 FileStream::~FileStream() { | 27 FileStream::~FileStream() { |
28 context_.release()->Orphan(); | 28 context_.release()->Orphan(); |
29 } | 29 } |
30 | 30 |
31 int FileStream::Open(const base::FilePath& path, int open_flags, | 31 int FileStream::Open(const base::FilePath& path, |
| 32 int open_flags, |
32 const CompletionCallback& callback) { | 33 const CompletionCallback& callback) { |
33 if (IsOpen()) { | 34 if (IsOpen()) { |
34 DLOG(FATAL) << "File is already open!"; | 35 DLOG(FATAL) << "File is already open!"; |
35 return ERR_UNEXPECTED; | 36 return ERR_UNEXPECTED; |
36 } | 37 } |
37 | 38 |
38 DCHECK(open_flags & base::File::FLAG_ASYNC); | 39 DCHECK(open_flags & base::File::FLAG_ASYNC); |
39 context_->OpenAsync(path, open_flags, callback); | 40 context_->OpenAsync(path, open_flags, callback); |
40 return ERR_IO_PENDING; | 41 return ERR_IO_PENDING; |
41 } | 42 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 90 |
90 context_->FlushAsync(callback); | 91 context_->FlushAsync(callback); |
91 return ERR_IO_PENDING; | 92 return ERR_IO_PENDING; |
92 } | 93 } |
93 | 94 |
94 const base::File& FileStream::GetFileForTesting() const { | 95 const base::File& FileStream::GetFileForTesting() const { |
95 return context_->file(); | 96 return context_->file(); |
96 } | 97 } |
97 | 98 |
98 } // namespace net | 99 } // namespace net |
OLD | NEW |