OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 17 matching lines...) Expand all Loading... | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef MHTMLArchive_h | 31 #ifndef MHTMLArchive_h |
32 #define MHTMLArchive_h | 32 #define MHTMLArchive_h |
33 | 33 |
34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
35 #include "wtf/HashMap.h" | 35 #include "wtf/HashMap.h" |
36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
37 #include "wtf/text/StringHash.h" | 37 #include "wtf/text/StringHash.h" |
38 #include <vector> | |
38 | 39 |
39 namespace blink { | 40 namespace blink { |
40 | 41 |
41 class ArchiveResource; | 42 class ArchiveResource; |
42 class KURL; | 43 class KURL; |
43 class SharedBuffer; | 44 class SharedBuffer; |
44 | 45 |
45 struct SerializedResource; | 46 struct SerializedResource; |
46 | 47 |
47 class PLATFORM_EXPORT MHTMLArchive final : public GarbageCollected<MHTMLArchive> { | 48 class PLATFORM_EXPORT MHTMLArchive final : public GarbageCollected<MHTMLArchive> { |
48 public: | 49 public: |
49 static MHTMLArchive* create(const KURL&, PassRefPtr<const SharedBuffer>); | 50 static MHTMLArchive* create(const KURL&, PassRefPtr<const SharedBuffer>); |
50 | 51 |
51 // Binary encoding results in smaller MHTML files but they might not work in other browsers. | 52 // Binary encoding results in smaller MHTML files but they might not work in other browsers. |
52 enum EncodingPolicy { | 53 enum EncodingPolicy { |
53 UseDefaultEncoding, | 54 UseDefaultEncoding, |
54 UseBinaryEncoding | 55 UseBinaryEncoding |
55 }; | 56 }; |
56 | 57 |
57 // Generates an MHTML header and appends it to |outputBuffer|. | 58 // Generates an MHTML header and appends it to |outputBuffer|. |
58 // | 59 // |
59 // Same |boundary| needs to used for all generateMHTMLHeader and | 60 // Same |boundary| needs to used for all generateMHTMLHeader and |
60 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same | 61 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same |
61 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 62 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
62 static void generateMHTMLHeader( | 63 static void generateMHTMLHeader( |
63 const String& boundary, const String& title, const String& mimeType, | 64 const String& boundary, const String& title, const String& mimeType, |
64 SharedBuffer& outputBuffer); | 65 std::vector<char>& outputBuffer); |
carlosk
2016/10/03 23:51:05
Is it really OK to pass non const references in Bl
carlosk
2016/10/04 21:49:53
Just for the record: I did ask dcheng@ directly ab
| |
65 | 66 |
66 // Serializes SerializedResource as an MHTML part and appends it in | 67 // Serializes SerializedResource as an MHTML part and appends it in |
67 // |outputBuffer|. | 68 // |outputBuffer|. |
68 // | 69 // |
69 // Same |boundary| needs to used for all generateMHTMLHeader and | 70 // Same |boundary| needs to used for all generateMHTMLHeader and |
70 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same | 71 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same |
71 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 72 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
72 // | 73 // |
73 // If |contentID| is non-empty, then it will be used as a Content-ID header. | 74 // If |contentID| is non-empty, then it will be used as a Content-ID header. |
74 // See rfc2557 - section 8.3 - "Use of the Content-ID header and CID URLs". | 75 // See rfc2557 - section 8.3 - "Use of the Content-ID header and CID URLs". |
75 static void generateMHTMLPart( | 76 static void generateMHTMLPart( |
76 const String& boundary, const String& contentID, | 77 const String& boundary, const String& contentID, |
77 EncodingPolicy, const SerializedResource&, | 78 EncodingPolicy, const SerializedResource&, |
78 SharedBuffer& outputBuffer); | 79 std::vector<char>& outputBuffer); |
79 | 80 |
80 // Generates an MHTML footer and appends it to |outputBuffer|. | 81 // Generates an MHTML footer and appends it to |outputBuffer|. |
81 // | 82 // |
82 // Same |boundary| needs to used for all generateMHTMLHeader and | 83 // Same |boundary| needs to used for all generateMHTMLHeader and |
83 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same | 84 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same |
84 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 85 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
85 static void generateMHTMLFooter( | 86 static void generateMHTMLFooter( |
86 const String& boundary, | 87 const String& boundary, |
87 SharedBuffer& outputBuffer); | 88 std::vector<char>& outputBuffer); |
88 | 89 |
89 typedef HeapHashMap<String, Member<ArchiveResource>> SubArchiveResources; | 90 typedef HeapHashMap<String, Member<ArchiveResource>> SubArchiveResources; |
90 | 91 |
91 ArchiveResource* mainResource() { return m_mainResource.get(); } | 92 ArchiveResource* mainResource() { return m_mainResource.get(); } |
92 ArchiveResource* subresourceForURL(const KURL&) const; | 93 ArchiveResource* subresourceForURL(const KURL&) const; |
93 | 94 |
94 DECLARE_TRACE(); | 95 DECLARE_TRACE(); |
95 | 96 |
96 private: | 97 private: |
97 MHTMLArchive(); | 98 MHTMLArchive(); |
98 | 99 |
99 void setMainResource(ArchiveResource*); | 100 void setMainResource(ArchiveResource*); |
100 void addSubresource(ArchiveResource*); | 101 void addSubresource(ArchiveResource*); |
101 static bool canLoadArchive(const KURL&); | 102 static bool canLoadArchive(const KURL&); |
102 | 103 |
103 Member<ArchiveResource> m_mainResource; | 104 Member<ArchiveResource> m_mainResource; |
104 SubArchiveResources m_subresources; | 105 SubArchiveResources m_subresources; |
105 }; | 106 }; |
106 | 107 |
107 } // namespace blink | 108 } // namespace blink |
108 | 109 |
109 #endif | 110 #endif |
OLD | NEW |