diff options
Diffstat (limited to 'net/base/file_stream_posix.cc')
-rw-r--r-- | net/base/file_stream_posix.cc | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc index e947a6e..a4c5b3c 100644 --- a/net/base/file_stream_posix.cc +++ b/net/base/file_stream_posix.cc @@ -298,8 +298,13 @@ FileStream::FileStream() } FileStream::FileStream(base::PlatformFile file, int flags) - : file_(base::kInvalidPlatformFileValue) { - Open(file, flags); + : file_(file), + open_flags_(flags) { + // If the file handle is opened with base::PLATFORM_FILE_ASYNC, we need to + // make sure we will perform asynchronous File IO to it. + if (flags & base::PLATFORM_FILE_ASYNC) { + async_context_.reset(new AsyncContext()); + } } FileStream::~FileStream() { @@ -318,12 +323,6 @@ void FileStream::Close() { } } -void FileStream::Release() { - // Abort any existing asynchronous operations. - async_context_.reset(); - file_ = base::kInvalidPlatformFileValue; -} - int FileStream::Open(const FilePath& path, int open_flags) { if (IsOpen()) { DLOG(FATAL) << "File is already open!"; @@ -345,21 +344,6 @@ int FileStream::Open(const FilePath& path, int open_flags) { return OK; } -int FileStream::Open(base::PlatformFile file, int open_flags) { - if (IsOpen()) { - DLOG(FATAL) << "File is already open!"; - return ERR_UNEXPECTED; - } - - open_flags_ = open_flags; - file_ = file; - - if (open_flags & base::PLATFORM_FILE_ASYNC) - async_context_.reset(new AsyncContext()); - - return OK; -} - bool FileStream::IsOpen() const { return file_ != base::kInvalidPlatformFileValue; } @@ -461,7 +445,7 @@ int64 FileStream::Truncate(int64 bytes) { if (!IsOpen()) return ERR_UNEXPECTED; - // We better be open for writing. + // We better be open for reading. DCHECK(open_flags_ & base::PLATFORM_FILE_WRITE); // Seek to the position to truncate from. |