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

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

Issue 2731293004: Move the writing of the MHTML footer to the browser process. (Closed)
Patch Set: Comments and naming changes. Created 3 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 /* 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 : public GarbageCollected<MHTMLArchive> { 48 : public GarbageCollected<MHTMLArchive> {
49 public: 49 public:
50 static MHTMLArchive* create(const KURL&, PassRefPtr<const SharedBuffer>); 50 static MHTMLArchive* create(const KURL&, PassRefPtr<const SharedBuffer>);
51 51
52 // Binary encoding results in smaller MHTML files but they might not work in 52 // Binary encoding results in smaller MHTML files but they might not work in
53 // other browsers. 53 // other browsers.
54 enum EncodingPolicy { UseDefaultEncoding, UseBinaryEncoding }; 54 enum EncodingPolicy { UseDefaultEncoding, UseBinaryEncoding };
55 55
56 // Generates an MHTML header and appends it to |outputBuffer|. 56 // Generates an MHTML header and appends it to |outputBuffer|.
57 // 57 //
58 // Same |boundary| needs to used for all generateMHTMLHeader and 58 // Same |boundary| needs to be used for all generateMHTMLHeader and
59 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same 59 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same
60 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). 60 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description).
61 static void generateMHTMLHeader(const String& boundary, 61 static void generateMHTMLHeader(const String& boundary,
62 const String& title, 62 const String& title,
63 const String& mimeType, 63 const String& mimeType,
64 Vector<char>& outputBuffer); 64 Vector<char>& outputBuffer);
65 65
66 // Serializes SerializedResource as an MHTML part and appends it in 66 // Serializes SerializedResource as an MHTML part and appends it in
67 // |outputBuffer|. 67 // |outputBuffer|.
68 // 68 //
69 // Same |boundary| needs to used for all generateMHTMLHeader and 69 // Same |boundary| needs to be used for all generateMHTMLHeader and
70 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same 70 // generateMHTMLPart and generateMHTMLFooter calls that belong to the same
71 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). 71 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description).
72 // 72 //
73 // If |contentID| is non-empty, then it will be used as a Content-ID header. 73 // 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". 74 // See rfc2557 - section 8.3 - "Use of the Content-ID header and CID URLs".
75 static void generateMHTMLPart(const String& boundary, 75 static void generateMHTMLPart(const String& boundary,
76 const String& contentID, 76 const String& contentID,
77 EncodingPolicy, 77 EncodingPolicy,
78 const SerializedResource&, 78 const SerializedResource&,
79 Vector<char>& outputBuffer); 79 Vector<char>& outputBuffer);
80 80
81 // Generates an MHTML footer and appends it to |outputBuffer|. 81 // Generates an MHTML footer and appends it to |outputBuffer| for testing
82 // purposes.
82 // 83 //
83 // Same |boundary| needs to used for all generateMHTMLHeader and 84 // Same |boundary| needs to be 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 generateMHTMLFooterForTesting(const String& boundary,
87 Vector<char>& outputBuffer); 88 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