[Mac] PepperFlash default on DEV channel.
[chromium-blink-merge.git] / webkit / media / test_response_generator.h
blobf73e94bcb81fc0b0b04d7d74164226add15ed5cd
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WEBKIT_MEDIA_TEST_RESPONSE_GENERATOR_H_
6 #define WEBKIT_MEDIA_TEST_RESPONSE_GENERATOR_H_
8 #include "base/basictypes.h"
9 #include "googleurl/src/gurl.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h"
13 namespace webkit_media {
15 // Generates WebURLErrors and WebURLResponses suitable for testing purposes.
16 class TestResponseGenerator {
17 public:
18 enum Flags {
19 kNormal = 0,
20 kNoAcceptRanges = 1 << 0, // Don't include Accept-Ranges in 206 response.
21 kNoContentRange = 1 << 1, // Don't include Content-Range in 206 response.
22 kNoContentLength = 1 << 2, // Don't include Content-Length in 206 response.
23 kNoContentRangeInstanceSize = 1 << 3, // Content-Range: N-M/* in 206.
26 // Build an HTTP response generator for the given URL. |content_length| is
27 // used to generate Content-Length and Content-Range headers.
28 TestResponseGenerator(const GURL& gurl, int64 content_length);
30 // Generates a WebURLError object.
31 WebKit::WebURLError GenerateError();
33 // Generates a regular HTTP 200 response.
34 WebKit::WebURLResponse Generate200();
36 // Generates a regular HTTP 206 response starting from |first_byte_offset|
37 // until the end of the resource.
38 WebKit::WebURLResponse Generate206(int64 first_byte_offset);
40 // Generates a custom HTTP 206 response starting from |first_byte_offset|
41 // until the end of the resource. You can tweak what gets included in the
42 // headers via |flags|.
43 WebKit::WebURLResponse Generate206(int64 first_byte_offset, Flags flags);
45 // Generates a regular HTTP 404 response.
46 WebKit::WebURLResponse Generate404();
48 // Generates a file:// response starting from |first_byte_offset| until the
49 // end of the resource.
51 // If |first_byte_offset| is negative a response containing no content length
52 // will be returned.
53 WebKit::WebURLResponse GenerateFileResponse(int64 first_byte_offset);
55 const GURL& gurl() { return gurl_; }
56 int64 content_length() { return content_length_; }
58 private:
59 GURL gurl_;
60 int64 content_length_;
62 DISALLOW_COPY_AND_ASSIGN(TestResponseGenerator);
65 } // namespace webkit_media
67 #endif // WEBKIT_MEDIA_TEST_RESPONSE_GENERATOR_H_