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

Unified Diff: trunk/src/net/base/upload_file_element_reader.h

Issue 141843002: Revert 245509 "net: Use FileStream asynchronously from UploadFil..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | trunk/src/net/base/upload_file_element_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/net/base/upload_file_element_reader.h
===================================================================
--- trunk/src/net/base/upload_file_element_reader.h (revision 245528)
+++ trunk/src/net/base/upload_file_element_reader.h (working copy)
@@ -6,7 +6,6 @@
#define NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_
#include "base/compiler_specific.h"
-#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
@@ -51,6 +50,20 @@
const CompletionCallback& callback) OVERRIDE;
private:
+ // Deletes FileStream with |task_runner| to avoid blocking the IO thread.
+ // This class is used as a template argument of scoped_ptr.
+ class FileStreamDeleter {
+ public:
+ explicit FileStreamDeleter(base::TaskRunner* task_runner);
+ ~FileStreamDeleter();
+ void operator() (FileStream* file_stream) const;
+
+ private:
+ scoped_refptr<base::TaskRunner> task_runner_;
+ };
+
+ typedef scoped_ptr<FileStream, FileStreamDeleter> ScopedFileStreamPtr;
+
FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, FileSmallerThanLength);
FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest,
UploadFileSmallerThanLength);
@@ -62,15 +75,16 @@
// Resets this instance to the uninitialized state.
void Reset();
- // These methods are used to implement Init().
- void OnOpenCompleted(const CompletionCallback& callback, int result);
- void OnSeekCompleted(const CompletionCallback& callback, int64 result);
- void OnGetFileInfoCompleted(const CompletionCallback& callback,
- base::File::Info* file_info,
- bool result);
+ // This method is used to implement Init().
+ void OnInitCompleted(ScopedFileStreamPtr* file_stream,
+ uint64* content_length,
+ const CompletionCallback& callback,
+ int result);
// This method is used to implement Read().
- void OnReadCompleted(const CompletionCallback& callback, int result);
+ void OnReadCompleted(ScopedFileStreamPtr file_stream,
+ const CompletionCallback& callback,
+ int result);
// Sets an value to override the result for GetContentLength().
// Used for tests.
@@ -84,7 +98,7 @@
const uint64 range_offset_;
const uint64 range_length_;
const base::Time expected_modification_time_;
- scoped_ptr<FileStream> file_stream_;
+ ScopedFileStreamPtr file_stream_;
uint64 content_length_;
uint64 bytes_remaining_;
base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_;
« no previous file with comments | « no previous file | trunk/src/net/base/upload_file_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698