| 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 "net/base/file_stream_context.h" | 8 #include "net/base/file_stream_context.h" |
| 8 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 9 | 10 |
| 10 namespace net { | 11 namespace net { |
| 11 | 12 |
| 12 FileStream::FileStream(const scoped_refptr<base::TaskRunner>& task_runner) | 13 FileStream::FileStream(const scoped_refptr<base::TaskRunner>& task_runner) |
| 13 : context_(new Context(task_runner)) { | 14 : context_(new Context(task_runner)) { |
| 14 } | 15 } |
| 15 | 16 |
| 16 FileStream::FileStream(base::File file, | 17 FileStream::FileStream(base::File file, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 if (!IsOpen()) | 50 if (!IsOpen()) |
| 50 return ERR_UNEXPECTED; | 51 return ERR_UNEXPECTED; |
| 51 | 52 |
| 52 context_->Seek(whence, offset, callback); | 53 context_->Seek(whence, offset, callback); |
| 53 return ERR_IO_PENDING; | 54 return ERR_IO_PENDING; |
| 54 } | 55 } |
| 55 | 56 |
| 56 int FileStream::Read(IOBuffer* buf, | 57 int FileStream::Read(IOBuffer* buf, |
| 57 int buf_len, | 58 int buf_len, |
| 58 const CompletionCallback& callback) { | 59 const CompletionCallback& callback) { |
| 60 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 61 tracked_objects::ScopedTracker tracking_profile( |
| 62 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 FileStream::Read")); |
| 63 |
| 59 if (!IsOpen()) | 64 if (!IsOpen()) |
| 60 return ERR_UNEXPECTED; | 65 return ERR_UNEXPECTED; |
| 61 | 66 |
| 62 // read(..., 0) will return 0, which indicates end-of-file. | 67 // read(..., 0) will return 0, which indicates end-of-file. |
| 63 DCHECK_GT(buf_len, 0); | 68 DCHECK_GT(buf_len, 0); |
| 64 | 69 |
| 65 return context_->Read(buf, buf_len, callback); | 70 return context_->Read(buf, buf_len, callback); |
| 66 } | 71 } |
| 67 | 72 |
| 68 int FileStream::Write(IOBuffer* buf, | 73 int FileStream::Write(IOBuffer* buf, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 81 | 86 |
| 82 context_->Flush(callback); | 87 context_->Flush(callback); |
| 83 return ERR_IO_PENDING; | 88 return ERR_IO_PENDING; |
| 84 } | 89 } |
| 85 | 90 |
| 86 const base::File& FileStream::GetFileForTesting() const { | 91 const base::File& FileStream::GetFileForTesting() const { |
| 87 return context_->file(); | 92 return context_->file(); |
| 88 } | 93 } |
| 89 | 94 |
| 90 } // namespace net | 95 } // namespace net |
| OLD | NEW |