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

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: changed argument order 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
« no previous file with comments | « net/base/upload_element_reader.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 34d8194cd68d7878baf26efdfab557c21aaef25d..cc8e83053a2979161ed6ad7931e0e4846b814a08 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_PRIVATE 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,
« no previous file with comments | « net/base/upload_element_reader.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698