Page Speed Optimization Libraries  1.7.30.1
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 
00063   virtual ResourcePtr CreateResource(const char* url);
00064 
00066   virtual bool Partition(OutputPartitions* partitions,
00067                          OutputResourceVector* outputs);
00068   virtual void Rewrite(int partition_index,
00069                        CachedResult* partition,
00070                        const OutputResourcePtr& output);
00071   virtual void Render();
00072   virtual OutputResourceKind kind() const;
00073 
00074   HtmlElement* get_element() const { return element_; }
00075 
00076  private:
00077   CommonFilter* filter_;
00078   HtmlElement* element_;
00079   HtmlElement::Attribute* src_;
00080 
00081   DISALLOW_COPY_AND_ASSIGN(InlineRewriteContext);
00082 };
00083 
00084 }  
00085 
00086 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_INLINE_REWRITE_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines