All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HttpCache.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "IHttpCache.h"
6 #include "Types.h"
7 #include "Helpers.h"
8 #include "Cache.h"
9 #include "CacheModel.h"
10 #include "CacheModelSerializer.h"
11 #include "CachePruner.h"
12 #include <vector>
13 #include <string>
14 
15 namespace Eegeo
16 {
17  namespace Web
18  {
19  namespace Cache
20  {
22  {
23  public:
24  HttpCache(
25  Helpers::IFileIO& fileIO,
26  Eegeo::Helpers::CacheSize_t maxCacheSizeBytes=(4294967296ULL));
27 
28  virtual ~HttpCache() {}
29 
30  virtual void AddToCache(const Eegeo::Web::Cache::CacheRecord& cacheRecordToAdd);
31 
32  virtual void RemoveFromCache(const std::string& url);
33 
34  virtual bool TryGetCachedHeaderInfo(
35  const std::string& url,
36  std::string& out_cachedETag,
37  std::string& out_cachedLastModified);
38 
39  virtual void GetFileNameByUrl(std::string& name, const std::string& url);
40  virtual void SetMaxCacheSize(Helpers::CacheSize_t size);
41  virtual void ClearCache();
42  virtual bool IsInCache(const std::string& url);
43  virtual void FlushInMemoryCacheRepresentation(bool prune);
44  virtual void ReloadCacheRepresentationFromStorage();
45  virtual bool LoadLocallyCachedData(const std::string& url, std::vector<Byte>& out_buffer);
46  virtual bool GetEnabled();
47  virtual void SetEnabled(bool enabled);
48 
49  private:
50  Helpers::IFileIO& m_fileIO;
51  CacheModel m_cacheModel;
52  CacheModelSerializer m_modelSerializer;
53  CachePruner m_cachePruner;
54  Eegeo::Helpers::CacheSize_t m_maxCacheSizeBytes;
55 
56  bool m_enabled;
57 
58  static const std::string Manifest;
59  };
60  }
61  }
62 }