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

Unified Diff: net/base/file_stream_posix.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_posix.h
===================================================================
--- net/base/file_stream_posix.h (revision 145483)
+++ net/base/file_stream_posix.h (working copy)
@@ -8,8 +8,6 @@
#define NET_BASE_FILE_STREAM_POSIX_H_
#pragma once
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "net/base/completion_callback.h"
#include "net/base/file_stream_whence.h"
@@ -35,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);
@@ -55,25 +54,18 @@
const net::BoundNetLog& owner_bound_net_log);
base::PlatformFile GetPlatformFileForTesting();
- // Resets on_io_complete_ and WeakPtr's.
- // Called when Read() or Write() is completed.
- void ResetOnIOComplete();
-
private:
- // Called when the file_ is closed asynchronously.
- void OnClosed(const CompletionCallback& callback);
+ class AsyncContext;
- // Waits until the in-flight async open/close/read/write operation is
- // complete.
- void WaitForIOCompletion();
+ bool is_async() { return !!(open_flags_ & base::PLATFORM_FILE_ASYNC); }
- base::PlatformFile file_;
+ // 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_;
- bool auto_closed_;
- bool record_uma_;
net::BoundNetLog bound_net_log_;
- base::WeakPtrFactory<FileStreamPosix> weak_ptr_factory_;
- scoped_ptr<base::WaitableEvent> on_io_complete_;
DISALLOW_COPY_AND_ASSIGN(FileStreamPosix);
};

Powered by Google App Engine
This is Rietveld 408576698