Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: Source/core/platform/network/FormData.h

Issue 27537012: Break core/platform/network dependency on core (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FormSubmission.cpp ('k') | Source/core/platform/network/FormData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 16 matching lines...) Expand all
27 #include "wtf/Vector.h" 27 #include "wtf/Vector.h"
28 #include "wtf/text/WTFString.h" 28 #include "wtf/text/WTFString.h"
29 29
30 namespace WTF{ 30 namespace WTF{
31 class TextEncoding; 31 class TextEncoding;
32 } 32 }
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 class BlobDataHandle; 36 class BlobDataHandle;
37 class FormDataList;
38 37
39 class FormDataElement { 38 class FormDataElement {
40 public: 39 public:
41 FormDataElement() : m_type(data) { } 40 FormDataElement() : m_type(data) { }
42 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a rray) { } 41 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a rray) { }
43 42
44 FormDataElement(const String& filename, long long fileStart, long long fileL ength, double expectedFileModificationTime) : m_type(encodedFile), m_filename(fi lename), m_fileStart(fileStart), m_fileLength(fileLength), m_expectedFileModific ationTime(expectedFileModificationTime) { } 43 FormDataElement(const String& filename, long long fileStart, long long fileL ength, double expectedFileModificationTime) : m_type(encodedFile), m_filename(fi lename), m_fileStart(fileStart), m_fileLength(fileLength), m_expectedFileModific ationTime(expectedFileModificationTime) { }
45 explicit FormDataElement(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalHandle) : m_type(encodedBlob), m_blobUUID(blobUUID), m_optionalBlobDataH andle(optionalHandle) { } 44 explicit FormDataElement(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalHandle) : m_type(encodedBlob), m_blobUUID(blobUUID), m_optionalBlobDataH andle(optionalHandle) { }
46 FormDataElement(const KURL& fileSystemURL, long long start, long long length , double expectedFileModificationTime) : m_type(encodedFileSystemURL), m_fileSys temURL(fileSystemURL), m_fileStart(start), m_fileLength(length), m_expectedFileM odificationTime(expectedFileModificationTime) { } 45 FormDataElement(const KURL& fileSystemURL, long long start, long long length , double expectedFileModificationTime) : m_type(encodedFileSystemURL), m_fileSys temURL(fileSystemURL), m_fileStart(start), m_fileLength(length), m_expectedFileM odificationTime(expectedFileModificationTime) { }
47 46
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 enum EncodingType { 89 enum EncodingType {
91 FormURLEncoded, // for application/x-www-form-urlencoded 90 FormURLEncoded, // for application/x-www-form-urlencoded
92 TextPlain, // for text/plain 91 TextPlain, // for text/plain
93 MultipartFormData // for multipart/form-data 92 MultipartFormData // for multipart/form-data
94 }; 93 };
95 94
96 static PassRefPtr<FormData> create(); 95 static PassRefPtr<FormData> create();
97 static PassRefPtr<FormData> create(const void*, size_t); 96 static PassRefPtr<FormData> create(const void*, size_t);
98 static PassRefPtr<FormData> create(const CString&); 97 static PassRefPtr<FormData> create(const CString&);
99 static PassRefPtr<FormData> create(const Vector<char>&); 98 static PassRefPtr<FormData> create(const Vector<char>&);
100 static PassRefPtr<FormData> create(const FormDataList&, const WTF::TextEncod ing&, EncodingType = FormURLEncoded);
101 static PassRefPtr<FormData> createMultiPart(const FormDataList&, const WTF:: TextEncoding&);
102 PassRefPtr<FormData> copy() const; 99 PassRefPtr<FormData> copy() const;
103 PassRefPtr<FormData> deepCopy() const; 100 PassRefPtr<FormData> deepCopy() const;
104 ~FormData(); 101 ~FormData();
105 102
106 void appendData(const void* data, size_t); 103 void appendData(const void* data, size_t);
107 void appendFile(const String& filePath); 104 void appendFile(const String& filePath);
108 void appendFileRange(const String& filename, long long start, long long leng th, double expectedModificationTime); 105 void appendFileRange(const String& filename, long long start, long long leng th, double expectedModificationTime);
109 void appendBlob(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalH andle); 106 void appendBlob(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalH andle);
110 void appendFileSystemURL(const KURL&); 107 void appendFileSystemURL(const KURL&);
111 void appendFileSystemURLRange(const KURL&, long long start, long long length , double expectedModificationTime); 108 void appendFileSystemURLRange(const KURL&, long long start, long long length , double expectedModificationTime);
112 109
113 void flatten(Vector<char>&) const; // omits files 110 void flatten(Vector<char>&) const; // omits files
114 String flattenToString() const; // omits files 111 String flattenToString() const; // omits files
115 112
116 bool isEmpty() const { return m_elements.isEmpty(); } 113 bool isEmpty() const { return m_elements.isEmpty(); }
117 const Vector<FormDataElement>& elements() const { return m_elements; } 114 const Vector<FormDataElement>& elements() const { return m_elements; }
115
118 const Vector<char>& boundary() const { return m_boundary; } 116 const Vector<char>& boundary() const { return m_boundary; }
117 void setBoundary(Vector<char> boundary) { m_boundary = boundary; }
119 118
120 bool alwaysStream() const { return m_alwaysStream; } 119 bool alwaysStream() const { return m_alwaysStream; }
121 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; } 120 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; }
122 121
123 // Identifies a particular form submission instance. A value of 0 is used 122 // Identifies a particular form submission instance. A value of 0 is used
124 // to indicate an unspecified identifier. 123 // to indicate an unspecified identifier.
125 void setIdentifier(int64_t identifier) { m_identifier = identifier; } 124 void setIdentifier(int64_t identifier) { m_identifier = identifier; }
126 int64_t identifier() const { return m_identifier; } 125 int64_t identifier() const { return m_identifier; }
127 126
128 bool containsPasswordData() const { return m_containsPasswordData; } 127 bool containsPasswordData() const { return m_containsPasswordData; }
129 void setContainsPasswordData(bool containsPasswordData) { m_containsPassword Data = containsPasswordData; } 128 void setContainsPasswordData(bool containsPasswordData) { m_containsPassword Data = containsPasswordData; }
130 129
131 static EncodingType parseEncodingType(const String& type) 130 static EncodingType parseEncodingType(const String& type)
132 { 131 {
133 if (equalIgnoringCase(type, "text/plain")) 132 if (equalIgnoringCase(type, "text/plain"))
134 return TextPlain; 133 return TextPlain;
135 if (equalIgnoringCase(type, "multipart/form-data")) 134 if (equalIgnoringCase(type, "multipart/form-data"))
136 return MultipartFormData; 135 return MultipartFormData;
137 return FormURLEncoded; 136 return FormURLEncoded;
138 } 137 }
139 138
140 private: 139 private:
141 FormData(); 140 FormData();
142 FormData(const FormData&); 141 FormData(const FormData&);
143 142
144 void appendKeyValuePairItems(const FormDataList&, const WTF::TextEncoding&, bool isMultiPartForm, EncodingType = FormURLEncoded);
145
146 Vector<FormDataElement> m_elements; 143 Vector<FormDataElement> m_elements;
147 144
148 int64_t m_identifier; 145 int64_t m_identifier;
149 bool m_alwaysStream; 146 bool m_alwaysStream;
150 Vector<char> m_boundary; 147 Vector<char> m_boundary;
151 bool m_containsPasswordData; 148 bool m_containsPasswordData;
152 }; 149 };
153 150
154 inline bool operator==(const FormData& a, const FormData& b) 151 inline bool operator==(const FormData& a, const FormData& b)
155 { 152 {
156 return a.elements() == b.elements(); 153 return a.elements() == b.elements();
157 } 154 }
158 155
159 inline bool operator!=(const FormData& a, const FormData& b) 156 inline bool operator!=(const FormData& a, const FormData& b)
160 { 157 {
161 return !(a == b); 158 return !(a == b);
162 } 159 }
163 160
164 } // namespace WebCore 161 } // namespace WebCore
165 162
166 #endif 163 #endif
OLDNEW
« no previous file with comments | « Source/core/loader/FormSubmission.cpp ('k') | Source/core/platform/network/FormData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698