diff options
author | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-15 09:55:38 +0000 |
---|---|---|
committer | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-15 09:55:38 +0000 |
commit | 89b429341068c7b6d4c1129052e7abfc708d6161 (patch) | |
tree | 208aa003365726a6ae615da869b9ab19dc451c09 /webkit/browser | |
parent | 24e4cac9b53c6bebf0bafc40213ff67fa9caedb2 (diff) | |
download | chromium_src-89b429341068c7b6d4c1129052e7abfc708d6161.zip chromium_src-89b429341068c7b6d4c1129052e7abfc708d6161.tar.gz chromium_src-89b429341068c7b6d4c1129052e7abfc708d6161.tar.bz2 |
This is to allow extensions to determine the total length of Javascript blobs.
This cannot AFAIK be done via passing the length in a custom binding, as base::Value does not support int64 a.k.a. 'long long' types.
The total blob length is going to be used in media_galleries_api.cc to construct the SafeMediaMetadataParser in a followup CL. It appears unused in this patch.
BUG=
Review URL: https://codereview.chromium.org/129823003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244860 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/browser')
-rw-r--r-- | webkit/browser/blob/blob_url_request_job.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/webkit/browser/blob/blob_url_request_job.cc b/webkit/browser/blob/blob_url_request_job.cc index 4b89636..f1040f5 100644 --- a/webkit/browser/blob/blob_url_request_job.cc +++ b/webkit/browser/blob/blob_url_request_job.cc @@ -10,10 +10,12 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/files/file_util_proxy.h" +#include "base/format_macros.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/stringprintf.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/http/http_request_headers.h" @@ -509,6 +511,18 @@ void BlobURLRequestJob::HeadersCompleted(net::HttpStatusCode status_code) { content_length_header.append(": "); content_length_header.append(base::Int64ToString(remaining_bytes_)); headers->AddHeader(content_length_header); + if (status_code == net::HTTP_PARTIAL_CONTENT) { + DCHECK(byte_range_set_); + DCHECK(byte_range_.IsValid()); + std::string content_range_header(net::HttpResponseHeaders::kContentRange); + content_range_header.append(": bytes "); + content_range_header.append(base::StringPrintf( + "%" PRId64 "-%" PRId64, + byte_range_.first_byte_position(), byte_range_.last_byte_position())); + content_range_header.append("/"); + content_range_header.append(base::StringPrintf("%" PRId64, total_size_)); + headers->AddHeader(content_range_header); + } if (!blob_data_->content_type().empty()) { std::string content_type_header(net::HttpRequestHeaders::kContentType); content_type_header.append(": "); |