summaryrefslogtreecommitdiffstats
path: root/net/base/file_stream_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/file_stream_context.h')
-rw-r--r--net/base/file_stream_context.h50
1 files changed, 27 insertions, 23 deletions
diff --git a/net/base/file_stream_context.h b/net/base/file_stream_context.h
index 34effea..42fc0eb 100644
--- a/net/base/file_stream_context.h
+++ b/net/base/file_stream_context.h
@@ -116,46 +116,50 @@ class FileStream::Context {
private:
////////////////////////////////////////////////////////////////////////////
- // Platform-independent methods implemented in file_stream_context.cc.
+ // Error code that is platform-dependent but is used in the platform-
+ // independent code 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.
+ 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 OpenResult {
- OpenResult();
- OpenResult(base::PlatformFile file, IOResult error_code);
base::PlatformFile file;
- IOResult error_code;
+ int error_code;
};
- // Log the error from |result| to |bound_net_log_|.
- void RecordError(const IOResult& result, FileErrorSource source) const;
+ // Map system error into network error code and log it with |bound_net_log_|.
+ int RecordAndMapError(int error, FileErrorSource source) const;
void BeginOpenEvent(const base::FilePath& path);
OpenResult OpenFileImpl(const base::FilePath& path, int open_flags);
- void ProcessOpenError(const IOResult& result);
- void OnOpenCompleted(const CompletionCallback& callback,
- OpenResult open_result);
+ int ProcessOpenError(int error_code);
+ void OnOpenCompleted(const CompletionCallback& callback, OpenResult 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,
- const IOResult& result);
+ int64 result);
// Called when asynchronous Open() or Seek()
// is completed. |result| contains the result or a network error code.
@@ -183,27 +187,27 @@ class FileStream::Context {
////////////////////////////////////////////////////////////////////////////
// Adjusts the position from where the data is read.
- IOResult SeekFileImpl(Whence whence, int64 offset);
+ int64 SeekFileImpl(Whence whence, int64 offset);
// Flushes all data written to the stream.
- IOResult FlushFileImpl();
+ int64 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.
- IOResult ReadFileImpl(scoped_refptr<IOBuffer> buf, int buf_len);
+ int64 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.
- IOResult WriteFileImpl(scoped_refptr<IOBuffer> buf, int buf_len);
+ int64 WriteFileImpl(scoped_refptr<IOBuffer> buf, int buf_len);
#endif
base::PlatformFile file_;