~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/rewriter/public/critical_css_finder.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
17
 
// Author: slamm@google.com (Stephen Lamm)
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/basictypes.h"
23
 
#include "net/instaweb/util/public/property_cache.h"
24
 
 
25
 
namespace net_instaweb {
26
 
 
27
 
class CriticalCssResult;
28
 
class RewriteDriver;
29
 
class Statistics;
30
 
class TimedVariable;
31
 
 
32
 
// Finds critical CSS rules (i.e. CSS needed for the initial page load).
33
 
class CriticalCssFinder {
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
 
 
45
 
  // Get critical css result from property cache.
46
 
  // Ownership of the result is passed to the caller.
47
 
  virtual CriticalCssResult* GetCriticalCssFromCache(RewriteDriver* driver);
48
 
 
49
 
  // Compute the critical css for the driver's url.
50
 
  virtual void ComputeCriticalCss(RewriteDriver* driver) = 0;
51
 
 
52
 
  // Copy |critical_css_map| into property cache. Returns true on success.
53
 
  virtual bool UpdateCache(RewriteDriver* driver,
54
 
                           const CriticalCssResult& result);
55
 
 
56
 
  // Collects the critical CSS rules from the property cache and updates the
57
 
  // same in the rewrite driver. The ownership of the ruleset stays with the
58
 
  // driver.
59
 
  virtual void UpdateCriticalCssInfoInDriver(RewriteDriver* driver);
60
 
 
61
 
  // Gets the critical CSS rules from the driver if they are present. Otherwise
62
 
  // calls UpdateCriticalCssInfoInDriver() to populate the ruleset in the driver
63
 
  // and returns the rules. The ownership of the CriticalCssResult is not
64
 
  // released and it stays with the driver.
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
 
}  // namespace net_instaweb
79
 
 
80
 
#endif  // NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_CSS_FINDER_H_