net: Use FileStream asynchronously from UploadFileElementReader

InitInternal() and ReadInternal() were used to share the same implementation with UploadFileElementReaderSync.
There is no need to maintain them since UploadFileElementReaderSync is gone.
Abandon these unneeded functions and use FileStream in an asynchronous way.

BUG=294797
TEST=net_unittests

Review URL: https://codereview.chromium.org/139253002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245509 0039d316-1c4b-4281-b951-d872f2087c98
parent 30231ef9
This diff is collapsed.
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ #define NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/files/file.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
...@@ -50,20 +51,6 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader { ...@@ -50,20 +51,6 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
const CompletionCallback& callback) OVERRIDE; const CompletionCallback& callback) OVERRIDE;
private: 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(UploadDataStreamTest, FileSmallerThanLength);
FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest,
UploadFileSmallerThanLength); UploadFileSmallerThanLength);
...@@ -75,16 +62,15 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader { ...@@ -75,16 +62,15 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
// Resets this instance to the uninitialized state. // Resets this instance to the uninitialized state.
void Reset(); void Reset();
// This method is used to implement Init(). // These methods are used to implement Init().
void OnInitCompleted(ScopedFileStreamPtr* file_stream, void OnOpenCompleted(const CompletionCallback& callback, int result);
uint64* content_length, void OnSeekCompleted(const CompletionCallback& callback, int64 result);
const CompletionCallback& callback, void OnGetFileInfoCompleted(const CompletionCallback& callback,
int result); base::File::Info* file_info,
bool result);
// This method is used to implement Read(). // This method is used to implement Read().
void OnReadCompleted(ScopedFileStreamPtr file_stream, void OnReadCompleted(const CompletionCallback& callback, int result);
const CompletionCallback& callback,
int result);
// Sets an value to override the result for GetContentLength(). // Sets an value to override the result for GetContentLength().
// Used for tests. // Used for tests.
...@@ -98,7 +84,7 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader { ...@@ -98,7 +84,7 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
const uint64 range_offset_; const uint64 range_offset_;
const uint64 range_length_; const uint64 range_length_;
const base::Time expected_modification_time_; const base::Time expected_modification_time_;
ScopedFileStreamPtr file_stream_; scoped_ptr<FileStream> file_stream_;
uint64 content_length_; uint64 content_length_;
uint64 bytes_remaining_; uint64 bytes_remaining_;
base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_; base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment