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

Unified Diff: chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer.h

Issue 440653003: [fsp] Add support for aborting running operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 years, 4 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: chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer.h
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer.h b/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer.h
index 5f969b1790470a7e877ad505ed593f78a0d10221..e21e12a0162443a91ec1fcf7b5f46600b0ac7e4e 100644
--- a/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer.h
+++ b/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer.h
@@ -22,12 +22,6 @@ class ProvidedFileSystemInterface;
// to Write().
class FileStreamWriter : public fileapi::FileStreamWriter {
public:
- typedef base::Callback<
- void(base::WeakPtr<ProvidedFileSystemInterface> file_system,
- const base::FilePath& file_path,
- int file_handle,
- base::File::Error result)> OpenFileCompletedCallback;
-
FileStreamWriter(const fileapi::FileSystemURL& url, int64 initial_offset);
virtual ~FileStreamWriter();
@@ -40,17 +34,28 @@ class FileStreamWriter : public fileapi::FileStreamWriter {
virtual int Flush(const net::CompletionCallback& callback) OVERRIDE;
private:
+ // Helper class for executing operations on the provided file system. All
+ // of its methods must be called on UI thread. Callbacks are called on IO
+ // thread.
+ class OperationRunner;
+
// State of the file stream writer.
enum State { NOT_INITIALIZED, INITIALIZING, INITIALIZED, FAILED };
+ // Called when OperationRunner::WriteOnUIThread is completed.
void OnWriteFileCompleted(int buffer_length,
const net::CompletionCallback& callback,
base::File::Error result);
- // Called when Write() operation is completed with either a success of an
+ // Called when Write() operation is completed with either a success or an
// error.
void OnWriteCompleted(net::CompletionCallback callback, int result);
+ // Called when Abort() operation is completed with either a success or an
+ // error.
+ void OnAbortCompleted(const net::CompletionCallback& callback,
+ base::File::Error result);
+
// Initializes the writer by opening the file. When completed with success,
// runs the |pending_closure|. Otherwise, calls the |error_callback|.
void Initialize(const base::Closure& pending_closure,
@@ -60,9 +65,6 @@ class FileStreamWriter : public fileapi::FileStreamWriter {
void OnOpenFileCompleted(
const base::Closure& pending_closure,
const net::CompletionCallback& error_callback,
- base::WeakPtr<ProvidedFileSystemInterface> file_system,
- const base::FilePath& file_path,
- int file_handle,
base::File::Error result);
// Same as Write(), but called after initializing is completed.
@@ -72,13 +74,9 @@ class FileStreamWriter : public fileapi::FileStreamWriter {
fileapi::FileSystemURL url_;
int64 current_offset_;
+ scoped_refptr<OperationRunner> runner_;
State state_;
- // Set during initialization (in case of a success).
- base::WeakPtr<ProvidedFileSystemInterface> file_system_;
- base::FilePath file_path_;
- int file_handle_;
-
base::WeakPtrFactory<FileStreamWriter> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(FileStreamWriter);
};

Powered by Google App Engine
This is Rietveld 408576698