Chromium Code Reviews| Index: net/base/upload_data.h |
| diff --git a/net/base/upload_data.h b/net/base/upload_data.h |
| index ab6186b78a9194a24d3a85785ecf1a1903c08d8b..571bb0c7147e2cd1e6a782699c5c46d762294ebf 100644 |
| --- a/net/base/upload_data.h |
| +++ b/net/base/upload_data.h |
| @@ -14,7 +14,6 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/supports_user_data.h" |
| #include "base/time.h" |
| -#include "googleurl/src/gurl.h" |
| #include "net/base/net_export.h" |
| namespace net { |
| @@ -46,7 +45,6 @@ class NET_EXPORT UploadData |
| 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. |
| @@ -65,7 +63,8 @@ class NET_EXPORT UploadData |
| type_ = type; |
| } |
| - const std::vector<char>& bytes() const { return bytes_; } |
| + const char* bytes() const { return bytes_start_ ? bytes_start_ : &buf_[0]; } |
|
darin (slow to review)
2012/08/15 17:49:55
maybe you should just ensure that bytes_start_ is
kinuko
2012/08/16 08:14:59
To do so we need to allocate memory by ourselves a
|
| + 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_; } |
| @@ -73,11 +72,16 @@ class NET_EXPORT UploadData |
| 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); |
| + } |
| + |
| + void SetToSharedBytes(const char* bytes, int bytes_len) { |
|
darin (slow to review)
2012/08/15 17:49:55
You should probably add a warning here about memor
kinuko
2012/08/16 08:14:59
Done.
|
| + type_ = TYPE_BYTES; |
| + bytes_start_ = bytes; |
| + bytes_length_ = bytes_len; |
| } |
| void SetToFilePath(const FilePath& path) { |
| @@ -97,13 +101,6 @@ class NET_EXPORT UploadData |
| 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. |
| @@ -152,12 +149,13 @@ class NET_EXPORT UploadData |
| } |
| 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_; |
| @@ -187,8 +185,6 @@ class NET_EXPORT UploadData |
| uint64 offset, uint64 length, |
| const base::Time& expected_modification_time); |
| - void AppendBlob(const GURL& blob_url); |
| - |
| // Adds the given chunk of bytes to be sent immediately with chunked transfer |
| // encoding. |
| void AppendChunk(const char* bytes, int bytes_len, bool is_last_chunk); |
| @@ -259,31 +255,6 @@ class NET_EXPORT UploadData |
| DISALLOW_COPY_AND_ASSIGN(UploadData); |
| }; |
| -#if defined(UNIT_TEST) |
| -inline bool operator==(const UploadData::Element& a, |
| - const UploadData::Element& b) { |
| - if (a.type() != b.type()) |
| - return false; |
| - if (a.type() == UploadData::TYPE_BYTES) |
| - return a.bytes() == b.bytes(); |
| - if (a.type() == UploadData::TYPE_FILE) { |
| - return a.file_path() == b.file_path() && |
| - a.file_range_offset() == b.file_range_offset() && |
| - a.file_range_length() == b.file_range_length() && |
| - a.expected_file_modification_time() == |
| - b.expected_file_modification_time(); |
| - } |
| - if (a.type() == UploadData::TYPE_BLOB) |
| - return a.blob_url() == b.blob_url(); |
| - return false; |
| -} |
| - |
| -inline bool operator!=(const UploadData::Element& a, |
| - const UploadData::Element& b) { |
| - return !(a == b); |
| -} |
| -#endif // defined(UNIT_TEST) |
| - |
| } // namespace net |
| #endif // NET_BASE_UPLOAD_DATA_H_ |