summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-21 07:51:31 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-21 07:51:31 +0000
commit2c03980fa0873647293a0e8fade9b6d0adc1193c (patch)
tree0edbea1a354e6457af64991a5ee1d77cfab17349 /net/base
parentf7528eca39a09fab8d37f5435e2eb0ef7139776d (diff)
downloadchromium_src-2c03980fa0873647293a0e8fade9b6d0adc1193c.zip
chromium_src-2c03980fa0873647293a0e8fade9b6d0adc1193c.tar.gz
chromium_src-2c03980fa0873647293a0e8fade9b6d0adc1193c.tar.bz2
Split net::UploadData into two: for resource request IPC and for upload handling
Introducing webkit_glue::ResourceRequestBody as a content-level abstraction corresponding to WebHTTPBody and as an alternative of net::UploadData in ResourceRequest. This interface can contain content-level objects like Blob (or FileSystem URL in later patches) while net::UploadData should NOT. This patch also removes Blob support in net::UploadData. BUG=110119 TEST=existing tests Review URL: https://chromiumcodereview.appspot.com/10834289 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/upload_data.cc6
-rw-r--r--net/base/upload_data.h2
-rw-r--r--net/base/upload_data_unittest.cc11
-rw-r--r--net/base/upload_element.cc15
-rw-r--r--net/base/upload_element.h18
5 files changed, 21 insertions, 31 deletions
diff --git a/net/base/upload_data.cc b/net/base/upload_data.cc
index a36ea06..ca35d12 100644
--- a/net/base/upload_data.cc
+++ b/net/base/upload_data.cc
@@ -45,12 +45,6 @@ void UploadData::AppendFileRange(const FilePath& file_path,
expected_modification_time);
}
-void UploadData::AppendBlob(const GURL& blob_url) {
- DCHECK(!is_chunked_);
- elements_.push_back(UploadElement());
- elements_.back().SetToBlobUrl(blob_url);
-}
-
void UploadData::AppendChunk(const char* bytes,
int bytes_len,
bool is_last_chunk) {
diff --git a/net/base/upload_data.h b/net/base/upload_data.h
index 20675d0..7e4f54b 100644
--- a/net/base/upload_data.h
+++ b/net/base/upload_data.h
@@ -53,8 +53,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);
diff --git a/net/base/upload_data_unittest.cc b/net/base/upload_data_unittest.cc
index 63636a2..98bb23d 100644
--- a/net/base/upload_data_unittest.cc
+++ b/net/base/upload_data_unittest.cc
@@ -103,12 +103,6 @@ TEST_F(UploadDataTest, IsInMemory_File) {
ASSERT_FALSE(upload_data_->IsInMemory());
}
-TEST_F(UploadDataTest, IsInMemory_Blob) {
- upload_data_->AppendBlob(GURL("blog:internal:12345"));
- // Until it's resolved, we don't know what blob contains.
- ASSERT_FALSE(upload_data_->IsInMemory());
-}
-
TEST_F(UploadDataTest, IsInMemory_Chunk) {
upload_data_->set_is_chunked(true);
ASSERT_FALSE(upload_data_->IsInMemory());
@@ -149,11 +143,6 @@ TEST_F(UploadDataTest, GetContentLength_File) {
ASSERT_EQ(kData.size(), callback.WaitForResult());
}
-TEST_F(UploadDataTest, GetContentLength_Blob) {
- upload_data_->AppendBlob(GURL("blog:internal:12345"));
- ASSERT_EQ(0U, upload_data_->GetContentLengthSync());
-}
-
TEST_F(UploadDataTest, GetContentLength_Chunk) {
upload_data_->set_is_chunked(true);
ASSERT_EQ(0U, upload_data_->GetContentLengthSync());
diff --git a/net/base/upload_element.cc b/net/base/upload_element.cc
index afa5b0a..b6bdbed 100644
--- a/net/base/upload_element.cc
+++ b/net/base/upload_element.cc
@@ -15,6 +15,8 @@ namespace net {
UploadElement::UploadElement()
: type_(TYPE_BYTES),
+ bytes_start_(NULL),
+ bytes_length_(0),
file_range_offset_(0),
file_range_length_(kuint64max),
is_last_chunk_(false),
@@ -38,9 +40,8 @@ UploadElement::~UploadElement() {
void UploadElement::SetToChunk(const char* bytes,
int bytes_len,
bool is_last_chunk) {
- bytes_.clear();
- bytes_.insert(bytes_.end(), bytes, bytes + bytes_len);
type_ = TYPE_CHUNK;
+ buf_.assign(bytes, bytes + bytes_len);
is_last_chunk_ = is_last_chunk;
}
@@ -49,10 +50,7 @@ uint64 UploadElement::GetContentLength() {
return content_length_;
if (type_ == TYPE_BYTES || type_ == TYPE_CHUNK)
- return static_cast<uint64>(bytes_.size());
- else if (type_ == TYPE_BLOB)
- // The blob reference will be resolved later.
- return 0;
+ return bytes_length();
DCHECK_EQ(TYPE_FILE, type_);
DCHECK(!file_stream_);
@@ -146,9 +144,8 @@ int UploadElement::ReadFromMemorySync(char* buf, int buf_len) {
// Check if we have anything to copy first, because we are getting
// the address of an element in |bytes_| and that will throw an
// exception if |bytes_| is an empty vector.
- if (num_bytes_to_read > 0) {
- memcpy(buf, &bytes_[offset_], num_bytes_to_read);
- }
+ if (num_bytes_to_read > 0)
+ memcpy(buf, bytes() + offset_, num_bytes_to_read);
offset_ += num_bytes_to_read;
return num_bytes_to_read;
diff --git a/net/base/upload_element.h b/net/base/upload_element.h
index 65e7701..ef09d67 100644
--- a/net/base/upload_element.h
+++ b/net/base/upload_element.h
@@ -41,7 +41,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_; }
@@ -53,7 +54,16 @@ class NET_EXPORT UploadElement {
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) {
@@ -128,7 +138,9 @@ 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_;