diff options
author | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-17 18:56:07 +0000 |
---|---|---|
committer | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-17 18:56:07 +0000 |
commit | d5aec989c84f6f5ba753976acc4e4aeda2525b82 (patch) | |
tree | c0cc77594adfbe06cb267d678b6c4471ec03f565 /webkit/glue/media | |
parent | cf42e0685ede37f92a658553bddaf8eeeac99030 (diff) | |
download | chromium_src-d5aec989c84f6f5ba753976acc4e4aeda2525b82.zip chromium_src-d5aec989c84f6f5ba753976acc4e4aeda2525b82.tar.gz chromium_src-d5aec989c84f6f5ba753976acc4e4aeda2525b82.tar.bz2 |
Not allow compression when requesting multimedia
because ffmpeg does not expect compressed files.
(It does not make sense to compress audio/video anyways...)
http://codereview.chromium.org/7044092
BUG=47381
TEST=http://www.deafmac.org/html5/grinchsample.mp4 (Please clear browser cache, otherwise it can contain original GZIP-ed file requested by old browser)
Review URL: http://codereview.chromium.org/7044092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media')
-rw-r--r-- | webkit/glue/media/buffered_resource_loader.cc | 14 | ||||
-rw-r--r-- | webkit/glue/media/buffered_resource_loader_unittest.cc | 15 | ||||
-rw-r--r-- | webkit/glue/media/simple_data_source.cc | 9 |
3 files changed, 33 insertions, 5 deletions
diff --git a/webkit/glue/media/buffered_resource_loader.cc b/webkit/glue/media/buffered_resource_loader.cc index eb14351..7829448 100644 --- a/webkit/glue/media/buffered_resource_loader.cc +++ b/webkit/glue/media/buffered_resource_loader.cc @@ -8,6 +8,7 @@ #include "base/stringprintf.h" #include "base/string_util.h" #include "net/base/net_errors.h" +#include "net/http/http_request_headers.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" @@ -106,13 +107,18 @@ void BufferedResourceLoader::Start(net::CompletionCallback* start_callback, if (IsRangeRequest()) { range_requested_ = true; - request.setHTTPHeaderField(WebString::fromUTF8("Range"), - WebString::fromUTF8(GenerateHeaders( - first_byte_position_, - last_byte_position_))); + request.setHTTPHeaderField( + WebString::fromUTF8(net::HttpRequestHeaders::kRange), + WebString::fromUTF8(GenerateHeaders(first_byte_position_, + last_byte_position_))); } frame->setReferrerForRequest(request, WebKit::WebURL()); + // Disable compression, compression for audio/video doesn't make sense... + request.setHTTPHeaderField( + WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), + WebString::fromUTF8("identity;q=1, *;q=0")); + // This flag is for unittests as we don't want to reset |url_loader| if (!keep_test_loader_) url_loader_.reset(frame->createAssociatedURLLoader()); diff --git a/webkit/glue/media/buffered_resource_loader_unittest.cc b/webkit/glue/media/buffered_resource_loader_unittest.cc index f23bd89..df44c48 100644 --- a/webkit/glue/media/buffered_resource_loader_unittest.cc +++ b/webkit/glue/media/buffered_resource_loader_unittest.cc @@ -3,14 +3,17 @@ // found in the LICENSE file. #include <algorithm> +#include <string> #include "base/format_macros.h" #include "base/stringprintf.h" #include "net/base/net_errors.h" +#include "net/http/http_request_headers.h" #include "net/http/http_util.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "webkit/glue/media/buffered_resource_loader.h" @@ -30,6 +33,7 @@ using ::testing::Return; using ::testing::ReturnRef; using ::testing::SetArgumentPointee; using ::testing::StrictMock; +using ::testing::Truly; using ::testing::NiceMock; using ::testing::WithArgs; @@ -65,6 +69,14 @@ ACTION_P(RequestCanceled, loader) { loader->didFail(NULL, error); } +// Predicate that tests that request disallows compressed data. +static bool CorrectAcceptEncoding(const WebKit::WebURLRequest &request) { + std::string value = request.httpHeaderField( + WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding)).utf8(); + return (value.find("identity;q=1") != std::string::npos) && + (value.find("*;q=0") != std::string::npos); +} + class BufferedResourceLoaderTest : public testing::Test { public: BufferedResourceLoaderTest() @@ -98,7 +110,8 @@ class BufferedResourceLoaderTest : public testing::Test { void Start() { InSequence s; - EXPECT_CALL(*url_loader_, loadAsynchronously(_, loader_.get())); + EXPECT_CALL(*url_loader_, loadAsynchronously(Truly(CorrectAcceptEncoding), + loader_.get())); loader_->Start( NewCallback(this, &BufferedResourceLoaderTest::StartCallback), NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback), diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc index 6647e52..57c51ad 100644 --- a/webkit/glue/media/simple_data_source.cc +++ b/webkit/glue/media/simple_data_source.cc @@ -9,12 +9,16 @@ #include "media/base/filter_host.h" #include "net/base/data_url.h" #include "net/base/load_flags.h" +#include "net/http/http_request_headers.h" #include "net/url_request/url_request_status.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "webkit/glue/media/web_data_source_factory.h" #include "webkit/glue/webkit_glue.h" +using WebKit::WebString; + namespace webkit_glue { static const char kDataScheme[] = "data"; @@ -300,6 +304,11 @@ void SimpleDataSource::StartTask() { frame_->setReferrerForRequest(request, WebKit::WebURL()); + // Disable compression, compression for audio/video doesn't make sense... + request.setHTTPHeaderField( + WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), + WebString::fromUTF8("identity;q=1, *;q=0")); + // This flag is for unittests as we don't want to reset |url_loader| if (!keep_test_loader_) url_loader_.reset(frame_->createAssociatedURLLoader()); |