Index: net/base/file_stream_context.h |
diff --git a/net/base/file_stream_context.h b/net/base/file_stream_context.h |
index 42fc0eb573c914039b08ecb6a91b07ac6a323ca5..34effea0704ac14ddb4242640bd7554809d3c37c 100644 |
--- a/net/base/file_stream_context.h |
+++ b/net/base/file_stream_context.h |
@@ -116,50 +116,46 @@ class FileStream::Context { |
private: |
//////////////////////////////////////////////////////////////////////////// |
- // Error code that is platform-dependent but is used in the platform- |
- // independent code implemented in file_stream_context.cc. |
- //////////////////////////////////////////////////////////////////////////// |
- enum { |
-#if defined(OS_WIN) |
- ERROR_BAD_FILE = ERROR_INVALID_HANDLE |
-#elif defined(OS_POSIX) |
- ERROR_BAD_FILE = EBADF |
-#endif |
- }; |
- |
- //////////////////////////////////////////////////////////////////////////// |
// Platform-independent methods implemented in file_stream_context.cc. |
//////////////////////////////////////////////////////////////////////////// |
+ struct IOResult { |
+ IOResult(); |
+ IOResult(int64 result, int os_error); |
+ static IOResult FromOSError(int64 os_error); |
+ |
+ int64 result; |
+ int os_error; // Set only when result < 0. |
+ }; |
+ |
struct OpenResult { |
+ OpenResult(); |
+ OpenResult(base::PlatformFile file, IOResult error_code); |
base::PlatformFile file; |
- int error_code; |
+ IOResult error_code; |
}; |
- // Map system error into network error code and log it with |bound_net_log_|. |
- int RecordAndMapError(int error, FileErrorSource source) const; |
+ // Log the error from |result| to |bound_net_log_|. |
+ void RecordError(const IOResult& result, FileErrorSource source) const; |
void BeginOpenEvent(const base::FilePath& path); |
OpenResult OpenFileImpl(const base::FilePath& path, int open_flags); |
- int ProcessOpenError(int error_code); |
- void OnOpenCompleted(const CompletionCallback& callback, OpenResult result); |
+ void ProcessOpenError(const IOResult& result); |
+ void OnOpenCompleted(const CompletionCallback& callback, |
+ OpenResult open_result); |
void CloseAndDelete(); |
void OnCloseCompleted(); |
Int64CompletionCallback IntToInt64(const CompletionCallback& callback); |
- // Checks for IO error that probably happened in async methods. |
- // If there was error reports it. |
- void CheckForIOError(int64* result, FileErrorSource source); |
- |
// Called when asynchronous Seek() is completed. |
// Reports error if needed and calls callback. |
void ProcessAsyncResult(const Int64CompletionCallback& callback, |
FileErrorSource source, |
- int64 result); |
+ const IOResult& result); |
// Called when asynchronous Open() or Seek() |
// is completed. |result| contains the result or a network error code. |
@@ -187,27 +183,27 @@ class FileStream::Context { |
//////////////////////////////////////////////////////////////////////////// |
// Adjusts the position from where the data is read. |
- int64 SeekFileImpl(Whence whence, int64 offset); |
+ IOResult SeekFileImpl(Whence whence, int64 offset); |
// Flushes all data written to the stream. |
- int64 FlushFileImpl(); |
+ IOResult FlushFileImpl(); |
#if defined(OS_WIN) |
void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf); |
- // Implementation of MessageLoopForIO::IOHandler |
+ // Implementation of MessageLoopForIO::IOHandler. |
virtual void OnIOCompleted(MessageLoopForIO::IOContext* context, |
DWORD bytes_read, |
DWORD error) OVERRIDE; |
#elif defined(OS_POSIX) |
// ReadFileImpl() is a simple wrapper around read() that handles EINTR |
// signals and calls RecordAndMapError() to map errno to net error codes. |
- int64 ReadFileImpl(scoped_refptr<IOBuffer> buf, int buf_len); |
+ IOResult ReadFileImpl(scoped_refptr<IOBuffer> buf, int buf_len); |
// WriteFileImpl() is a simple wrapper around write() that handles EINTR |
// signals and calls MapSystemError() to map errno to net error codes. |
// It tries to write to completion. |
- int64 WriteFileImpl(scoped_refptr<IOBuffer> buf, int buf_len); |
+ IOResult WriteFileImpl(scoped_refptr<IOBuffer> buf, int buf_len); |
#endif |
base::PlatformFile file_; |