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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameSerializer.h

Issue 2469873002: [ImageResource 4] Split ImageResource into Resource and Image parts (Closed)
Patch Set: comments Created 4 years 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 30 matching lines...) Expand all
41 41
42 namespace blink { 42 namespace blink {
43 43
44 class Attribute; 44 class Attribute;
45 class CSSRule; 45 class CSSRule;
46 class CSSStyleSheet; 46 class CSSStyleSheet;
47 class CSSValue; 47 class CSSValue;
48 class Document; 48 class Document;
49 class Element; 49 class Element;
50 class FontResource; 50 class FontResource;
51 class ImageResource; 51 class ImageResourceContent;
52 class LocalFrame; 52 class LocalFrame;
53 class Resource;
54 class SharedBuffer; 53 class SharedBuffer;
55 class StylePropertySet; 54 class StylePropertySet;
56 55
57 struct SerializedResource; 56 struct SerializedResource;
58 57
59 // This class is used to serialize frame's contents back to text (typically 58 // This class is used to serialize frame's contents back to text (typically
60 // HTML). It serializes frame's document and resources such as images and CSS 59 // HTML). It serializes frame's document and resources such as images and CSS
61 // stylesheets. 60 // stylesheets.
62 class CORE_EXPORT FrameSerializer final { 61 class CORE_EXPORT FrameSerializer final {
63 STACK_ALLOCATED(); 62 STACK_ALLOCATED();
(...skipping 15 matching lines...) Expand all
79 // If no link rewriting is desired, this method should return false. 78 // If no link rewriting is desired, this method should return false.
80 virtual bool rewriteLink(const Element&, String& rewrittenLink) { 79 virtual bool rewriteLink(const Element&, String& rewrittenLink) {
81 return false; 80 return false;
82 } 81 }
83 82
84 // Tells whether to skip serialization of a subresource or CSSStyleSheet 83 // Tells whether to skip serialization of a subresource or CSSStyleSheet
85 // with a given URI. Used to deduplicate resources across multiple frames. 84 // with a given URI. Used to deduplicate resources across multiple frames.
86 virtual bool shouldSkipResourceWithURL(const KURL&) { return false; } 85 virtual bool shouldSkipResourceWithURL(const KURL&) { return false; }
87 86
88 // Tells whether to skip serialization of a subresource. 87 // Tells whether to skip serialization of a subresource.
89 virtual bool shouldSkipResource(const Resource&) { return false; } 88 virtual bool shouldSkipResource(bool hasCacheControlNoStoreHeader) {
89 return false;
90 }
90 }; 91 };
91 92
92 // Constructs a serializer that will write output to the given vector of 93 // Constructs a serializer that will write output to the given vector of
93 // SerializedResources and uses the Delegate for controlling some 94 // SerializedResources and uses the Delegate for controlling some
94 // serialization aspects. Callers need to ensure that both arguments stay 95 // serialization aspects. Callers need to ensure that both arguments stay
95 // alive until the FrameSerializer gets destroyed. 96 // alive until the FrameSerializer gets destroyed.
96 FrameSerializer(Vector<SerializedResource>&, Delegate&); 97 FrameSerializer(Vector<SerializedResource>&, Delegate&);
97 98
98 // Initiates the serialization of the frame. All serialized content and 99 // Initiates the serialization of the frame. All serialized content and
99 // retrieved resources are added to the Vector passed to the constructor. 100 // retrieved resources are added to the Vector passed to the constructor.
100 // The first resource in that vector is the frame's serialized content. 101 // The first resource in that vector is the frame's serialized content.
101 // Subsequent resources are images, css, etc. 102 // Subsequent resources are images, css, etc.
102 void serializeFrame(const LocalFrame&); 103 void serializeFrame(const LocalFrame&);
103 104
104 static String markOfTheWebDeclaration(const KURL&); 105 static String markOfTheWebDeclaration(const KURL&);
105 106
106 private: 107 private:
107 // Serializes the stylesheet back to text and adds it to the resources if URL 108 // Serializes the stylesheet back to text and adds it to the resources if URL
108 // is not-empty. It also adds any resources included in that stylesheet 109 // is not-empty. It also adds any resources included in that stylesheet
109 // (including any imported stylesheets and their own resources). 110 // (including any imported stylesheets and their own resources).
110 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); 111 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&);
111 112
112 // Serializes the css rule (including any imported stylesheets), adding 113 // Serializes the css rule (including any imported stylesheets), adding
113 // referenced resources. 114 // referenced resources.
114 void serializeCSSRule(CSSRule*); 115 void serializeCSSRule(CSSRule*);
115 116
116 bool shouldAddURL(const KURL&); 117 bool shouldAddURL(const KURL&);
117 118
118 void addToResources(const Resource&, 119 void addToResources(const String& mimeType,
120 bool hasCacheControlNoStoreHeader,
119 PassRefPtr<const SharedBuffer>, 121 PassRefPtr<const SharedBuffer>,
120 const KURL&); 122 const KURL&);
121 void addImageToResources(ImageResource*, const KURL&); 123 void addImageToResources(ImageResourceContent*, const KURL&);
122 void addFontToResources(FontResource*); 124 void addFontToResources(FontResource*);
123 125
124 void retrieveResourcesForProperties(const StylePropertySet*, Document&); 126 void retrieveResourcesForProperties(const StylePropertySet*, Document&);
125 void retrieveResourcesForCSSValue(const CSSValue&, Document&); 127 void retrieveResourcesForCSSValue(const CSSValue&, Document&);
126 128
127 Vector<SerializedResource>* m_resources; 129 Vector<SerializedResource>* m_resources;
128 HashSet<KURL> m_resourceURLs; 130 HashSet<KURL> m_resourceURLs;
129 131
130 bool m_isSerializingCss; 132 bool m_isSerializingCss;
131 133
132 Delegate& m_delegate; 134 Delegate& m_delegate;
133 }; 135 };
134 136
135 } // namespace blink 137 } // namespace blink
136 138
137 #endif // FrameSerializer_h 139 #endif // FrameSerializer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698