diff options
author | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-04 00:00:54 +0000 |
---|---|---|
committer | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-04 00:00:54 +0000 |
commit | 33c6d3f12211d716768ab195be90d598cd2bd364 (patch) | |
tree | 58af1d1690f995e8e4bf0e03fab379b9940f9946 /net/base/file_stream_win.cc | |
parent | deac4290c3fd825f6f3000e89d67d4ac8a190371 (diff) | |
download | chromium_src-33c6d3f12211d716768ab195be90d598cd2bd364.zip chromium_src-33c6d3f12211d716768ab195be90d598cd2bd364.tar.gz chromium_src-33c6d3f12211d716768ab195be90d598cd2bd364.tar.bz2 |
Make BaseFile member functions return net::Error's.
Moving towards giving the user feedback when a file system error occurs during a download.
Split from CL 7134019.
rdsmith: downloads
phajdan.jr: downloads, base
wtc: net
brettw: base
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7778003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/file_stream_win.cc')
-rw-r--r-- | net/base/file_stream_win.cc | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc index c08521e..314687e 100644 --- a/net/base/file_stream_win.cc +++ b/net/base/file_stream_win.cc @@ -33,21 +33,6 @@ static void IncrementOffset(OVERLAPPED* overlapped, DWORD count) { SetOffset(overlapped, offset); } -static int MapErrorCode(DWORD err) { - switch (err) { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - return ERR_FILE_NOT_FOUND; - case ERROR_ACCESS_DENIED: - return ERR_ACCESS_DENIED; - case ERROR_SUCCESS: - return OK; - default: - LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED"; - return ERR_FAILED; - } -} - // FileStream::AsyncContext ---------------------------------------------- class FileStream::AsyncContext : public MessageLoopForIO::IOHandler { @@ -106,7 +91,7 @@ void FileStream::AsyncContext::OnIOCompleted( int result = static_cast<int>(bytes_read); if (error && error != ERROR_HANDLE_EOF) - result = MapErrorCode(error); + result = MapSystemError(error); if (bytes_read) IncrementOffset(&context->overlapped, bytes_read); @@ -164,7 +149,7 @@ int FileStream::Open(const FilePath& path, int open_flags) { if (file_ == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); LOG(WARNING) << "Failed to open file: " << error; - return MapErrorCode(error); + return MapSystemError(error); } if (open_flags_ & base::PLATFORM_FILE_ASYNC) { @@ -191,7 +176,7 @@ int64 FileStream::Seek(Whence whence, int64 offset) { if (!SetFilePointerEx(file_, distance, &result, move_method)) { DWORD error = GetLastError(); LOG(WARNING) << "SetFilePointerEx failed: " << error; - return MapErrorCode(error); + return MapSystemError(error); } if (async_context_.get()) SetOffset(async_context_->overlapped(), result); @@ -212,7 +197,7 @@ int64 FileStream::Available() { if (!GetFileSizeEx(file_, &file_size)) { DWORD error = GetLastError(); LOG(WARNING) << "GetFileSizeEx failed: " << error; - return MapErrorCode(error); + return MapSystemError(error); } return file_size.QuadPart - cur_pos; @@ -246,7 +231,7 @@ int FileStream::Read( rv = 0; // Report EOF by returning 0 bytes read. } else { LOG(WARNING) << "ReadFile failed: " << error; - rv = MapErrorCode(error); + rv = MapSystemError(error); } } else if (overlapped) { async_context_->IOCompletionIsPending(callback); @@ -303,7 +288,7 @@ int FileStream::Write( rv = ERR_IO_PENDING; } else { LOG(WARNING) << "WriteFile failed: " << error; - rv = MapErrorCode(error); + rv = MapSystemError(error); } } else if (overlapped) { async_context_->IOCompletionIsPending(callback); @@ -327,7 +312,7 @@ int FileStream::Flush() { int rv; DWORD error = GetLastError(); - rv = MapErrorCode(error); + rv = MapSystemError(error); return rv; } @@ -350,7 +335,7 @@ int64 FileStream::Truncate(int64 bytes) { if (!result) { DWORD error = GetLastError(); LOG(WARNING) << "SetEndOfFile failed: " << error; - return MapErrorCode(error); + return MapSystemError(error); } // Success. |