| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "platform/heap/Handle.h" | 45 #include "platform/heap/Handle.h" |
| 46 #include "platform/network/ResourceResponse.h" | 46 #include "platform/network/ResourceResponse.h" |
| 47 #include "wtf/Vector.h" | 47 #include "wtf/Vector.h" |
| 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 GarbageCollectedMixin { |
| 56 public: | 56 public: |
| 57 virtual ~Client() = default; | 57 virtual ~Client() = default; |
| 58 virtual void onePartInMultipartReceived(const ResourceResponse&) = 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 skippableLengthForTest(const Vector<char>& data, size_t size)
{ return skippableLength(data, size); } | 70 static size_t skippableLengthForTest(const Vector<char>& data, size_t size)
{ return skippableLength(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 skippableLength(const Vector<char>&, size_t); | 76 static size_t skippableLength(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 Member<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_isCancelled = false; | 88 bool m_isCancelled = false; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| 92 | 92 |
| 93 #endif // MultipartImageResourceParser_h | 93 #endif // MultipartImageResourceParser_h |
| OLD | NEW |