Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mock_property_page.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 
18 
20 
21 #ifndef PAGESPEED_OPT_HTTP_MOCK_PROPERTY_PAGE_H_
22 #define PAGESPEED_OPT_HTTP_MOCK_PROPERTY_PAGE_H_
23 
29 
30 namespace net_instaweb {
31 
33  public:
34  MockPropertyPage(ThreadSystem* thread_system,
35  PropertyCache* property_cache,
36  const StringPiece& url,
37  const StringPiece& options_signature_hash,
38  const StringPiece& cache_key_suffix)
39  : PropertyPage(
40  kPropertyCachePage,
41  url,
42  options_signature_hash,
43  cache_key_suffix,
45  thread_system->NewMutex(), property_cache),
46  called_(false),
47  valid_(false),
48  time_ms_(-1) {}
49  virtual ~MockPropertyPage();
50  virtual bool IsCacheValid(int64 write_timestamp_ms) const {
51  return time_ms_ == -1 || write_timestamp_ms > time_ms_;
52  }
53  virtual void Done(bool valid) {
54  called_ = true;
55  valid_ = valid;
56  }
57 
58  bool called() const { return called_; }
59  bool valid() const { return valid_; }
60  void set_time_ms(int64 time_ms) {
61  time_ms_ = time_ms;
62  }
63 
64  private:
65  bool called_;
66  bool valid_;
67  int64 time_ms_;
68 
69 
70 };
71 }
72 
73 #endif
Definition: mock_property_page.h:32
Adds property-semantics to a raw cache API.
Definition: property_cache.h:180
PropertyPage(PageType page_type, StringPiece url, StringPiece options_signature_hash, StringPiece cache_key_suffix, const RequestContextPtr &request_context, AbstractMutex *mutex, PropertyCache *property_cache)
Definition: property_cache.h:323
virtual void Done(bool valid)
Called as a result of PropertyCache::Read when the data is available.
Definition: mock_property_page.h:53
virtual bool IsCacheValid(int64 write_timestamp_ms) const
Definition: mock_property_page.h:50
static RequestContextPtr NewTestRequestContext(ThreadSystem *thread_system)
Definition: request_context.h:66
Definition: thread_system.h:40
virtual CondvarCapableMutex * NewMutex()=0