Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 /* ***** BEGIN LICENSE BLOCK ***** | |
| 6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |
| 7 * | |
| 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 | |
| 10 * the License. You may obtain a copy of the License at | |
| 11 * http://www.mozilla.org/MPL/ | |
| 12 * | |
| 13 * Software distributed under the License is distributed on an "AS IS" basis, | |
| 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
| 15 * for the specific language governing rights and limitations under the | |
| 16 * License. | |
| 17 * | |
| 18 * The Original Code is mozilla.org code. | |
| 19 * | |
| 20 * The Initial Developer of the Original Code is | |
| 21 * Netscape Communications Corporation. | |
| 22 * Portions created by the Initial Developer are Copyright (C) 1998 | |
| 23 * the Initial Developer. All Rights Reserved. | |
| 24 * | |
| 25 * Contributor(s): | |
| 26 * | |
| 27 * Alternatively, the contents of this file may be used under the terms of | |
| 28 * either the GNU General Public License Version 2 or later (the "GPL"), or | |
| 29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
| 30 * in which case the provisions of the GPL or the LGPL are applicable instead | |
| 31 * of those above. If you wish to allow use of your version of this file only | |
| 32 * under the terms of either the GPL or the LGPL, and not to allow others to | |
| 33 * use your version of this file under the terms of the MPL, indicate your | |
| 34 * decision by deleting the provisions above and replace them with the notice | |
| 35 * and other provisions required by the GPL or the LGPL. If you do not delete | |
| 36 * the provisions above, a recipient may use your version of this file under | |
| 37 * the terms of any one of the MPL, the GPL or the LGPL. | |
| 38 * | |
| 39 * ***** END LICENSE BLOCK ***** */ | |
| 40 | |
| 41 #ifndef MultipartImageResourceParser_h | |
| 42 #define MultipartImageResourceParser_h | |
| 43 | |
| 44 #include "core/CoreExport.h" | |
| 45 #include "platform/heap/Handle.h" | |
| 46 #include "platform/network/ResourceResponse.h" | |
| 47 #include "wtf/Vector.h" | |
| 48 | |
| 49 namespace blink { | |
| 50 | |
| 51 // A parser parsing mlutipart/x-mixed-replace resource. | |
| 52 class CORE_EXPORT MultipartImageResourceParser : public GarbageCollectedFinalize d<MultipartImageResourceParser> { | |
| 53 public: | |
| 54 class CORE_EXPORT Client : public WillBeGarbageCollectedMixin { | |
| 55 public: | |
| 56 virtual ~Client() {} | |
| 57 virtual void didReceiveResponse(const ResourceResponse&) = 0; | |
| 58 virtual void didReceiveData(const char* bytes, size_t) = 0; | |
|
hiroshige
2016/02/25 18:39:08
How about renaming these to:
responseReceivedMul
yhirano
2016/02/26 22:21:51
I think appendData is not appropriate for a "clien
| |
| 59 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
| 60 }; | |
| 61 | |
| 62 MultipartImageResourceParser(const ResourceResponse&, const Vector<char>& bo undary, Client*); | |
| 63 void addData(const char* bytes, size_t); | |
|
hiroshige
2016/02/25 18:39:08
How about also renaming addData() to appendData(),
yhirano
2016/02/26 22:21:50
Done.
| |
| 64 void finish(); | |
| 65 void cancel() { m_isCancelled = true; } | |
| 66 | |
| 67 DECLARE_TRACE(); | |
| 68 | |
| 69 static int pushOverLineForTest(const Vector<char>& data, size_t size) { retu rn pushOverLine(data, size); } | |
| 70 static size_t findBoundaryForTest(const Vector<char>& data, Vector<char>* bo undary) { return findBoundary(data, boundary); } | |
| 71 | |
| 72 private: | |
| 73 bool parseHeaders(); | |
| 74 bool isCancelled() const { return m_isCancelled; } | |
| 75 static int pushOverLine(const Vector<char>&, size_t); | |
| 76 // This function updates |*boundary|. | |
| 77 static size_t findBoundary(const Vector<char>& data, Vector<char>* boundary) ; | |
| 78 | |
| 79 const ResourceResponse m_originalResponse; | |
| 80 Vector<char> m_boundary; | |
| 81 RawPtrWillBeMember<Client> m_client; | |
| 82 | |
| 83 Vector<char> m_data; | |
| 84 bool m_isParsingTop = true; | |
| 85 bool m_isParsingHeaders = false; | |
| 86 bool m_sawLastBoundary = false; | |
| 87 bool m_isFirstPart = true; | |
| 88 bool m_isCancelled = false; | |
| 89 }; | |
| 90 | |
| 91 } // namespace blink | |
| 92 | |
| 93 #endif // MultipartImageResourceParser_h | |
| OLD | NEW |