Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
audacity::network_manager::CurlResponseFactory Class Referencefinal

#include <CurlResponseFactory.h>

Inheritance diagram for audacity::network_manager::CurlResponseFactory:
[legend]
Collaboration diagram for audacity::network_manager::CurlResponseFactory:
[legend]

Public Member Functions

 CurlResponseFactory ()
 
 ~CurlResponseFactory ()
 
void setProxy (const std::string &proxy) override
 
ResponsePtr performRequest (RequestVerb verb, const Request &request) override
 
ResponsePtr performRequest (RequestVerb verb, const Request &request, RequestPayloadStreamPtr payloadStream) override
 
ResponsePtr performRequest (RequestVerb verb, const Request &request, std::unique_ptr< MultipartData > form) override
 
void terminate () override
 
- Public Member Functions inherited from audacity::network_manager::IResponseFactory
virtual ~IResponseFactory ()=default
 
virtual void setProxy (const std::string &proxy)=0
 
virtual ResponsePtr performRequest (RequestVerb verb, const Request &request)=0
 
virtual ResponsePtr performRequest (RequestVerb verb, const Request &request, RequestPayloadStreamPtr payloadStream)=0
 
virtual ResponsePtr performRequest (RequestVerb verb, const Request &request, std::unique_ptr< MultipartData > form)=0
 
virtual void terminate ()=0
 

Private Attributes

std::unique_ptr< CurlHandleManagermHandleManager { std::make_unique<CurlHandleManager> () }
 
std::unique_ptr< ThreadPool > mThreadPool
 

Detailed Description

Definition at line 26 of file CurlResponseFactory.h.

Constructor & Destructor Documentation

◆ CurlResponseFactory()

audacity::network_manager::CurlResponseFactory::CurlResponseFactory ( )

Definition at line 128 of file CurlResponseFactory.cpp.

129 : mThreadPool (std::make_unique<ThreadPool>(
130 std::max (
132 std::thread::hardware_concurrency ()
133 )))
134{
135
136}
constexpr decltype(std::thread::hardware_concurrency()) MIN_CURL_THREADS

◆ ~CurlResponseFactory()

audacity::network_manager::CurlResponseFactory::~CurlResponseFactory ( )

Definition at line 138 of file CurlResponseFactory.cpp.

139{
140}

Member Function Documentation

◆ performRequest() [1/3]

ResponsePtr audacity::network_manager::CurlResponseFactory::performRequest ( RequestVerb  verb,
const Request request 
)
overridevirtual

Implements audacity::network_manager::IResponseFactory.

Definition at line 147 of file CurlResponseFactory.cpp.

148{
149 return performRequest(verb, request, RequestPayloadStreamPtr {});
150}
ResponsePtr performRequest(RequestVerb verb, const Request &request) override
std::shared_ptr< RequestPayloadStream > RequestPayloadStreamPtr
Definition: CurlResponse.h:33

References performRequest().

Referenced by performRequest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ performRequest() [2/3]

ResponsePtr audacity::network_manager::CurlResponseFactory::performRequest ( RequestVerb  verb,
const Request request,
RequestPayloadStreamPtr  payloadStream 
)
overridevirtual

Implements audacity::network_manager::IResponseFactory.

Definition at line 152 of file CurlResponseFactory.cpp.

155{
156 if (!mThreadPool)
157 return std::make_shared<StubResponse>(request);
158
159 auto response =
160 std::make_shared<CurlResponse>(verb, request, mHandleManager.get());
161
162 mThreadPool->enqueue(
163 [response, payloadStream = std::move(payloadStream)]()
164 {
165 if (payloadStream)
166 response->setPayload(payloadStream);
167
168 response->perform();
169 });
170
171 return response;
172}
std::unique_ptr< CurlHandleManager > mHandleManager

References mHandleManager, and mThreadPool.

◆ performRequest() [3/3]

ResponsePtr audacity::network_manager::CurlResponseFactory::performRequest ( RequestVerb  verb,
const Request request,
std::unique_ptr< MultipartData form 
)
overridevirtual

Implements audacity::network_manager::IResponseFactory.

Definition at line 174 of file CurlResponseFactory.cpp.

177{
178 if (!mThreadPool)
179 return std::make_shared<StubResponse>(request);
180
181 std::shared_ptr<CurlResponse> response =
182 std::make_shared<CurlResponse>(verb, request, mHandleManager.get());
183
184
185 mThreadPool->enqueue(
186 [response, rawForm = form.release()]() mutable
187 {
188 if (rawForm != nullptr && !rawForm->IsEmpty())
189 response->setForm(std::unique_ptr<MultipartData>(rawForm));
190
191 response->perform();
192 });
193
194 return response;
195}

References mHandleManager, and mThreadPool.

◆ setProxy()

void audacity::network_manager::CurlResponseFactory::setProxy ( const std::string &  proxy)
overridevirtual

Implements audacity::network_manager::IResponseFactory.

Definition at line 142 of file CurlResponseFactory.cpp.

143{
144 mHandleManager->setProxy (proxy);
145}

References mHandleManager.

◆ terminate()

void audacity::network_manager::CurlResponseFactory::terminate ( )
overridevirtual

Implements audacity::network_manager::IResponseFactory.

Definition at line 197 of file CurlResponseFactory.cpp.

198{
199 mThreadPool.reset ();
200 mHandleManager.reset ();
201}

References mHandleManager, and mThreadPool.

Member Data Documentation

◆ mHandleManager

std::unique_ptr<CurlHandleManager> audacity::network_manager::CurlResponseFactory::mHandleManager { std::make_unique<CurlHandleManager> () }
private

Definition at line 43 of file CurlResponseFactory.h.

Referenced by performRequest(), setProxy(), and terminate().

◆ mThreadPool

std::unique_ptr<ThreadPool> audacity::network_manager::CurlResponseFactory::mThreadPool
private

Definition at line 44 of file CurlResponseFactory.h.

Referenced by performRequest(), and terminate().


The documentation for this class was generated from the following files: