summaryrefslogtreecommitdiffstats
path: root/net/base/file_stream_context.h
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 18:39:24 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 18:39:24 +0000
commitd22837bfda1972f69bca9a29784ae6f69f5d9e3f (patch)
tree0f5e17116a9efe2ef155a4739cac1c5508044b87 /net/base/file_stream_context.h
parent28865f1149f18ad7089572bd8ec86257268d222f (diff)
downloadchromium_src-d22837bfda1972f69bca9a29784ae6f69f5d9e3f.zip
chromium_src-d22837bfda1972f69bca9a29784ae6f69f5d9e3f.tar.gz
chromium_src-d22837bfda1972f69bca9a29784ae6f69f5d9e3f.tar.bz2
Experimental Revert of 184577
ASAN bots started timing out consistently last night at the time this was submitted. It's a possible culprit. It doesn't involve extensions, but it does things with streams and I assume those are connected to the feeds in this test somehow. browser_tests browser_tests failed 4 ( 12 mins, 52 secs ) stdio ParseFeedInvalidFeed1 ParseFeedInvalidFeed2 ParseFeedValidFeed3 ParseFeedValidFeed4 http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASAN%20Tests%20%281%29/builds/3019 http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASAN%20Tests%20%282%29/builds/3186 http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASAN%20Tests%20%283%29/builds/2716 > Fix net::FileStream to handle all errors correctly. > > This CL adds FileStream::Context::IOResult struct that's used to pass > results of IO operations inside FileStream::Context. Following bugs are > fixes: > > 1. On POSIX net::FileStream::Read() and net::FileStream::Write() would > return a positive result in case of an error. This happens because > POSIX errors are positive integers and FileStream was written with > assumption that they are negative. > 2. On Windows Seek() and Flush() errors were not handled correctly. > This is because CheckForIOError() was assuming that all error codes > are negative, but RecordAndMapError() was mapping positive errors. > 3. On Windows results of asynchronous ReadFile() and WriteFile() were > not handled correctly - ERR_IO_PENDING would be returned even when > operation completes synchronously. > 4. On Windows OVERLAPPED struct wasn't set to zeros as necessary. > > Also added unittests to check that error codes are handled correctly > now. > > TBR=mmenke@chromium.org > > Review URL: https://codereview.chromium.org/12326107 TBR=sergeyu@chromium.org Review URL: https://codereview.chromium.org/12330144 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184672 0039d316-1c4b-4281-b951-d872f2087c98
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_;