Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
31 
32 namespace net_instaweb {
33 
34 class CachedResult;
35 class CommonFilter;
36 class OutputPartitions;
37 
41  public:
45  virtual ~InlineRewriteContext();
46 
52  bool StartInlining();
53 
54  protected:
56 
60  virtual bool ShouldInline(const ResourcePtr& resource,
61  GoogleString* explanation) const = 0;
62  virtual void RenderInline(const ResourcePtr& resource,
63  const StringPiece& text,
64  HtmlElement* element) = 0;
65  virtual RewriteDriver::InputRole InputRole() const = 0;
66 
71  virtual ResourcePtr CreateResource(const char* url, bool* is_authorized);
72 
74  virtual bool Partition(OutputPartitions* partitions,
75  OutputResourceVector* outputs);
76  virtual void Rewrite(int partition_index,
77  CachedResult* partition,
78  const OutputResourcePtr& output);
79  virtual void Render();
80  virtual OutputResourceKind kind() const;
81 
82  HtmlElement* get_element() const { return element_; }
83 
84  private:
85  CommonFilter* filter_;
86  HtmlElement* element_;
88 
89 
90 };
91 
92 }
93 
94 #endif
Definition: common_filter.h:47
virtual void Rewrite(int partition_index, CachedResult *partition, const OutputResourcePtr &output)
Definition: html_element.h:66
virtual OutputResourceKind kind() const
Definition: inline_rewrite_context.h:40
InlineRewriteContext(CommonFilter *filter, HtmlElement *element, HtmlElement::Attribute *src)
Note that you should also call StartInlining() to do the work.
Definition: html_element.h:42
InputRole
Definition: rewrite_driver.h:611
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: rewrite_context.h:155
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