summaryrefslogtreecommitdiffstats
path: root/media/blink/test_response_generator.h
diff options
context:
space:
mode:
authoracolwell <acolwell@chromium.org>2014-09-06 12:01:32 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-06 19:06:46 +0000
commit9e0840d0672da96350a1f33d684f2c64d2574f46 (patch)
tree6d72e3d50fcfd66f70a58c5d3583358055de4d9a /media/blink/test_response_generator.h
parent87a3ebac6b26918b151151efed3311d0ddc20d73 (diff)
downloadchromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.zip
chromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.tar.gz
chromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.tar.bz2
Move WebMediaPlayerImpl and its dependencies to media/blink.
Moving WebMediaPlayerImpl and related classes in content/renderer/media to media/blink so that they can be reused by Mojo code. BUG=408338 Review URL: https://codereview.chromium.org/495353003 Cr-Commit-Position: refs/heads/master@{#293628}
Diffstat (limited to 'media/blink/test_response_generator.h')
-rw-r--r--media/blink/test_response_generator.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/media/blink/test_response_generator.h b/media/blink/test_response_generator.h
new file mode 100644
index 0000000..7e3e98d
--- /dev/null
+++ b/media/blink/test_response_generator.h
@@ -0,0 +1,66 @@
+// Copyright 2013 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 MEDIA_BLINK_TEST_RESPONSE_GENERATOR_H_
+#define MEDIA_BLINK_TEST_RESPONSE_GENERATOR_H_
+
+#include "base/basictypes.h"
+#include "third_party/WebKit/public/platform/WebURLError.h"
+#include "third_party/WebKit/public/platform/WebURLResponse.h"
+#include "url/gurl.h"
+
+namespace 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.
+ kNoContentRangeInstanceSize = 1 << 3, // Content-Range: N-M/* in 206.
+ };
+
+ // 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.
+ blink::WebURLError GenerateError();
+
+ // Generates a regular HTTP 200 response.
+ blink::WebURLResponse Generate200();
+
+ // Generates a regular HTTP 206 response starting from |first_byte_offset|
+ // until the end of the resource.
+ blink::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|.
+ blink::WebURLResponse Generate206(int64 first_byte_offset, Flags flags);
+
+ // Generates a regular HTTP 404 response.
+ blink::WebURLResponse Generate404();
+
+ // Generates a file:// response starting from |first_byte_offset| until the
+ // end of the resource.
+ //
+ // If |first_byte_offset| is negative a response containing no content length
+ // will be returned.
+ blink::WebURLResponse GenerateFileResponse(int64 first_byte_offset);
+
+ int64 content_length() { return content_length_; }
+
+ private:
+ GURL gurl_;
+ int64 content_length_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestResponseGenerator);
+};
+
+} // namespace media
+
+#endif // MEDIA_BLINK_TEST_RESPONSE_GENERATOR_H_