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

Unified Diff: net/base/upload_file_element_reader.h

Issue 10913179: net: Make UploadDataStream::Init() asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 years, 3 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/upload_file_element_reader.h
diff --git a/net/base/upload_file_element_reader.h b/net/base/upload_file_element_reader.h
index 875314bd12135e3a3000b72538443c0afe01d32a..3b4e9ec490d62a0807da92a9fc18770d9483f026 100644
--- a/net/base/upload_file_element_reader.h
+++ b/net/base/upload_file_element_reader.h
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/time.h"
#include "net/base/upload_element_reader.h"
@@ -26,12 +27,19 @@ class NET_EXPORT_PRIVATE UploadFileElementReader : public UploadElementReader {
virtual ~UploadFileElementReader();
// UploadElementReader overrides:
+ virtual int Init(const CompletionCallback& callback) OVERRIDE;
virtual int InitSync() OVERRIDE;
virtual uint64 GetContentLength() const OVERRIDE;
virtual uint64 BytesRemaining() const OVERRIDE;
virtual int ReadSync(char* buf, int buf_length) OVERRIDE;
private:
+ // This method is used to implement Init().
+ void OnInitCompleted(scoped_ptr<FileStream>* file_stream,
+ uint64* content_length,
+ int* result,
+ const CompletionCallback& callback);
+
// Sets an value to override the result for GetContentLength().
// Used for tests.
struct NET_EXPORT ScopedOverridingContentLengthForTests {
@@ -46,6 +54,7 @@ class NET_EXPORT_PRIVATE UploadFileElementReader : public UploadElementReader {
scoped_ptr<FileStream> file_stream_;
uint64 content_length_;
uint64 bytes_remaining_;
+ base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_;
FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, FileSmallerThanLength);
FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest,

Powered by Google App Engine
This is Rietveld 408576698