diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-29 19:29:47 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-29 19:29:47 +0000 |
commit | dbb747cc59a580ba977e5ed8feb1d74117270415 (patch) | |
tree | f7e85df659f888a64a419d0d146d3c957b946ea9 /net/base/file_stream_win.h | |
parent | 62e9bad28db38512959c91005c9572ece80b3643 (diff) | |
download | chromium_src-dbb747cc59a580ba977e5ed8feb1d74117270415.zip chromium_src-dbb747cc59a580ba977e5ed8feb1d74117270415.tar.gz chromium_src-dbb747cc59a580ba977e5ed8feb1d74117270415.tar.bz2 |
net: Make destruction and closure of FileStream safer.
Before this patch, it was unsafe to destroy or close FileStream
while the file is being opened (i.e. async Open() is in flight).
BUG=115067
TEST=net_unittests
Review URL: https://chromiumcodereview.appspot.com/9467025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/file_stream_win.h')
-rw-r--r-- | net/base/file_stream_win.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/base/file_stream_win.h b/net/base/file_stream_win.h index cc6f565..5b4dd7e 100644 --- a/net/base/file_stream_win.h +++ b/net/base/file_stream_win.h @@ -11,6 +11,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/platform_file.h" +#include "base/synchronization/waitable_event.h" #include "net/base/completion_callback.h" #include "net/base/file_stream_whence.h" #include "net/base/net_export.h" @@ -52,14 +53,16 @@ class NET_EXPORT FileStreamWin { class AsyncContext; friend class AsyncContext; - // Called when the file_ is opened asynchronously. |file| contains the - // platform file opened. |result| contains the result as a network error - // code. - void OnOpened(base::PlatformFile *file, int* result); + // Called when the file_ is opened asynchronously. |result| contains the + // result as a network error code. + void OnOpened(int* result); // Called when the file_ is closed asynchronously. void OnClosed(); + // Waits until the in-flight async open/close operation is complete. + void WaitForIOCompletion(); + // This member is used to support asynchronous reads. It is non-null when // the FileStreamWin was opened with PLATFORM_FILE_ASYNC. scoped_ptr<AsyncContext> async_context_; @@ -71,6 +74,7 @@ class NET_EXPORT FileStreamWin { net::BoundNetLog bound_net_log_; base::WeakPtrFactory<FileStreamWin> weak_ptr_factory_; CompletionCallback callback_; + scoped_ptr<base::WaitableEvent> on_io_complete_; DISALLOW_COPY_AND_ASSIGN(FileStreamWin); }; |