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

Unified Diff: net/base/upload_file_element_reader.h

Issue 11778016: net: Stop using base::WorkerPool from UploadFileElementReader (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix CF Created 7 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 | « net/base/upload_data_stream_unittest.cc ('k') | 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: net/base/upload_file_element_reader.h
diff --git a/net/base/upload_file_element_reader.h b/net/base/upload_file_element_reader.h
index f85d45f756af1ea3aa3027898c7b119cdef4c8e5..ad16bb25a4994a8cb1f715fb24d412c6b778ec6d 100644
--- a/net/base/upload_file_element_reader.h
+++ b/net/base/upload_file_element_reader.h
@@ -8,11 +8,16 @@
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time.h"
#include "net/base/upload_element_reader.h"
+namespace base {
+class TaskRunner;
+}
+
namespace net {
class FileStream;
@@ -20,16 +25,9 @@ class FileStream;
// An UploadElementReader implementation for file.
class NET_EXPORT UploadFileElementReader : public UploadElementReader {
public:
- // Deletes FileStream on the worker pool to avoid blocking the IO thread.
- // This class is used as a template argument of scoped_ptr_malloc.
- class FileStreamDeleter {
- public:
- void operator() (FileStream* file_stream) const;
- };
-
- typedef scoped_ptr_malloc<FileStream, FileStreamDeleter> ScopedFileStreamPtr;
-
- UploadFileElementReader(const FilePath& path,
+ // |task_runner| is used to perform file operations. It must not be NULL.
+ UploadFileElementReader(base::TaskRunner* task_runner,
+ const FilePath& path,
uint64 range_offset,
uint64 range_length,
const base::Time& expected_modification_time);
@@ -52,6 +50,20 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
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);
@@ -81,6 +93,7 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
~ScopedOverridingContentLengthForTests();
};
+ scoped_refptr<base::TaskRunner> task_runner_;
const FilePath path_;
const uint64 range_offset_;
const uint64 range_length_;
« no previous file with comments | « net/base/upload_data_stream_unittest.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698