Page Speed Optimization Libraries  1.11.33.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
inline_rewrite_context.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_INLINE_REWRITE_CONTEXT_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_INLINE_REWRITE_CONTEXT_H_
21 
26 #include "pagespeed/kernel/base/basictypes.h"
27 #include "pagespeed/kernel/base/string.h"
28 #include "pagespeed/kernel/base/string_util.h"
29 #include "pagespeed/kernel/html/html_element.h"
30 
31 namespace net_instaweb {
32 
33 class CachedResult;
34 class CommonFilter;
35 class OutputPartitions;
36 
40  public:
42  InlineRewriteContext(CommonFilter* filter, HtmlElement* element,
43  HtmlElement::Attribute* src);
44  virtual ~InlineRewriteContext();
45 
51  bool StartInlining();
52 
53  protected:
55 
59  virtual bool ShouldInline(const ResourcePtr& resource,
60  GoogleString* explanation) const = 0;
61  virtual void RenderInline(const ResourcePtr& resource,
62  const StringPiece& text,
63  HtmlElement* element) = 0;
64 
69  virtual ResourcePtr CreateResource(const char* url, bool* is_authorized);
70 
72  virtual bool Partition(OutputPartitions* partitions,
73  OutputResourceVector* outputs);
74  virtual void Rewrite(int partition_index,
75  CachedResult* partition,
76  const OutputResourcePtr& output);
77  virtual void Render();
78  virtual OutputResourceKind kind() const;
79 
80  HtmlElement* get_element() const { return element_; }
81 
82  private:
83  CommonFilter* filter_;
84  HtmlElement* element_;
85  HtmlElement::Attribute* src_;
86 
87 
88 };
89 
90 }
91 
92 #endif
Definition: common_filter.h:47
virtual void Rewrite(int partition_index, CachedResult *partition, const OutputResourcePtr &output)
virtual OutputResourceKind kind() const
Definition: inline_rewrite_context.h:39
InlineRewriteContext(CommonFilter *filter, HtmlElement *element, HtmlElement::Attribute *src)
Note that you should also call StartInlining() to do the work.
Definition: rewrite_context.h:146
virtual ResourcePtr CreateResource(const char *url, bool *is_authorized)
virtual bool ShouldInline(const ResourcePtr &resource, GoogleString *explanation) const =0
Subclasses of InlineRewriteContext must override these:
virtual bool Partition(OutputPartitions *partitions, OutputResourceVector *outputs)
InlineRewriteContext takes care of these methods from RewriteContext;.
OutputResourceKind
Definition: output_resource_kind.h:26