Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
css_resource_slot.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 
22 
23 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CSS_RESOURCE_SLOT_H_
24 #define NET_INSTAWEB_REWRITER_PUBLIC_CSS_RESOURCE_SLOT_H_
25 
26 #include <cstddef>
27 #include <set>
28 
35 
36 namespace Css { class Values; }
37 
38 namespace net_instaweb {
39 
40 class HtmlElement;
41 class RewriteOptions;
42 
44 class CssResourceSlot : public ResourceSlot {
45  public:
46  virtual void Render();
47  virtual void Finished();
48  virtual GoogleString LocationString() const;
49 
50  virtual HtmlElement* element() const { return NULL; }
51  Css::Values* values() const { return values_; }
52  size_t value_index() const { return value_index_; }
53  UrlRelativity url_relativity() const { return url_relativity_; }
54 
55  virtual bool DirectSetUrl(const StringPiece& url);
56  virtual bool CanDirectSetUrl() { return true; }
57 
58  protected:
59  CssResourceSlot(const ResourcePtr& resource,
60  const GoogleUrl& trim_url, const RewriteOptions* options,
61  Css::Values* values, size_t value_index);
62 
63  REFCOUNT_FRIEND_DECLARATION(CssResourceSlot);
64  virtual ~CssResourceSlot();
65 
66  private:
67  friend class CssResourceSlotFactory;
68 
69  Css::Values* values_;
70  size_t value_index_;
71 
72  UrlRelativity url_relativity_;
73  GoogleUrl trim_url_;
74  const RewriteOptions* options_;
75 
76 
77 };
78 
79 typedef RefCountedPtr<CssResourceSlot> CssResourceSlotPtr;
80 
84  public:
87 
90  CssResourceSlotPtr GetSlot(const ResourcePtr& resource,
91  const GoogleUrl& trim_url,
92  const RewriteOptions* options,
93  Css::Values* values, size_t value_index);
94  CssResourceSlotPtr UniquifySlot(CssResourceSlotPtr slot);
95 
96  private:
97  class SlotComparator {
98  public:
99  bool operator()(const CssResourceSlotPtr& p,
100  const CssResourceSlotPtr& q) const;
101  };
102  typedef std::set<CssResourceSlotPtr, SlotComparator> SlotSet;
103 
104  SlotSet slots_;
105 
106 };
107 
108 }
109 
110 #endif
class GoogleUrl
Definition: google_url.h:58
virtual GoogleString LocationString() const
virtual bool DirectSetUrl(const StringPiece &url)
Definition: css_resource_slot.h:83
Definition: resource_slot.h:54
Definition: html_element.h:42
virtual bool CanDirectSetUrl()
Definition: css_resource_slot.h:56
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
UrlRelativity
namespace url
Definition: google_url.h:51
A place storing a rewritable URL inside a CSS AST.
Definition: css_resource_slot.h:44
virtual HtmlElement * element() const
Return HTML element associated with slot, or NULL if none (CSS, IPRO)
Definition: css_resource_slot.h:50
CssResourceSlotPtr GetSlot(const ResourcePtr &resource, const GoogleUrl &trim_url, const RewriteOptions *options, Css::Values *values, size_t value_index)
Definition: rewrite_options.h:84