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

Side by Side Diff: third_party/WebKit/Source/platform/mhtml/MHTMLArchive.h

Issue 2379823003: Move MHTML file writing out of the renderer main thread. (Closed)
Patch Set: Removed unneeded std::move calls that clang was complaining about. Created 4 years, 2 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 /* 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
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 48 class PLATFORM_EXPORT MHTMLArchive final
48 : public GarbageCollected<MHTMLArchive> { 49 : public GarbageCollected<MHTMLArchive> {
49 public: 50 public:
50 static MHTMLArchive* create(const KURL&, PassRefPtr<const SharedBuffer>); 51 static MHTMLArchive* create(const KURL&, PassRefPtr<const SharedBuffer>);
51 52
52 // Binary encoding results in smaller MHTML files but they might not work in 53 // Binary encoding results in smaller MHTML files but they might not work in
53 // other browsers. 54 // other browsers.
54 enum EncodingPolicy { UseDefaultEncoding, UseBinaryEncoding }; 55 enum EncodingPolicy { UseDefaultEncoding, UseBinaryEncoding };
55 56
56 // Generates an MHTML header and appends it to |outputBuffer|. 57 // Generates an MHTML header and appends it to |outputBuffer|.
57 // 58 //
58 // Same |boundary| needs to used for all generateMHTMLHeader and 59 // Same |boundary| needs to used for all generateMHTMLHeader and
59 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same 60 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same
60 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). 61 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description).
61 static void generateMHTMLHeader(const String& boundary, 62 static void generateMHTMLHeader(const String& boundary,
62 const String& title, 63 const String& title,
63 const String& mimeType, 64 const String& mimeType,
64 SharedBuffer& outputBuffer); 65 std::vector<char>& outputBuffer);
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(const String& boundary, 76 static void generateMHTMLPart(const String& boundary,
76 const String& contentID, 77 const String& contentID,
77 EncodingPolicy, 78 EncodingPolicy,
78 const SerializedResource&, 79 const SerializedResource&,
79 SharedBuffer& outputBuffer); 80 std::vector<char>& outputBuffer);
80 81
81 // Generates an MHTML footer and appends it to |outputBuffer|. 82 // Generates an MHTML footer and appends it to |outputBuffer|.
82 // 83 //
83 // Same |boundary| needs to used for all generateMHTMLHeader and 84 // Same |boundary| needs to used for all generateMHTMLHeader and
84 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same 85 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same
85 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). 86 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description).
86 static void generateMHTMLFooter(const String& boundary, 87 static void generateMHTMLFooter(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698