diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 07:54:39 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 07:54:39 +0000 |
commit | bf96f533df6515f9ddea3278515a77ab81c00263 (patch) | |
tree | 72ba664e83a3a5880b1b16bd379d041c2e85e368 /chrome/common/net | |
parent | 26c2f823d194dc69819b7def92f920f0ec861df5 (diff) | |
download | chromium_src-bf96f533df6515f9ddea3278515a77ab81c00263.zip chromium_src-bf96f533df6515f9ddea3278515a77ab81c00263.tar.gz chromium_src-bf96f533df6515f9ddea3278515a77ab81c00263.tar.bz2 |
Add chunked uploads support to SPDY
As part of this, I had to move the chunked encoding part from UploadData::Element::SetChunk
to HttpStreamParser::DoSendBody as SPDY doesn't have this encoded format and UploadData
needs to serve both.
BUG=none
TEST=net_unittests (2 new tests added)
Review URL: http://codereview.chromium.org/6292013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net')
-rw-r--r-- | chrome/common/net/url_fetcher.cc | 32 | ||||
-rw-r--r-- | chrome/common/net/url_fetcher.h | 7 |
2 files changed, 16 insertions, 23 deletions
diff --git a/chrome/common/net/url_fetcher.cc b/chrome/common/net/url_fetcher.cc index 30c18fb..5e5e910 100644 --- a/chrome/common/net/url_fetcher.cc +++ b/chrome/common/net/url_fetcher.cc @@ -101,11 +101,12 @@ class URLFetcher::Core // |original_url_| and |url_|. base::TimeTicks GetBackoffReleaseTime(); - void CompleteAddingUploadDataChunk(const std::string& data); + void CompleteAddingUploadDataChunk(const std::string& data, + bool is_last_chunk); // Adds a block of data to be uploaded in a POST body. This can only be called // after Start(). - void AppendChunkToUpload(const std::string& data); + void AppendChunkToUpload(const std::string& data, bool is_last_chunk); URLFetcher* fetcher_; // Corresponding fetcher object GURL original_url_; // The URL we were asked to fetch @@ -291,23 +292,23 @@ void URLFetcher::Core::OnResponseStarted(net::URLRequest* request) { } void URLFetcher::Core::CompleteAddingUploadDataChunk( - const std::string& content) { + const std::string& content, bool is_last_chunk) { DCHECK(is_chunked_upload_); DCHECK(request_.get()); - if (content.length()) { - request_->AppendChunkToUpload(content.data(), - static_cast<int>(content.length())); - } else { - request_->MarkEndOfChunks(); - } + DCHECK(!content.empty()); + request_->AppendChunkToUpload(content.data(), + static_cast<int>(content.length()), + is_last_chunk); } -void URLFetcher::Core::AppendChunkToUpload(const std::string& content) { +void URLFetcher::Core::AppendChunkToUpload(const std::string& content, + bool is_last_chunk) { DCHECK(delegate_loop_proxy_); CHECK(io_message_loop_proxy_.get()); io_message_loop_proxy_->PostTask( FROM_HERE, - NewRunnableMethod(this, &Core::CompleteAddingUploadDataChunk, content)); + NewRunnableMethod(this, &Core::CompleteAddingUploadDataChunk, content, + is_last_chunk)); } void URLFetcher::Core::OnReadCompleted(net::URLRequest* request, @@ -520,13 +521,10 @@ void URLFetcher::set_chunked_upload(const std::string& content_type) { core_->is_chunked_upload_ = true; } -void URLFetcher::AppendChunkToUpload(const std::string& data) { +void URLFetcher::AppendChunkToUpload(const std::string& data, + bool is_last_chunk) { DCHECK(data.length()); - core_->AppendChunkToUpload(data); -} - -void URLFetcher::MarkEndOfChunks() { - core_->AppendChunkToUpload(std::string()); + core_->AppendChunkToUpload(data, is_last_chunk); } const std::string& URLFetcher::upload_data() const { diff --git a/chrome/common/net/url_fetcher.h b/chrome/common/net/url_fetcher.h index 20f6ea7..e3e7eff 100644 --- a/chrome/common/net/url_fetcher.h +++ b/chrome/common/net/url_fetcher.h @@ -140,12 +140,7 @@ class URLFetcher { // Adds the given bytes to a request's POST data transmitted using chunked // transfer encoding. // This method should be called ONLY after calling Start(). - void AppendChunkToUpload(const std::string& data); - - // Signals the end of a chunked transfer encoded data stream. This method - // should be called ONLY after calling Start(), set_chunked_upload() and - // typically one or more calls to AppendChunkToUpload. - void MarkEndOfChunks(); + void AppendChunkToUpload(const std::string& data, bool is_last_chunk); // Set one or more load flags as defined in net/base/load_flags.h. Must be // called before the request is started. |