Page Speed Optimization Libraries  1.5.27.2
net/instaweb/rewriter/public/inline_rewrite_context.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Google Inc.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http:///www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00018 
00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_INLINE_REWRITE_CONTEXT_H_
00020 #define NET_INSTAWEB_REWRITER_PUBLIC_INLINE_REWRITE_CONTEXT_H_
00021 
00022 #include "net/instaweb/htmlparse/public/html_element.h"
00023 #include "net/instaweb/rewriter/public/output_resource_kind.h"
00024 #include "net/instaweb/rewriter/public/resource.h"
00025 #include "net/instaweb/rewriter/public/server_context.h"
00026 #include "net/instaweb/rewriter/public/rewrite_context.h"
00027 #include "net/instaweb/util/public/basictypes.h"
00028 #include "net/instaweb/util/public/string_util.h"
00029 
00030 namespace net_instaweb {
00031 
00032 class CachedResult;
00033 class CommonFilter;
00034 class OutputPartitions;
00035 
00038 class InlineRewriteContext : public RewriteContext {
00039  public:
00041   InlineRewriteContext(CommonFilter* filter, HtmlElement* element,
00042                        HtmlElement::Attribute* src);
00043   virtual ~InlineRewriteContext();
00044 
00050   bool StartInlining();
00051 
00052  protected:
00054   virtual bool ShouldInline(const ResourcePtr& resource) const = 0;
00055   virtual void RenderInline(const ResourcePtr& resource,
00056                             const StringPiece& text,
00057                             HtmlElement* element) = 0;
00058 
00059 
00061   virtual bool Partition(OutputPartitions* partitions,
00062                          OutputResourceVector* outputs);
00063   virtual void Rewrite(int partition_index,
00064                        CachedResult* partition,
00065                        const OutputResourcePtr& output);
00066   virtual void Render();
00067   virtual OutputResourceKind kind() const;
00068 
00069   HtmlElement* get_element() const { return element_; }
00070 
00071  private:
00072   CommonFilter* filter_;
00073   HtmlElement* element_;
00074   HtmlElement::Attribute* src_;
00075 
00076   DISALLOW_COPY_AND_ASSIGN(InlineRewriteContext);
00077 };
00078 
00079 }  
00080 
00081 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_INLINE_REWRITE_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines