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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/fetch/MultipartParser.h
diff --git a/third_party/WebKit/Source/modules/fetch/MultipartParser.h b/third_party/WebKit/Source/modules/fetch/MultipartParser.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc8033ab9a541225898e0e05069e9ad495fb6bdc
--- /dev/null
+++ b/third_party/WebKit/Source/modules/fetch/MultipartParser.h
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MultipartParser_h
+#define MultipartParser_h
+
+#include "modules/ModulesExport.h"
+#include "platform/heap/Handle.h"
+#include "platform/network/ResourceResponse.h"
+#include "wtf/Vector.h"
+
+namespace blink {
+
+class MODULES_EXPORT MultipartParser final : public GarbageCollectedFinalized<MultipartParser> {
+ WTF_MAKE_NONCOPYABLE(MultipartParser);
+
+public:
+ class MODULES_EXPORT Client : public GarbageCollectedMixin {
+ public:
+ virtual ~Client() = default;
+ virtual void partHeaderFieldsInMultipartReceived(const ResourceResponse&) = 0;
+ 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
+ virtual void partDataInMultipartFullyReceived() = 0;
+ DEFINE_INLINE_VIRTUAL_TRACE() {}
+ };
+
+ MultipartParser(Vector<char> boundary, Client*);
+ bool appendData(const char* bytes, size_t);
+ void cancel();
+ bool finish();
+
+ bool isCancelled() const { return m_state == Cancelled; }
+
+ DECLARE_TRACE();
+
+private:
+ size_t countNonDelimiterBytes(const char* bytes, size_t) const;
+ size_t countPossibleDelimiterBytes(const char* bytes, size_t) const;
+ size_t countTransportPaddingBytes(const char* bytes, size_t) const;
+ bool parseDelimiter(const char* bytes, size_t, size_t* index);
+ bool parseDelimiterSuffix(const char* bytes, size_t, size_t* index, const char* suffix);
+ size_t seenDelimiterSuffixLength() const;
+
+ Vector<char> m_delimiter;
+ Member<Client> m_client;
+ size_t m_seenDelimiterLength;
+ size_t m_seenDelimiterOffset;
+ Vector<char> m_seenHeaderBytes;
+
+ enum State {
+ ParsingPreamble,
+ ParsingDelimiterSuffix,
+ ParsingPartHeaderFields,
+ ParsingPartOctets,
+ ParsingDelimiterOrCloseDelimiterSuffix,
+ ParsingCloseDelimiterSuffix,
+ ParsingEpilogue,
+ Cancelled,
+ Failed,
+ Finished
+ } m_state;
+};
+
+} // namespace blink
+
+#endif // MultipartParser_h

Powered by Google App Engine
This is Rietveld 408576698