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

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: fix 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 17 matching lines...) Expand all
81 // If no link rewriting is desired, this method should return false. 80 // If no link rewriting is desired, this method should return false.
82 virtual bool rewriteLink(const Element&, String& rewrittenLink) { 81 virtual bool rewriteLink(const Element&, String& rewrittenLink) {
83 return false; 82 return false;
84 } 83 }
85 84
86 // Tells whether to skip serialization of a subresource or CSSStyleSheet 85 // Tells whether to skip serialization of a subresource or CSSStyleSheet
87 // with a given URI. Used to deduplicate resources across multiple frames. 86 // with a given URI. Used to deduplicate resources across multiple frames.
88 virtual bool shouldSkipResourceWithURL(const KURL&) { return false; } 87 virtual bool shouldSkipResourceWithURL(const KURL&) { return false; }
89 88
90 // Tells whether to skip serialization of a subresource. 89 // Tells whether to skip serialization of a subresource.
91 virtual bool shouldSkipResource(const Resource&) { return false; } 90 virtual bool shouldSkipResource(bool hasCacheControlNoStoreHeader) {
yhirano 2016/12/05 09:02:04 Can you use enum rather than a boolean parameter?
hiroshige 2016/12/06 09:32:51 Done, but better name might be needed.
91 return false;
92 }
92 }; 93 };
93 94
94 // Constructs a serializer that will write output to the given vector of 95 // Constructs a serializer that will write output to the given vector of
95 // SerializedResources and uses the Delegate for controlling some 96 // SerializedResources and uses the Delegate for controlling some
96 // serialization aspects. Callers need to ensure that both arguments stay 97 // serialization aspects. Callers need to ensure that both arguments stay
97 // alive until the FrameSerializer gets destroyed. 98 // alive until the FrameSerializer gets destroyed.
98 FrameSerializer(Vector<SerializedResource>&, Delegate&); 99 FrameSerializer(Vector<SerializedResource>&, Delegate&);
99 100
100 // Initiates the serialization of the frame. All serialized content and 101 // Initiates the serialization of the frame. All serialized content and
101 // retrieved resources are added to the Vector passed to the constructor. 102 // retrieved resources are added to the Vector passed to the constructor.
102 // The first resource in that vector is the frame's serialized content. 103 // The first resource in that vector is the frame's serialized content.
103 // Subsequent resources are images, css, etc. 104 // Subsequent resources are images, css, etc.
104 void serializeFrame(const LocalFrame&); 105 void serializeFrame(const LocalFrame&);
105 106
106 static String markOfTheWebDeclaration(const KURL&); 107 static String markOfTheWebDeclaration(const KURL&);
107 108
108 private: 109 private:
109 // Serializes the stylesheet back to text and adds it to the resources if URL 110 // Serializes the stylesheet back to text and adds it to the resources if URL
110 // is not-empty. It also adds any resources included in that stylesheet 111 // is not-empty. It also adds any resources included in that stylesheet
111 // (including any imported stylesheets and their own resources). 112 // (including any imported stylesheets and their own resources).
112 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); 113 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&);
113 114
114 // Serializes the css rule (including any imported stylesheets), adding 115 // Serializes the css rule (including any imported stylesheets), adding
115 // referenced resources. 116 // referenced resources.
116 void serializeCSSRule(CSSRule*); 117 void serializeCSSRule(CSSRule*);
117 118
118 bool shouldAddURL(const KURL&); 119 bool shouldAddURL(const KURL&);
119 120
120 void addToResources(const Resource&, 121 void addToResources(const String& mimeType,
122 bool hasCacheControlNoStoreHeader,
121 PassRefPtr<const SharedBuffer>, 123 PassRefPtr<const SharedBuffer>,
122 const KURL&); 124 const KURL&);
123 void addImageToResources(ImageResource*, const KURL&); 125 void addImageToResources(ImageResourceContent*, const KURL&);
124 void addFontToResources(FontResource*); 126 void addFontToResources(FontResource*);
125 127
126 void retrieveResourcesForProperties(const StylePropertySet*, Document&); 128 void retrieveResourcesForProperties(const StylePropertySet*, Document&);
127 void retrieveResourcesForCSSValue(const CSSValue&, Document&); 129 void retrieveResourcesForCSSValue(const CSSValue&, Document&);
128 130
129 Vector<SerializedResource>* m_resources; 131 Vector<SerializedResource>* m_resources;
130 HashSet<KURL> m_resourceURLs; 132 HashSet<KURL> m_resourceURLs;
131 133
132 bool m_isSerializingCss; 134 bool m_isSerializingCss;
133 135
134 Delegate& m_delegate; 136 Delegate& m_delegate;
135 }; 137 };
136 138
137 } // namespace blink 139 } // namespace blink
138 140
139 #endif // FrameSerializer_h 141 #endif // FrameSerializer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698