Page Speed Optimization Libraries
1.6.29.3
|
00001 /* 00002 * Copyright 2012 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 00020 00021 #ifndef NET_INSTAWEB_UTIL_PUBLIC_MOCK_PROPERTY_PAGE_H_ 00022 #define NET_INSTAWEB_UTIL_PUBLIC_MOCK_PROPERTY_PAGE_H_ 00023 00024 #include "net/instaweb/http/public/request_context.h" 00025 #include "net/instaweb/util/public/basictypes.h" 00026 #include "net/instaweb/util/public/property_cache.h" 00027 #include "net/instaweb/util/public/thread_system.h" 00028 #include "net/instaweb/util/public/string_util.h" 00029 00030 namespace net_instaweb { 00031 00032 class MockPropertyPage : public PropertyPage { 00033 public: 00034 MockPropertyPage(ThreadSystem* thread_system, 00035 PropertyCache* property_cache, 00036 const StringPiece& key) 00037 : PropertyPage( 00038 kPropertyCachePage, key, 00039 RequestContext::NewTestRequestContext(thread_system), 00040 thread_system->NewMutex(), property_cache), 00041 called_(false), 00042 valid_(false), 00043 time_ms_(-1) {} 00044 virtual ~MockPropertyPage(); 00045 virtual bool IsCacheValid(int64 write_timestamp_ms) const { 00046 return time_ms_ == -1 || write_timestamp_ms > time_ms_; 00047 } 00048 virtual void Done(bool valid) { 00049 called_ = true; 00050 valid_ = valid; 00051 } 00052 00053 bool called() const { return called_; } 00054 bool valid() const { return valid_; } 00055 void set_time_ms(int64 time_ms) { 00056 time_ms_ = time_ms; 00057 } 00058 00059 private: 00060 bool called_; 00061 bool valid_; 00062 int64 time_ms_; 00063 00064 DISALLOW_COPY_AND_ASSIGN(MockPropertyPage); 00065 }; 00066 } 00067 00068 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_MOCK_PROPERTY_PAGE_H_