2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "WebBlobData.h"
36 #include "WebNonCopyable.h"
37 #include "WebString.h"
41 namespace WebCore { class FormData; }
42 namespace WTF { template <typename T> class PassRefPtr; }
47 class WebHTTPBodyPrivate;
52 enum Type { TypeData, TypeFile, TypeBlob, TypeFileSystemURL } type;
56 long long fileLength; // -1 means to the end of the file.
57 double modificationTime;
62 ~WebHTTPBody() { reset(); }
64 WebHTTPBody() : m_private(0) { }
65 WebHTTPBody(const WebHTTPBody& b) : m_private(0) { assign(b); }
66 WebHTTPBody& operator=(const WebHTTPBody& b)
72 BLINK_PLATFORM_EXPORT void initialize();
73 BLINK_PLATFORM_EXPORT void reset();
74 BLINK_PLATFORM_EXPORT void assign(const WebHTTPBody&);
76 bool isNull() const { return !m_private; }
78 // Returns the number of elements comprising the http body.
79 BLINK_PLATFORM_EXPORT size_t elementCount() const;
81 // Sets the values of the element at the given index. Returns false if
82 // index is out of bounds.
83 BLINK_PLATFORM_EXPORT bool elementAt(size_t index, Element&) const;
85 // Append to the list of elements.
86 BLINK_PLATFORM_EXPORT void appendData(const WebData&);
87 BLINK_PLATFORM_EXPORT void appendFile(const WebString&);
88 // Passing -1 to fileLength means to the end of the file.
89 BLINK_PLATFORM_EXPORT void appendFileRange(const WebString&, long long fileStart, long long fileLength, double modificationTime);
90 BLINK_PLATFORM_EXPORT void appendBlob(const WebString& uuid);
92 // Append a resource which is identified by the FileSystem URL.
93 BLINK_PLATFORM_EXPORT void appendFileSystemURLRange(const WebURL&, long long start, long long length, double modificationTime);
95 // Identifies a particular form submission instance. A value of 0 is
96 // used to indicate an unspecified identifier.
97 BLINK_PLATFORM_EXPORT long long identifier() const;
98 BLINK_PLATFORM_EXPORT void setIdentifier(long long);
100 BLINK_PLATFORM_EXPORT bool containsPasswordData() const;
101 BLINK_PLATFORM_EXPORT void setContainsPasswordData(bool);
104 BLINK_PLATFORM_EXPORT WebHTTPBody(const WTF::PassRefPtr<WebCore::FormData>&);
105 BLINK_PLATFORM_EXPORT WebHTTPBody& operator=(const WTF::PassRefPtr<WebCore::FormData>&);
106 BLINK_PLATFORM_EXPORT operator WTF::PassRefPtr<WebCore::FormData>() const;
110 BLINK_PLATFORM_EXPORT void assign(WebHTTPBodyPrivate*);
111 BLINK_PLATFORM_EXPORT void ensureMutable();
113 WebHTTPBodyPrivate* m_private;