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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/MultipartParser.h

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: Rebase Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef MultipartParser_h
6 #define MultipartParser_h
7
8 #include "modules/ModulesExport.h"
9 #include "platform/heap/Handle.h"
10 #include "platform/network/ResourceResponse.h"
11 #include "wtf/Vector.h"
12
13 namespace blink {
14
15 class MODULES_EXPORT MultipartParser final : public GarbageCollectedFinalized<Mu ltipartParser> {
16 WTF_MAKE_NONCOPYABLE(MultipartParser);
17
18 public:
19 class MODULES_EXPORT Client : public GarbageCollectedMixin {
20 public:
21 virtual ~Client() = default;
22 virtual void partHeaderFieldsInMultipartReceived(const ResourceResponse& ) = 0;
23 virtual void partDataInMultipartReceived(const char* bytes, size_t) = 0;
yhirano 2016/09/12 02:20:49 It looks you include the delimiter to the "part da
yhirano 2016/09/12 02:20:49 Can |size| be zero? I don't think it problematic b
e_hakkinen 2016/09/16 13:41:37 I do not include the delimiter to the "part data".
e_hakkinen 2016/09/16 13:41:37 No, |size| cannot be zero. To me, it sounds contra
yhirano 2016/09/20 09:49:53 Then please write so. Unless you express such thin
yhirano 2016/09/20 09:49:53 Sorry, I misunderstood. Thanks for the explanation
24 virtual void partDataInMultipartFullyReceived() = 0;
25 DEFINE_INLINE_VIRTUAL_TRACE() {}
26 };
27
28 MultipartParser(Vector<char> boundary, Client*);
29 bool appendData(const char* bytes, size_t);
30 void cancel();
31 bool finish();
32
33 bool isCancelled() const { return m_state == Cancelled; }
34
35 DECLARE_TRACE();
36
37 private:
38 size_t countNonDelimiterBytes(const char* bytes, size_t) const;
39 size_t countPossibleDelimiterBytes(const char* bytes, size_t) const;
40 size_t countTransportPaddingBytes(const char* bytes, size_t) const;
41 bool parseDelimiter(const char* bytes, size_t, size_t* index);
42 bool parseDelimiterSuffix(const char* bytes, size_t, size_t* index, const ch ar* suffix);
43 size_t seenDelimiterSuffixLength() const;
44
45 Vector<char> m_delimiter;
46 Member<Client> m_client;
47 size_t m_seenDelimiterLength;
48 size_t m_seenDelimiterOffset;
49 Vector<char> m_seenHeaderBytes;
50
51 enum State {
52 ParsingPreamble,
53 ParsingDelimiterSuffix,
54 ParsingPartHeaderFields,
55 ParsingPartOctets,
56 ParsingDelimiterOrCloseDelimiterSuffix,
57 ParsingCloseDelimiterSuffix,
58 ParsingEpilogue,
59 Cancelled,
60 Failed,
61 Finished
62 } m_state;
63 };
64
65 } // namespace blink
66
67 #endif // MultipartParser_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698