Page Speed Optimization Libraries  1.7.30.1
net/instaweb/util/public/fallback_property_page.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 
00023 
00024 #ifndef NET_INSTAWEB_UTIL_PUBLIC_FALLBACK_PROPERTY_PAGE_H_
00025 #define NET_INSTAWEB_UTIL_PUBLIC_FALLBACK_PROPERTY_PAGE_H_
00026 
00027 #include "net/instaweb/util/public/basictypes.h"
00028 #include "net/instaweb/util/public/scoped_ptr.h"
00029 #include "net/instaweb/util/public/cache_interface.h"
00030 #include "net/instaweb/util/public/property_cache.h"
00031 #include "net/instaweb/util/public/string.h"
00032 #include "net/instaweb/util/public/string_util.h"
00033 
00034 namespace net_instaweb {
00035 
00036 class GoogleUrl;
00037 
00038 class FallbackPropertyPage : public AbstractPropertyPage {
00039  public:
00041   FallbackPropertyPage(PropertyPage* actual_property_page,
00042                        PropertyPage* property_page_with_fallback_values);
00043   virtual ~FallbackPropertyPage();
00044 
00047   virtual PropertyValue* GetProperty(
00048       const PropertyCache::Cohort* cohort,
00049       const StringPiece& property_name);
00050 
00053   PropertyValue* GetFallbackProperty(
00054         const PropertyCache::Cohort* cohort,
00055         const StringPiece& property_name);
00056 
00059   virtual void UpdateValue(
00060       const PropertyCache::Cohort* cohort, const StringPiece& property_name,
00061       const StringPiece& value);
00062 
00065   virtual void WriteCohort(const PropertyCache::Cohort* cohort);
00066 
00068   virtual CacheInterface::KeyState GetCacheState(
00069       const PropertyCache::Cohort* cohort);
00070 
00072   virtual CacheInterface::KeyState GetFallbackCacheState(
00073         const PropertyCache::Cohort* cohort);
00074 
00076   virtual void DeleteProperty(const PropertyCache::Cohort* cohort,
00077                               const StringPiece& property_name);
00078 
00079   PropertyPage* actual_property_page() { return actual_property_page_.get(); }
00080   PropertyPage* property_page_with_fallback_values() {
00081     return property_page_with_fallback_values_.get();
00082   }
00083 
00086   static GoogleString GetFallbackPageUrl(const GoogleUrl& request_url);
00087 
00089   static bool IsFallbackUrl(const GoogleString& url);
00090 
00091  private:
00092   scoped_ptr<PropertyPage> actual_property_page_;
00093   scoped_ptr<PropertyPage> property_page_with_fallback_values_;
00094   DISALLOW_COPY_AND_ASSIGN(FallbackPropertyPage);
00095 };
00096 
00097 }  
00098 #endif  ///< NET_INSTAWEB_UTIL_PUBLIC_FALLBACK_PROPERTY_PAGE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines