All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WebServiceCacheStoreWorkItem.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Cache.h"
7 #include "WorkItem.h"
8 #include "Helpers.h"
9 #include "Web.h"
10 #include <string>
11 
12 namespace Eegeo
13 {
14  namespace Web
15  {
16  namespace Cache
17  {
18  namespace WebRequestCacheTasks
19  {
21  {
22  public:
24  : WorkItem(false)
25  , m_pHeaderData(NULL)
26  , m_headerDataLength(0)
27  , m_pBodyData(NULL)
28  , m_bodyDataLength(0)
29  , m_pFileIO(NULL)
30  , m_pHttpCache(NULL)
31  , m_webRequestServiceCallback(webRequestServiceCallback)
32  , m_active(false)
33  , m_success(false)
34  {
35  }
36 
37  virtual ~WebServiceCacheStoreWorkItem() {}
38 
39  //WebServiceCacheStoreWorkItem expects a resourceData it takes ownership of, and will delete[] when done
40  void Setup(
41  const std::string& url,
42  Helpers::IFileIO* fileIO,
43  Helpers::IHttpCache* httpCache,
44  Byte* headerData,
45  size_t headerDataLength,
46  Byte* resourceData,
47  size_t resourceDataLength);
48 
49  void DoWork();
50  void DoFinalizeOnMainThread();
51 
52  bool IsActive() const { return m_active; }
53 
54  private:
55  void AddToCache() const;
56 
57  Byte *m_pHeaderData;
58  size_t m_headerDataLength;
59  Byte *m_pBodyData;
60  size_t m_bodyDataLength;
61  std::string m_url;
62  Helpers::IFileIO* m_pFileIO;
63  Helpers::IHttpCache* m_pHttpCache;
65  bool m_active;
66  bool m_success;
67  };
68  }
69  }
70  }
71 }