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

Unified Diff: net/base/upload_bytes_element_reader.h

Issue 11439008: net: Change argument of URLRequest::set_upload from UploadData to UploadDataStream (Closed) Base URL: http://git.chromium.org/chromium/src.git@chunk
Patch Set: Fix android Created 8 years 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_bytes_element_reader.h
diff --git a/net/base/upload_bytes_element_reader.h b/net/base/upload_bytes_element_reader.h
index afc9560e54aec448732fd3a54db87b77ccda8b42..def8c9ee4fa79c2c3c0bfe62a79a4b78707c52ba 100644
--- a/net/base/upload_bytes_element_reader.h
+++ b/net/base/upload_bytes_element_reader.h
@@ -5,19 +5,25 @@
#ifndef NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_
#define NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "net/base/upload_element_reader.h"
namespace net {
// An UploadElementReader implementation for bytes.
-class NET_EXPORT_PRIVATE UploadBytesElementReader : public UploadElementReader {
+// |data| should outlive this class because this class does not take the
+// ownership of the data.
+class NET_EXPORT UploadBytesElementReader : public UploadElementReader {
public:
- UploadBytesElementReader(const char* bytes, int length);
+ UploadBytesElementReader(const char* bytes, uint64 length);
virtual ~UploadBytesElementReader();
const char* bytes() const { return bytes_; }
- int length() const { return length_; }
+ uint64 length() const { return length_; }
// UploadElementReader overrides:
virtual const UploadBytesElementReader* AsBytesReader() const OVERRIDE;
@@ -33,12 +39,30 @@ class NET_EXPORT_PRIVATE UploadBytesElementReader : public UploadElementReader {
private:
const char* const bytes_;
- const int length_;
- int offset_;
+ const uint64 length_;
+ uint64 offset_;
DISALLOW_COPY_AND_ASSIGN(UploadBytesElementReader);
};
+// A subclass of UplodBytesElementReader which owns the data given as a vector.
+class NET_EXPORT UploadOwnedBytesElementReader
+ : public UploadBytesElementReader {
+ public:
+ // |data| is cleared by this ctor.
+ explicit UploadOwnedBytesElementReader(std::vector<char>* data);
+ virtual ~UploadOwnedBytesElementReader();
+
+ // Creates UploadOwnedBytesElementReader with a string.
+ static UploadOwnedBytesElementReader* CreateWithString(
+ const std::string& string);
+
+ private:
+ std::vector<char> data_;
+
+ DISALLOW_COPY_AND_ASSIGN(UploadOwnedBytesElementReader);
+};
+
} // namespace net
#endif // NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_unittest.cc ('k') | net/base/upload_bytes_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698