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

Unified Diff: net/base/upload_element.h

Issue 10834289: Split net::UploadData into two: for IPC and for upload handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + moved ResolveBlobRef from webkit_blob to webkit_glue Created 8 years, 4 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_unittest.cc ('k') | net/base/upload_element.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/upload_element.h
diff --git a/net/base/upload_element.h b/net/base/upload_element.h
index 65e77011f9227f4fb73d31999de9f365d5affdf0..90444d69036a344cea1086c4fdc8a7cfe551d36d 100644
--- a/net/base/upload_element.h
+++ b/net/base/upload_element.h
@@ -24,7 +24,6 @@ class NET_EXPORT UploadElement {
enum Type {
TYPE_BYTES,
TYPE_FILE,
- TYPE_BLOB,
// A block of bytes to be sent in chunked encoding immediately, without
// waiting for rest of the data.
@@ -41,7 +40,8 @@ class NET_EXPORT UploadElement {
type_ = type;
}
- const std::vector<char>& bytes() const { return bytes_; }
+ const char* bytes() const { return bytes_start_ ? bytes_start_ : &buf_[0]; }
+ uint64 bytes_length() const { return buf_.size() + bytes_length_; }
const FilePath& file_path() const { return file_path_; }
uint64 file_range_offset() const { return file_range_offset_; }
uint64 file_range_length() const { return file_range_length_; }
@@ -49,11 +49,19 @@ class NET_EXPORT UploadElement {
const base::Time& expected_file_modification_time() const {
return expected_file_modification_time_;
}
- const GURL& blob_url() const { return blob_url_; }
void SetToBytes(const char* bytes, int bytes_len) {
type_ = TYPE_BYTES;
- bytes_.assign(bytes, bytes + bytes_len);
+ buf_.assign(bytes, bytes + bytes_len);
+ }
+
+ // This does not copy the given data and the caller should make sure
+ // the data is secured somewhere else (e.g. by attaching the data
+ // using SetUserData).
+ void SetToSharedBytes(const char* bytes, int bytes_len) {
+ type_ = TYPE_BYTES;
+ bytes_start_ = bytes;
+ bytes_length_ = bytes_len;
}
void SetToFilePath(const FilePath& path) {
@@ -73,13 +81,6 @@ class NET_EXPORT UploadElement {
expected_file_modification_time_ = expected_modification_time;
}
- // TODO(jianli): UploadData should not contain any blob reference. We need
- // to define another structure to represent WebKit::WebHTTPBody.
- void SetToBlobUrl(const GURL& blob_url) {
- type_ = TYPE_BLOB;
- blob_url_ = blob_url;
- }
-
// Though similar to bytes, a chunk indicates that the element is sent via
// chunked transfer encoding and not buffered until the full upload data
// is available.
@@ -128,12 +129,13 @@ class NET_EXPORT UploadElement {
}
Type type_;
- std::vector<char> bytes_;
+ std::vector<char> buf_;
+ const char* bytes_start_;
+ uint64 bytes_length_;
FilePath file_path_;
uint64 file_range_offset_;
uint64 file_range_length_;
base::Time expected_file_modification_time_;
- GURL blob_url_;
bool is_last_chunk_;
bool override_content_length_;
bool content_length_computed_;
@@ -161,7 +163,8 @@ inline bool operator==(const UploadElement& a,
if (a.type() != b.type())
return false;
if (a.type() == UploadElement::TYPE_BYTES)
- return a.bytes() == b.bytes();
+ return a.bytes_length() == b.bytes_length() &&
+ memcmp(a.bytes(), b.bytes(), b.bytes_length()) == 0;
if (a.type() == UploadElement::TYPE_FILE) {
return a.file_path() == b.file_path() &&
a.file_range_offset() == b.file_range_offset() &&
@@ -169,8 +172,6 @@ inline bool operator==(const UploadElement& a,
a.expected_file_modification_time() ==
b.expected_file_modification_time();
}
- if (a.type() == UploadElement::TYPE_BLOB)
- return a.blob_url() == b.blob_url();
return false;
}
« no previous file with comments | « net/base/upload_data_unittest.cc ('k') | net/base/upload_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698