libzypp 17.31.23
networkrequestdispatcher_p.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14#ifndef ZYPP_NG_MEDIA_CURL_PRIVATE_CURL_P_H_INCLUDED
15#define ZYPP_NG_MEDIA_CURL_PRIVATE_CURL_P_H_INCLUDED
16
18#include <zypp-core/zyppng/base/private/base_p.h>
19#include <curl/curl.h>
20#include <deque>
21#include <set>
22#include <unordered_map>
23
24namespace zyppng {
25
26class Timer;
27class SocketNotifier;
28
30{
31 ZYPP_DECLARE_PUBLIC(NetworkRequestDispatcher)
32public:
33 NetworkRequestDispatcherPrivate ( NetworkRequestDispatcher &p );
35
37
38 std::deque< std::shared_ptr<NetworkRequest> > _pendingDownloads;
39 std::vector< std::shared_ptr<NetworkRequest> > _runningDownloads;
40
41 std::shared_ptr<Timer> _timer;
42 std::map< curl_socket_t, std::shared_ptr<SocketNotifier> > _socketHandler;
43
44 bool _isRunning = false;
45 bool _locked = false; //if set to true, no new requests will be dequeued
46 CURLM *_multi = nullptr;
47
49
50 std::string _userAgent;
51 std::unordered_map< std::string, std::unordered_map<std::string, std::string> > _customHeaders;
52
53 //signals
54 Signal< void ( NetworkRequestDispatcher &, NetworkRequest & )> _sigDownloadStarted;
55 Signal< void ( NetworkRequestDispatcher &, NetworkRequest & )> _sigDownloadFinished;
56 Signal< void ( NetworkRequestDispatcher & )> _sigQueueFinished;
57 Signal< void ( NetworkRequestDispatcher & )> _sigError;
58
59private:
60 static int multi_timer_cb ( CURLM *multi, long timeout_ms, void *g );
61 static int static_socket_callback(CURL *easy, curl_socket_t s, int what, void *userp, SocketNotifier *socketp );
62
63 void multiTimerTimout ( const Timer &t );
64 int socketCallback(CURL *easy, curl_socket_t s, int what, void * );
65
66 void cancelAll ( NetworkRequestError result );
69
70 void onSocketActivated ( const SocketNotifier &listener, int events );
71
72 void handleMultiSocketAction ( curl_socket_t nativeSocket, int evBitmask );
73 void dequeuePending ();
74};
75}
76
77#endif
static int static_socket_callback(CURL *easy, curl_socket_t s, int what, void *userp, SocketNotifier *socketp)
int socketCallback(CURL *easy, curl_socket_t s, int what, void *)
Signal< void(NetworkRequestDispatcher &)> _sigError
Signal< void(NetworkRequestDispatcher &)> _sigQueueFinished
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > _customHeaders
void setFinished(NetworkRequest &req, NetworkRequestError result)
void handleMultiSocketAction(curl_socket_t nativeSocket, int evBitmask)
Signal< void(NetworkRequestDispatcher &, NetworkRequest &)> _sigDownloadFinished
std::map< curl_socket_t, std::shared_ptr< SocketNotifier > > _socketHandler
void onSocketActivated(const SocketNotifier &listener, int events)
Signal< void(NetworkRequestDispatcher &, NetworkRequest &)> _sigDownloadStarted
void cancelAll(NetworkRequestError result)
std::deque< std::shared_ptr< NetworkRequest > > _pendingDownloads
static int multi_timer_cb(CURLM *multi, long timeout_ms, void *g)
std::vector< std::shared_ptr< NetworkRequest > > _runningDownloads
The NetworkRequestError class Represents a error that occured in.