Page Speed Optimization Libraries  1.5.27.2
net/instaweb/rewriter/public/critical_selector_finder.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2013 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_CRITICAL_SELECTOR_FINDER_H_
00020 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_SELECTOR_FINDER_H_
00021 
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/string.h"
00024 #include "net/instaweb/util/public/string_util.h"
00025 
00026 namespace net_instaweb {
00027 
00028 class CriticalSelectorSet;
00029 class MessageHandler;
00030 class PropertyCache;
00031 class PropertyPage;
00032 class RewriteDriver;
00033 class Statistics;
00034 class TimedVariable;
00035 
00038 class CriticalSelectorFinder {
00039  public:
00040   static const char kCriticalSelectorsValidCount[];
00041   static const char kCriticalSelectorsExpiredCount[];
00042   static const char kCriticalSelectorsNotFoundCount[];
00043   static const char kCriticalSelectorsPropertyName[];
00044 
00045   CriticalSelectorFinder(StringPiece cohort, Statistics* stats);
00046   virtual ~CriticalSelectorFinder();
00047 
00048   static void InitStats(Statistics* statistics);
00049 
00053   CriticalSelectorSet* DecodeCriticalSelectorsFromPropertyCache(
00054       RewriteDriver* driver);
00055 
00061   void WriteCriticalSelectorsToPropertyCache(
00062       const StringSet& selector_set, RewriteDriver* driver);
00063 
00064   void WriteCriticalSelectorsToPropertyCache(
00065       const StringSet& selector_set, const PropertyCache* cache,
00066       PropertyPage* page, MessageHandler* message_handler);
00067 
00069   int NumSetsToKeep() const {
00070     return kDefaultNumSetsToKeep;
00071   }
00072 
00075 
00076  private:
00079   static const int kDefaultNumSetsToKeep = 10;
00080 
00085   void UpdateCriticalSelectorSet(
00086     const StringSet& new_set, CriticalSelectorSet* set);
00087 
00088   GoogleString cohort_;
00089 
00090   TimedVariable* critical_selectors_valid_count_;
00091   TimedVariable* critical_selectors_expired_count_;
00092   TimedVariable* critical_selectors_not_found_count_;
00093 
00094   DISALLOW_COPY_AND_ASSIGN(CriticalSelectorFinder);
00095 };
00096 
00097 }  
00098 
00099 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_SELECTOR_FINDER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines