diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 21:59:16 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 21:59:16 +0000 |
commit | 9830942170ffdfa01625dc1b34fcc3138e873071 (patch) | |
tree | d3077810b2f5b79466824009aadbfd01703270ac /webkit/media/test_response_generator.h | |
parent | 84f4dc00fe3211465900921ab044cc95606c8f85 (diff) | |
download | chromium_src-9830942170ffdfa01625dc1b34fcc3138e873071.zip chromium_src-9830942170ffdfa01625dc1b34fcc3138e873071.tar.gz chromium_src-9830942170ffdfa01625dc1b34fcc3138e873071.tar.bz2 |
Rewrite BufferedDataSource tests to use real BufferedResourceLoader objects.
The new tests expose the very real memory leak described in bug 100914. The fix for the leak is non trivial and will be addressed in a follow up patch.
BUG=100914
Review URL: http://codereview.chromium.org/8649002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media/test_response_generator.h')
-rw-r--r-- | webkit/media/test_response_generator.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/webkit/media/test_response_generator.h b/webkit/media/test_response_generator.h new file mode 100644 index 0000000..fbdf5a8 --- /dev/null +++ b/webkit/media/test_response_generator.h @@ -0,0 +1,59 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_MEDIA_TEST_RESPONSE_GENERATOR_H_ +#define WEBKIT_MEDIA_TEST_RESPONSE_GENERATOR_H_ + +#include "base/basictypes.h" +#include "googleurl/src/gurl.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" + +namespace webkit_media { + +// Generates WebURLErrors and WebURLResponses suitable for testing purposes. +class TestResponseGenerator { + public: + enum Flags { + kNormal = 0, + kNoAcceptRanges = 1 << 0, // Don't include Accept-Ranges in 206 response. + kNoContentRange = 1 << 1, // Don't include Content-Range in 206 response. + kNoContentLength = 1 << 2, // Don't include Content-Length in 206 response. + }; + + // Build an HTTP response generator for the given URL. |content_length| is + // used to generate Content-Length and Content-Range headers. + TestResponseGenerator(const GURL& gurl, int64 content_length); + + // Generates a WebURLError object. + WebKit::WebURLError GenerateError(); + + // Generates a regular HTTP 200 response. + WebKit::WebURLResponse Generate200(); + + // Generates a regular HTTP 206 response starting from |first_byte_offset| + // until the end of the resource. + WebKit::WebURLResponse Generate206(int64 first_byte_offset); + + // Generates a custom HTTP 206 response starting from |first_byte_offset| + // until the end of the resource. You can tweak what gets included in the + // headers via |flags|. + WebKit::WebURLResponse Generate206(int64 first_byte_offset, Flags flags); + + // Generates a regular HTTP 404 response. + WebKit::WebURLResponse Generate404(); + + const GURL& gurl() { return gurl_; } + int64 content_length() { return content_length_; } + + private: + GURL gurl_; + int64 content_length_; + + DISALLOW_COPY_AND_ASSIGN(TestResponseGenerator); +}; + +} // namespace webkit_media + +#endif // WEBKIT_MEDIA_TEST_RESPONSE_GENERATOR_H_ |