chrome.bluetoothSocket: clean-up Listen functions
[chromium-blink-merge.git] / content / renderer / media / test_response_generator.h
blobdcbcc0544e4deee3264beebdbf02ef723e0af926
1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_TEST_RESPONSE_GENERATOR_H_
6 #define CONTENT_RENDERER_MEDIA_TEST_RESPONSE_GENERATOR_H_
8 #include "base/basictypes.h"
9 #include "third_party/WebKit/public/platform/WebURLError.h"
10 #include "third_party/WebKit/public/platform/WebURLResponse.h"
11 #include "url/gurl.h"
13 namespace content {
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 blink::WebURLError GenerateError();
33 // Generates a regular HTTP 200 response.
34 blink::WebURLResponse Generate200();
36 // Generates a regular HTTP 206 response starting from |first_byte_offset|
37 // until the end of the resource.
38 blink::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 blink::WebURLResponse Generate206(int64 first_byte_offset, Flags flags);
45 // Generates a regular HTTP 404 response.
46 blink::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 blink::WebURLResponse GenerateFileResponse(int64 first_byte_offset);
55 int64 content_length() { return content_length_; }
57 private:
58 GURL gurl_;
59 int64 content_length_;
61 DISALLOW_COPY_AND_ASSIGN(TestResponseGenerator);
64 } // namespace content
66 #endif // CONTENT_RENDERER_MEDIA_TEST_RESPONSE_GENERATOR_H_