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

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

Issue 23992003: blob hacking webcore style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/core/platform/network/BlobData.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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef FormData_h 20 #ifndef FormData_h
21 #define FormData_h 21 #define FormData_h
22 22
23 #include "core/platform/network/BlobData.h"
23 #include "weborigin/KURL.h" 24 #include "weborigin/KURL.h"
24 #include "wtf/Forward.h" 25 #include "wtf/Forward.h"
25 #include "wtf/RefCounted.h" 26 #include "wtf/RefCounted.h"
26 #include "wtf/Vector.h" 27 #include "wtf/Vector.h"
27 #include "wtf/text/WTFString.h" 28 #include "wtf/text/WTFString.h"
28 29
29 namespace WTF{ 30 namespace WTF{
30 class TextEncoding; 31 class TextEncoding;
31 } 32 }
32 33
33 namespace WebCore { 34 namespace WebCore {
34 35
36 class BlobDataHandle;
35 class FormDataList; 37 class FormDataList;
36 38
37 class FormDataElement { 39 class FormDataElement {
38 public: 40 public:
39 FormDataElement() : m_type(data) { } 41 FormDataElement() : m_type(data) { }
40 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a rray) { } 42 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a rray) { }
41 43
42 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) { } 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 explicit FormDataElement(const KURL& blobURL) : m_type(encodedBlob), m_url(b lobURL) { } 45 explicit FormDataElement(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalHandle) : m_type(encodedBlob), m_blobUUID(blobUUID), m_optionalBlobDataH andle(optionalHandle) { }
44 FormDataElement(const KURL& url, long long start, long long length, double e xpectedFileModificationTime) : m_type(encodedURL), m_url(url), m_fileStart(start ), m_fileLength(length), m_expectedFileModificationTime(expectedFileModification Time) { } 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 47
46 enum Type { 48 enum Type {
47 data, 49 data,
48 encodedFile 50 encodedFile,
49 , encodedBlob 51 encodedBlob,
50 , encodedURL 52 encodedFileSystemURL
51 } m_type; 53 } m_type;
52 Vector<char> m_data; 54 Vector<char> m_data;
53 String m_filename; 55 String m_filename;
54 KURL m_url; // For Blob or URL. 56 String m_blobUUID;
57 RefPtr<BlobDataHandle> m_optionalBlobDataHandle;
58 KURL m_fileSystemURL;
55 long long m_fileStart; 59 long long m_fileStart;
56 long long m_fileLength; 60 long long m_fileLength;
57 double m_expectedFileModificationTime; 61 double m_expectedFileModificationTime;
58 }; 62 };
59 63
60 inline bool operator==(const FormDataElement& a, const FormDataElement& b) 64 inline bool operator==(const FormDataElement& a, const FormDataElement& b)
61 { 65 {
62 if (&a == &b) 66 if (&a == &b)
63 return true; 67 return true;
64 68
65 if (a.m_type != b.m_type) 69 if (a.m_type != b.m_type)
66 return false; 70 return false;
67 if (a.m_type == FormDataElement::data) 71 if (a.m_type == FormDataElement::data)
68 return a.m_data == b.m_data; 72 return a.m_data == b.m_data;
69 if (a.m_type == FormDataElement::encodedFile) 73 if (a.m_type == FormDataElement::encodedFile)
70 return a.m_filename == b.m_filename && a.m_fileStart == b.m_fileStart && a.m_fileLength == b.m_fileLength && a.m_expectedFileModificationTime == b.m_exp ectedFileModificationTime; 74 return a.m_filename == b.m_filename && a.m_fileStart == b.m_fileStart && a.m_fileLength == b.m_fileLength && a.m_expectedFileModificationTime == b.m_exp ectedFileModificationTime;
71 if (a.m_type == FormDataElement::encodedBlob) 75 if (a.m_type == FormDataElement::encodedBlob)
72 return a.m_url == b.m_url; 76 return a.m_blobUUID == b.m_blobUUID;
73 if (a.m_type == FormDataElement::encodedURL) 77 if (a.m_type == FormDataElement::encodedFileSystemURL)
74 return a.m_url == b.m_url; 78 return a.m_fileSystemURL == b.m_fileSystemURL;
75 79
76 return true; 80 return true;
77 } 81 }
78 82
79 inline bool operator!=(const FormDataElement& a, const FormDataElement& b) 83 inline bool operator!=(const FormDataElement& a, const FormDataElement& b)
80 { 84 {
81 return !(a == b); 85 return !(a == b);
82 } 86 }
83 87
84 class FormData : public RefCounted<FormData> { 88 class FormData : public RefCounted<FormData> {
(...skipping 10 matching lines...) Expand all
95 static PassRefPtr<FormData> create(const Vector<char>&); 99 static PassRefPtr<FormData> create(const Vector<char>&);
96 static PassRefPtr<FormData> create(const FormDataList&, const WTF::TextEncod ing&, EncodingType = FormURLEncoded); 100 static PassRefPtr<FormData> create(const FormDataList&, const WTF::TextEncod ing&, EncodingType = FormURLEncoded);
97 static PassRefPtr<FormData> createMultiPart(const FormDataList&, const WTF:: TextEncoding&); 101 static PassRefPtr<FormData> createMultiPart(const FormDataList&, const WTF:: TextEncoding&);
98 PassRefPtr<FormData> copy() const; 102 PassRefPtr<FormData> copy() const;
99 PassRefPtr<FormData> deepCopy() const; 103 PassRefPtr<FormData> deepCopy() const;
100 ~FormData(); 104 ~FormData();
101 105
102 void appendData(const void* data, size_t); 106 void appendData(const void* data, size_t);
103 void appendFile(const String& filePath); 107 void appendFile(const String& filePath);
104 void appendFileRange(const String& filename, long long start, long long leng th, double expectedModificationTime); 108 void appendFileRange(const String& filename, long long start, long long leng th, double expectedModificationTime);
105 void appendBlob(const KURL& blobURL); 109 void appendBlob(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalH andle);
106 void appendURL(const KURL&); 110 void appendFileSystemURL(const KURL&);
107 void appendURLRange(const KURL&, long long start, long long length, double e xpectedModificationTime); 111 void appendFileSystemURLRange(const KURL&, long long start, long long length , double expectedModificationTime);
108 112
109 void flatten(Vector<char>&) const; // omits files 113 void flatten(Vector<char>&) const; // omits files
110 String flattenToString() const; // omits files 114 String flattenToString() const; // omits files
111 115
112 bool isEmpty() const { return m_elements.isEmpty(); } 116 bool isEmpty() const { return m_elements.isEmpty(); }
113 const Vector<FormDataElement>& elements() const { return m_elements; } 117 const Vector<FormDataElement>& elements() const { return m_elements; }
114 const Vector<char>& boundary() const { return m_boundary; } 118 const Vector<char>& boundary() const { return m_boundary; }
115 119
116 bool alwaysStream() const { return m_alwaysStream; } 120 bool alwaysStream() const { return m_alwaysStream; }
117 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; } 121 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 157 }
154 158
155 inline bool operator!=(const FormData& a, const FormData& b) 159 inline bool operator!=(const FormData& a, const FormData& b)
156 { 160 {
157 return !(a == b); 161 return !(a == b);
158 } 162 }
159 163
160 } // namespace WebCore 164 } // namespace WebCore
161 165
162 #endif 166 #endif
OLDNEW
« no previous file with comments | « Source/core/platform/network/BlobData.cpp ('k') | Source/core/platform/network/FormData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698