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 "base/profiler/scoped_tracker.h" | 7 #include "base/profiler/scoped_tracker.h" |
8 #include "net/base/file_stream_context.h" | 8 #include "net/base/file_stream_context.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 context_->Open(path, open_flags, callback); | 34 context_->Open(path, open_flags, callback); |
35 return ERR_IO_PENDING; | 35 return ERR_IO_PENDING; |
36 } | 36 } |
37 | 37 |
38 int FileStream::Close(const CompletionCallback& callback) { | 38 int FileStream::Close(const CompletionCallback& callback) { |
39 context_->Close(callback); | 39 context_->Close(callback); |
40 return ERR_IO_PENDING; | 40 return ERR_IO_PENDING; |
41 } | 41 } |
42 | 42 |
43 bool FileStream::IsOpen() const { | 43 bool FileStream::IsOpen() const { |
44 return context_->file().IsValid(); | 44 return context_->IsOpen(); |
45 } | 45 } |
46 | 46 |
47 int FileStream::Seek(base::File::Whence whence, | 47 int FileStream::Seek(int64_t offset, const Int64CompletionCallback& callback) { |
48 int64_t offset, | |
49 const Int64CompletionCallback& callback) { | |
50 if (!IsOpen()) | 48 if (!IsOpen()) |
51 return ERR_UNEXPECTED; | 49 return ERR_UNEXPECTED; |
52 | 50 |
53 context_->Seek(whence, offset, callback); | 51 context_->Seek(offset, callback); |
54 return ERR_IO_PENDING; | 52 return ERR_IO_PENDING; |
55 } | 53 } |
56 | 54 |
57 int FileStream::Read(IOBuffer* buf, | 55 int FileStream::Read(IOBuffer* buf, |
58 int buf_len, | 56 int buf_len, |
59 const CompletionCallback& callback) { | 57 const CompletionCallback& callback) { |
60 // TODO(rvargas): Remove ScopedTracker below once crbug.com/475751 is fixed. | 58 // TODO(rvargas): Remove ScopedTracker below once crbug.com/475751 is fixed. |
61 tracked_objects::ScopedTracker tracking_profile( | 59 tracked_objects::ScopedTracker tracking_profile( |
62 FROM_HERE_WITH_EXPLICIT_FUNCTION("475751 FileStream::Read")); | 60 FROM_HERE_WITH_EXPLICIT_FUNCTION("475751 FileStream::Read")); |
63 | 61 |
(...skipping 17 matching lines...) Expand all Loading... |
81 } | 79 } |
82 | 80 |
83 int FileStream::Flush(const CompletionCallback& callback) { | 81 int FileStream::Flush(const CompletionCallback& callback) { |
84 if (!IsOpen()) | 82 if (!IsOpen()) |
85 return ERR_UNEXPECTED; | 83 return ERR_UNEXPECTED; |
86 | 84 |
87 context_->Flush(callback); | 85 context_->Flush(callback); |
88 return ERR_IO_PENDING; | 86 return ERR_IO_PENDING; |
89 } | 87 } |
90 | 88 |
91 const base::File& FileStream::GetFileForTesting() const { | |
92 return context_->file(); | |
93 } | |
94 | |
95 } // namespace net | 89 } // namespace net |
OLD | NEW |