Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mock_time_cache.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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 
26 
27 #ifndef PAGESPEED_KERNEL_CACHE_MOCK_TIME_CACHE_H_
28 #define PAGESPEED_KERNEL_CACHE_MOCK_TIME_CACHE_H_
29 
34 #include "pagespeed/kernel/cache/cache_interface.h"
35 
36 namespace net_instaweb {
37 
38 class Scheduler;
39 
41 class MockTimeCache : public CacheInterface {
42  public:
44  MockTimeCache(Scheduler* scheduler, CacheInterface* cache);
45  virtual ~MockTimeCache();
46 
48  virtual void Get(const GoogleString& key, Callback* callback);
49  virtual void Put(const GoogleString& key, const SharedString& value);
50  virtual void Delete(const GoogleString& key);
51 
55  void set_delay_us(int64 delay_us) { delay_us_ = delay_us; }
56  int64 delay_us() const { return delay_us_; }
57 
58  Scheduler* scheduler() { return scheduler_; }
59 
60  virtual GoogleString Name() const { return FormatName(cache_->Name()); }
61  static GoogleString FormatName(StringPiece name);
62  virtual bool IsBlocking() const { return cache_->IsBlocking(); }
63  virtual bool IsHealthy() const { return cache_->IsHealthy(); }
64  virtual void ShutDown() { cache_->ShutDown(); }
65 
66  private:
67  class DelayCallback;
68 
69  Scheduler* scheduler_;
70  CacheInterface* cache_;
71  int64 delay_us_;
72  GoogleString name_;
73 
74 
75 };
76 
77 }
78 
79 #endif
Abstract interface for a cache.
Definition: cache_interface.h:32
See file comment.
Definition: mock_time_cache.h:41
virtual void ShutDown()
Definition: mock_time_cache.h:64
MockTimeCache(Scheduler *scheduler, CacheInterface *cache)
Note: takes ownership of nothing.
virtual bool IsBlocking() const
Definition: mock_time_cache.h:62
void set_delay_us(int64 delay_us)
Definition: mock_time_cache.h:55
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual bool IsHealthy() const =0
virtual bool IsBlocking() const =0
Definition: shared_string.h:40
virtual void Get(const GoogleString &key, Callback *callback)
Reimplementations of CacheInterface methods.
virtual GoogleString Name() const
Definition: mock_time_cache.h:60
Definition: cache_interface.h:42
virtual bool IsHealthy() const
Definition: mock_time_cache.h:63
virtual void Put(const GoogleString &key, const SharedString &value)
Definition: scheduler.h:47
virtual GoogleString Name() const =0