All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EmscriptenWebRequestService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IWebRequestService.h"
7 #include "Web.h"
8 #include "Tasks.h"
9 #include "ICallback.h"
10 #include "CallbackCollection.h"
11 #include <map>
12 #include <deque>
13 
14 namespace Eegeo
15 {
16  namespace Emscripten
17  {
19  {
20  public:
23 
24  void EnqueueLoad(Web::IWebLoadRequest* pWebRequest);
25  void EnqueueCancel(Web::IWebLoadRequest* pWebRequest);
26 
27  void Update();
28 
29  bool HasOngoingNetworkActivity() const;
30  void RegisterNetworkActivityChanged(Helpers::ICallback1<const bool&>& callback);
31  void UnregisterNetworkActivityChanged(Helpers::ICallback1<const bool&>& callback);
32 
33  private:
34  void ProcessPendingDeletedRequests();
35  void CheckNetworkActivityChanged();
36 
37  void HandleEmscriptenLoadedEvent(const Web::IWebLoadRequest& webRequest, const Web::TResourceData& bodyData);
38  void HandleEmscriptenErrorEvent(const Web::IWebLoadRequest& webRequest, const int& statusCode);
39 
42  std::map<const Web::IWebLoadRequest*, int> m_requestToActiveEmscriptenRequestId;
43  std::deque<const Web::IWebLoadRequest*> m_requestsToDelete;
44 
45  Helpers::CallbackCollection1<const bool&> m_networkActivityChangedCallbacks;
46  bool m_hasNetworkActivity;
47  };
48  }
49 }