Index: net/base/file_stream.h |
=================================================================== |
--- net/base/file_stream.h (revision 151422) |
+++ net/base/file_stream.h (working copy) |
@@ -15,11 +15,6 @@ |
#include "net/base/file_stream_whence.h" |
#include "net/base/net_export.h" |
#include "net/base/net_log.h" |
-#if defined(OS_WIN) |
-#include "net/base/file_stream_win.h" |
-#elif defined(OS_POSIX) |
-#include "net/base/file_stream_posix.h" |
-#endif |
class FilePath; |
@@ -39,8 +34,8 @@ |
// opened. |
// |net_log| is the net log pointer to use to create a |BoundNetLog|. May be |
// NULL if logging is not needed. |
- // The already opened file will not be automatically closed when FileStream |
- // is destructed. |
+ // Note: the new FileStream object takes ownership of the PlatformFile and |
+ // will close it on destruction. |
FileStream(base::PlatformFile file, int flags, net::NetLog* net_log); |
// If the file stream was opened with Open() or OpenSync(), the underlying |
@@ -62,7 +57,8 @@ |
// Call this method to close the FileStream synchronously. |
// It is OK to call CloseSync() multiple times. Redundant calls are |
// ignored. Note that if there are any pending async operations, they'll |
- // be aborted. |
+ // be aborted and actual closing of the stream will happen asynchronously |
+ // (to avoid races with async operation). |
virtual void CloseSync(); |
// Call this method to open the FileStream asynchronously. The remaining |
@@ -216,12 +212,18 @@ |
base::PlatformFile GetPlatformFileForTesting(); |
private: |
-#if defined(OS_WIN) |
- FileStreamWin impl_; |
-#elif defined(OS_POSIX) |
- FileStreamPosix impl_; |
-#endif |
+ class AsyncContext; |
willchan no longer on Chromium
2012/08/27 06:24:06
How about we just call it Context. It's not necess
|
+ bool is_async() { return !!(open_flags_ & base::PLATFORM_FILE_ASYNC); } |
+ |
+ // Context performing I/O operations. Despite its name the context is used |
+ // for synchronous operations too, but it was extracted into separate class |
+ // to perform asynchronous operations correctly. |
+ AsyncContext* context_; |
+ |
+ int open_flags_; |
+ net::BoundNetLog bound_net_log_; |
+ |
DISALLOW_COPY_AND_ASSIGN(FileStream); |
}; |