Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
critical_images_beacon_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 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_CRITICAL_IMAGES_BEACON_FILTER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_IMAGES_BEACON_FILTER_H_
21 
31 
32 namespace net_instaweb {
33 
39  public:
40  static const char* kImageOnloadCode;
42  static const char kCriticalImagesBeaconAddedCount[];
43 
44  explicit CriticalImagesBeaconFilter(RewriteDriver* driver);
45  virtual ~CriticalImagesBeaconFilter();
46 
47  virtual void DetermineEnabled(GoogleString* disabled_reason);
48 
49  static void InitStats(Statistics* statistics);
50 
51  virtual void StartDocumentImpl() { }
52  virtual void EndDocument();
53  virtual void StartElementImpl(HtmlElement* element) { }
54  virtual void EndElementImpl(HtmlElement* element);
55  virtual const char* Name() const { return "CriticalImagesBeacon"; }
56  ScriptUsage GetScriptUsage() const override { return kWillInjectScripts; }
57 
61  static bool ShouldApply(RewriteDriver* rewrite_driver);
62 
63  private:
65  void Clear();
66 
69  void MaybeAddBeaconJavascript(HtmlElement* element);
70 
71  BeaconMetadata beacon_metadata_;
72  StringSet image_url_hashes_;
73  bool insert_beacon_js_;
75  Variable* critical_images_beacon_added_count_;
76 
77  bool added_beacon_js_;
78 
79 
80 };
81 
82 }
83 
84 #endif
Definition: common_filter.h:47
ScriptUsage GetScriptUsage() const override
Definition: critical_images_beacon_filter.h:56
Definition: statistics.h:43
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
static bool ShouldApply(RewriteDriver *rewrite_driver)
Definition: critical_images_beacon_filter.h:38
Definition: html_element.h:42
virtual const char * Name() const
The name of this filter – used for logging and debugging.
Definition: critical_images_beacon_filter.h:55
static const char kCriticalImagesBeaconAddedCount[]
Counters.
Definition: critical_images_beacon_filter.h:42
Definition: critical_finder_support_util.h:78
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
ScriptUsage
Describes a filter's relationship with scripts.
Definition: html_filter.h:38
Definition: rewrite_driver.h:100
virtual void DetermineEnabled(GoogleString *disabled_reason)
virtual void StartDocumentImpl()
Definition: critical_images_beacon_filter.h:51