Chromium Code Reviews| Index: net/base/file_stream.cc |
| diff --git a/net/base/file_stream.cc b/net/base/file_stream.cc |
| index bf56a49e8c011ea7907d68c4268cd6d5e0e2838b..86f33b3c0f2ccf00be4931c93c521acf86fa3c79 100644 |
| --- a/net/base/file_stream.cc |
| +++ b/net/base/file_stream.cc |
| @@ -30,12 +30,12 @@ int FileStream::Open(const base::FilePath& path, int open_flags, |
| } |
| DCHECK(open_flags & base::File::FLAG_ASYNC); |
| - context_->OpenAsync(path, open_flags, callback); |
| + context_->Open(path, open_flags, callback); |
| return ERR_IO_PENDING; |
| } |
| int FileStream::Close(const CompletionCallback& callback) { |
| - context_->CloseAsync(callback); |
| + context_->Close(callback); |
| return ERR_IO_PENDING; |
| } |
| @@ -43,13 +43,13 @@ bool FileStream::IsOpen() const { |
| return context_->file().IsValid(); |
| } |
| -int FileStream::Seek(Whence whence, |
| +int FileStream::Seek(base::File::Whence whence, |
| int64 offset, |
| const Int64CompletionCallback& callback) { |
| if (!IsOpen()) |
| return ERR_UNEXPECTED; |
| - context_->SeekAsync(whence, offset, callback); |
| + context_->Seek(whence, offset, callback); |
| return ERR_IO_PENDING; |
| } |
| @@ -62,7 +62,19 @@ int FileStream::Read(IOBuffer* buf, |
| // read(..., 0) will return 0, which indicates end-of-file. |
| DCHECK_GT(buf_len, 0); |
| - return context_->ReadAsync(buf, buf_len, callback); |
| + return context_->Read(buf, buf_len, callback); |
| +} |
| + |
| +int FileStream::ReadNonBlocking(IOBuffer* buf, |
| + int buf_len, |
| + const CompletionCallback& callback) { |
| + if (!IsOpen()) |
| + return ERR_UNEXPECTED; |
| + |
| + // read(..., 0) will return 0, which indicates end-of-file. |
| + DCHECK_GT(buf_len, 0); |
| + |
| + return context_->ReadNonBlocking(buf, buf_len, callback); |
| } |
| int FileStream::Write(IOBuffer* buf, |
| @@ -74,14 +86,26 @@ int FileStream::Write(IOBuffer* buf, |
| // write(..., 0) will return 0, which indicates end-of-file. |
|
wtc
2014/06/16 23:01:44
This comment is wrong. A write byte count of 0 doe
rvargas (doing something else)
2014/06/18 01:36:38
Done.
|
| DCHECK_GT(buf_len, 0); |
| - return context_->WriteAsync(buf, buf_len, callback); |
| + return context_->Write(buf, buf_len, callback); |
| +} |
| + |
| +int FileStream::WriteNonBlocking(IOBuffer* buf, |
| + int buf_len, |
| + const CompletionCallback& callback) { |
| + if (!IsOpen()) |
| + return ERR_UNEXPECTED; |
| + |
| + // write(..., 0) will return 0, which indicates end-of-file. |
| + DCHECK_GT(buf_len, 0); |
| + |
| + return context_->WriteNonBlocking(buf, buf_len, callback); |
| } |
| int FileStream::Flush(const CompletionCallback& callback) { |
| if (!IsOpen()) |
| return ERR_UNEXPECTED; |
| - context_->FlushAsync(callback); |
| + context_->Flush(callback); |
| return ERR_IO_PENDING; |
| } |