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

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;
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 class Buffer {
yhirano 2016/09/20 09:49:53 This class is used in a two ways: 1. It is a matc
e_hakkinen 2016/09/20 21:59:29 Done.
39 public:
40 Buffer();
41 Buffer(const char* first, const char* last);
42 Buffer(const char* data, size_t, size_t capacity);
43
44 bool appendIfExpected(char value);
45 bool appendIfExpected(const char* first, const char* last);
46 void clear();
47
48 bool empty() const { return size() == 0u; }
49 const char* data() const { return m_data; }
50 size_t size() const { return m_size; }
51
52 private:
53 size_t m_capacity = 0u;
54 const char* m_data = nullptr;
55 size_t m_size = 0u;
56 };
57
58 Buffer closeDelimiterSuffixBuffer(size_t = 0u) const;
yhirano 2016/09/20 09:49:53 The parameter is never specified.
e_hakkinen 2016/09/20 21:59:29 Done.
59 Buffer delimiterBuffer(size_t = 0u) const;
60 Buffer delimiterSuffixBuffer(size_t = 0u) const;
yhirano 2016/09/20 09:49:53 The parameter is never specified.
e_hakkinen 2016/09/20 21:59:29 Done.
61
62 bool parseDataAndDelimiter(const char** bytesPointer, const char* bytesEnd, Buffer* data);
yhirano 2016/09/20 09:49:53 These three functions are named in the same manner
e_hakkinen 2016/09/20 21:59:29 They return true only when they have parsed what t
63 bool parseHeaderFields(const char** bytesPointer, const char* bytesEnd, WebU RLResponse*);
64 bool parseTransportPadding(const char** bytesPointer, const char* bytesEnd) const;
65
66 Buffer m_bufferedBytes;
67 Vector<char> m_bufferedHeaderBytes;
68 Member<Client> m_client;
69 Vector<char> m_delimiter;
70
71 enum State {
72 ParsingPreamble,
73 ParsingDelimiterSuffix,
74 ParsingPartHeaderFields,
75 ParsingPartOctets,
76 ParsingDelimiterOrCloseDelimiterSuffix,
77 ParsingCloseDelimiterSuffix,
78 ParsingEpilogue,
79 Cancelled,
80 Failed,
81 Finished
82 } m_state;
83 };
84
85 } // namespace blink
86
87 #endif // MultipartParser_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698