Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
critical_css_finder.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_CSS_FINDER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_CSS_FINDER_H_
21 
22 #include "net/instaweb/util/public/property_cache.h"
23 #include "pagespeed/kernel/base/basictypes.h"
24 
25 namespace net_instaweb {
26 
27 class CriticalCssResult;
28 class RewriteDriver;
29 class Statistics;
30 class TimedVariable;
31 
34  public:
35  static const char kCriticalCssValidCount[];
36  static const char kCriticalCssExpiredCount[];
37  static const char kCriticalCssNotFoundCount[];
38  static const char kCriticalCssPropertyName[];
39 
40  CriticalCssFinder(const PropertyCache::Cohort* cohort, Statistics* stats);
41  virtual ~CriticalCssFinder();
42 
43  static void InitStats(Statistics* statistics);
44 
47  virtual CriticalCssResult* GetCriticalCssFromCache(RewriteDriver* driver);
48 
50  virtual void ComputeCriticalCss(RewriteDriver* driver) = 0;
51 
53  virtual bool UpdateCache(RewriteDriver* driver,
54  const CriticalCssResult& result);
55 
59  virtual void UpdateCriticalCssInfoInDriver(RewriteDriver* driver);
60 
65  virtual CriticalCssResult* GetCriticalCss(RewriteDriver* driver);
66 
67  const PropertyCache::Cohort* cohort() const { return cohort_; }
68 
69  private:
70  const PropertyCache::Cohort* cohort_;
71  TimedVariable* critical_css_valid_count_;
72  TimedVariable* critical_css_expired_count_;
73  TimedVariable* critical_css_not_found_count_;
74 
75  DISALLOW_COPY_AND_ASSIGN(CriticalCssFinder);
76 };
77 
78 }
79 
80 #endif
virtual CriticalCssResult * GetCriticalCss(RewriteDriver *driver)
virtual bool UpdateCache(RewriteDriver *driver, const CriticalCssResult &result)
Copy |critical_css_map| into property cache. Returns true on success.
Finds critical CSS rules (i.e. CSS needed for the initial page load).
Definition: critical_css_finder.h:33
virtual void ComputeCriticalCss(RewriteDriver *driver)=0
Compute the critical css for the driver's url.
virtual void UpdateCriticalCssInfoInDriver(RewriteDriver *driver)
virtual CriticalCssResult * GetCriticalCssFromCache(RewriteDriver *driver)
Definition: rewrite_driver.h:98