1 | // Aseprite |
2 | // Copyright (C) 2022 Igara Studio S.A. |
3 | // Copyright (C) 2001-2016 David Capello |
4 | // |
5 | // This program is distributed under the terms of |
6 | // the End-User License Agreement for Aseprite. |
7 | |
8 | #ifndef APP_RES_HTTP_LOADER_H_INCLUDED |
9 | #define APP_RES_HTTP_LOADER_H_INCLUDED |
10 | #pragma once |
11 | |
12 | #include "base/thread.h" |
13 | |
14 | #include <atomic> |
15 | #include <string> |
16 | |
17 | namespace net { |
18 | class HttpRequest; |
19 | } |
20 | |
21 | namespace app { |
22 | |
23 | class HttpLoader { |
24 | public: |
25 | HttpLoader(const std::string& url); |
26 | ~HttpLoader(); |
27 | |
28 | void abort(); |
29 | bool isDone() const { return m_done; } |
30 | std::string filename() const { return m_filename; } |
31 | |
32 | private: |
33 | void threadHttpRequest(); |
34 | |
35 | std::string m_url; |
36 | std::atomic<bool> m_done; |
37 | net::HttpRequest* m_request; |
38 | base::thread m_thread; |
39 | std::string m_filename; |
40 | }; |
41 | |
42 | } // namespace app |
43 | |
44 | #endif |
45 | |