Page Speed Optimization Libraries
1.7.30.1
|
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& url, 00037 const StringPiece& options_signature_hash, 00038 const StringPiece& cache_key_suffix) 00039 : PropertyPage( 00040 kPropertyCachePage, 00041 url, 00042 options_signature_hash, 00043 cache_key_suffix, 00044 RequestContext::NewTestRequestContext(thread_system), 00045 thread_system->NewMutex(), property_cache), 00046 called_(false), 00047 valid_(false), 00048 time_ms_(-1) {} 00049 virtual ~MockPropertyPage(); 00050 virtual bool IsCacheValid(int64 write_timestamp_ms) const { 00051 return time_ms_ == -1 || write_timestamp_ms > time_ms_; 00052 } 00053 virtual void Done(bool valid) { 00054 called_ = true; 00055 valid_ = valid; 00056 } 00057 00058 bool called() const { return called_; } 00059 bool valid() const { return valid_; } 00060 void set_time_ms(int64 time_ms) { 00061 time_ms_ = time_ms; 00062 } 00063 00064 private: 00065 bool called_; 00066 bool valid_; 00067 int64 time_ms_; 00068 00069 DISALLOW_COPY_AND_ASSIGN(MockPropertyPage); 00070 }; 00071 } 00072 00073 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_MOCK_PROPERTY_PAGE_H_