Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: net/base/file_stream_win.h

Issue 10701050: net: Implement canceling of all async operations in FileStream. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/file_stream_win.h
===================================================================
--- net/base/file_stream_win.h (revision 145483)
+++ net/base/file_stream_win.h (working copy)
@@ -8,10 +8,7 @@
#define NET_BASE_FILE_STREAM_WIN_H_
#pragma once
-#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"
@@ -36,6 +33,7 @@
// FileStream implementations.
void Close(const CompletionCallback& callback);
void CloseSync();
+ void CloseAndCancelAsync();
int Open(const FilePath& path, int open_flags,
const CompletionCallback& callback);
int OpenSync(const FilePath& path, int open_flags);
@@ -58,37 +56,15 @@
private:
class AsyncContext;
- // A helper method for Seek.
- void SeekFile(Whence whence, int64 offset, int64* result);
+ bool is_async() { return !!(open_flags_ & base::PLATFORM_FILE_ASYNC); }
- // Called when the file_ is opened asynchronously. |result| contains the
- // result as a network error code.
- void OnOpened(const CompletionCallback& callback, int* result);
+ // 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_;
- // Called when the file_ is closed asynchronously.
- void OnClosed(const CompletionCallback& callback);
-
- // Called when the file_ is seeked asynchronously.
- void OnSeeked(const Int64CompletionCallback& callback, int64* result);
-
- // Resets on_io_complete_ and WeakPtr's.
- // Called in OnOpened, OnClosed and OnSeeked.
- void ResetOnIOComplete();
-
- // 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_;
-
- base::PlatformFile file_;
int open_flags_;
- bool auto_closed_;
- bool record_uma_;
net::BoundNetLog bound_net_log_;
- base::WeakPtrFactory<FileStreamWin> weak_ptr_factory_;
- scoped_ptr<base::WaitableEvent> on_io_complete_;
DISALLOW_COPY_AND_ASSIGN(FileStreamWin);
};

Powered by Google App Engine
This is Rietveld 408576698