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

Side by Side Diff: third_party/WebKit/Source/core/fetch/MultipartImageResourceParser.h

Issue 1756953002: Stop dispatching notifyFinished for each part in a multipart response (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup-2
Patch Set: Created 4 years, 9 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /* ***** BEGIN LICENSE BLOCK ***** 5 /* ***** BEGIN LICENSE BLOCK *****
6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * 7 *
8 * The contents of this file are subject to the Mozilla Public License Version 8 * The contents of this file are subject to the Mozilla Public License Version
9 * 1.1 (the "License"); you may not use this file except in compliance with 9 * 1.1 (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at 10 * the License. You may obtain a copy of the License at
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 namespace blink { 49 namespace blink {
50 50
51 // A parser parsing mlutipart/x-mixed-replace resource. 51 // A parser parsing mlutipart/x-mixed-replace resource.
52 class CORE_EXPORT MultipartImageResourceParser final : public GarbageCollectedFi nalized<MultipartImageResourceParser> { 52 class CORE_EXPORT MultipartImageResourceParser final : public GarbageCollectedFi nalized<MultipartImageResourceParser> {
53 WTF_MAKE_NONCOPYABLE(MultipartImageResourceParser); 53 WTF_MAKE_NONCOPYABLE(MultipartImageResourceParser);
54 public: 54 public:
55 class CORE_EXPORT Client : public WillBeGarbageCollectedMixin { 55 class CORE_EXPORT Client : public WillBeGarbageCollectedMixin {
56 public: 56 public:
57 virtual ~Client() = default; 57 virtual ~Client() = default;
58 virtual void onePartInMultipartReceived(const ResourceResponse&, bool is FirstPart) = 0; 58 virtual void onePartInMultipartReceived(const ResourceResponse&) = 0;
59 virtual void multipartDataReceived(const char* bytes, size_t) = 0; 59 virtual void multipartDataReceived(const char* bytes, size_t) = 0;
60 DEFINE_INLINE_VIRTUAL_TRACE() {} 60 DEFINE_INLINE_VIRTUAL_TRACE() {}
61 }; 61 };
62 62
63 MultipartImageResourceParser(const ResourceResponse&, const Vector<char>& bo undary, Client*); 63 MultipartImageResourceParser(const ResourceResponse&, const Vector<char>& bo undary, Client*);
64 void appendData(const char* bytes, size_t); 64 void appendData(const char* bytes, size_t);
65 void finish(); 65 void finish();
66 void cancel() { m_isCancelled = true; } 66 void cancel() { m_isCancelled = true; }
67 67
68 DECLARE_TRACE(); 68 DECLARE_TRACE();
69 69
70 static size_t pushOverLineForTest(const Vector<char>& data, size_t size) { r eturn pushOverLine(data, size); } 70 static size_t pushOverLineForTest(const Vector<char>& data, size_t size) { r eturn pushOverLine(data, size); }
71 static size_t findBoundaryForTest(const Vector<char>& data, Vector<char>* bo undary) { return findBoundary(data, boundary); } 71 static size_t findBoundaryForTest(const Vector<char>& data, Vector<char>* bo undary) { return findBoundary(data, boundary); }
72 72
73 private: 73 private:
74 bool parseHeaders(); 74 bool parseHeaders();
75 bool isCancelled() const { return m_isCancelled; } 75 bool isCancelled() const { return m_isCancelled; }
76 static size_t pushOverLine(const Vector<char>&, size_t); 76 static size_t pushOverLine(const Vector<char>&, size_t);
77 // This function updates |*boundary|. 77 // This function updates |*boundary|.
78 static size_t findBoundary(const Vector<char>& data, Vector<char>* boundary) ; 78 static size_t findBoundary(const Vector<char>& data, Vector<char>* boundary) ;
79 79
80 const ResourceResponse m_originalResponse; 80 const ResourceResponse m_originalResponse;
81 Vector<char> m_boundary; 81 Vector<char> m_boundary;
82 RawPtrWillBeMember<Client> m_client; 82 RawPtrWillBeMember<Client> m_client;
83 83
84 Vector<char> m_data; 84 Vector<char> m_data;
85 bool m_isParsingTop = true; 85 bool m_isParsingTop = true;
86 bool m_isParsingHeaders = false; 86 bool m_isParsingHeaders = false;
87 bool m_sawLastBoundary = false; 87 bool m_sawLastBoundary = false;
88 bool m_isFirstPart = true;
89 bool m_isCancelled = false; 88 bool m_isCancelled = false;
90 }; 89 };
91 90
92 } // namespace blink 91 } // namespace blink
93 92
94 #endif // MultipartImageResourceParser_h 93 #endif // MultipartImageResourceParser_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698